Updated and revised some tests

This commit is contained in:
2026-05-19 11:24:49 +10:00
parent 414a9d6194
commit a0d75b3c70
20 changed files with 49 additions and 54 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ void Toy_private_appendAstBlock(Toy_Bucket** bucketHandle, Toy_Ast* block, Toy_A
//first, check if we're an empty head //first, check if we're an empty head
if (block->block.child == NULL) { if (block->block.child == NULL) {
block->block.child = child; block->block.child = child;
return; //NOTE: first call on an empty head skips any memory allocations return; //First call on an empty head skips any memory allocations
} }
//run (or jump) until we hit the current tail //run (or jump) until we hit the current tail
+1 -2
View File
@@ -1287,8 +1287,7 @@ static unsigned int writeBytecodeFromAst(Toy_Bytecode** mb, Toy_Ast* ast) {
break; break;
case TOY_AST_END: case TOY_AST_END:
fprintf(stderr, TOY_CC_ERROR "COMPILER ERROR: Invalid AST type found: Unknown 'end'\n" TOY_CC_RESET); //NO-OP
(*mb)->panic = true;
break; break;
} }
+1
View File
@@ -0,0 +1 @@
//TODO: empty test script
-9
View File
@@ -1,9 +0,0 @@
//these are allowed
/* EMPTY */;
if (true) { }
if (true) pass;
//these are not allowed
// if (true) /* EMPTY */;
+1
View File
@@ -0,0 +1 @@
//TODO: empty test script
+2
View File
@@ -11,3 +11,5 @@ assert 1 < 2;
//assert with an optional message //assert with an optional message
assert true, "Assertion message"; assert true, "Assertion message";
//TODO: add mustfails
+16 -19
View File
@@ -1,65 +1,62 @@
//literals //literals
if (true) { if (true) {
print "Success 1"; assert true, "if-then-else 1";
} }
else { else {
print "Failure 1"; assert false, "if-then-else 1";
} }
//false literals //false literals
if (false) { if (false) {
print "Failure 2"; assert false, "if-then-else 2";
} }
else { else {
print "Success 2"; assert true, "if-then-else 2";
} }
//conditionals //conditionals
if (1 < 2) { if (1 < 2) {
print "Success 3"; assert true, "if-then-else 3";
} }
if (1 > 2) { if (1 > 2) {
print "Failure 3"; assert false, "if-then-else 3";
} }
//variables //variables
var a = 42; var a = 42;
if (a) { if (a) {
print "Success 4"; assert true, "if-then-else 4";
} }
else { else {
print "Failure 4"; assert false, "if-then-else 4";
} }
if (a == 42) { if (a == 42) {
print "Success 5"; assert true, "if-then-else 5";
} }
else { else {
print "Failure 5"; assert false, "if-then-else 5";
} }
//concatenated strings //concatenated strings
if ("foo" .. "bar" == "foobar") { if ("foo" .. "bar" == "foobar") {
print "Success 6"; assert true, "if-then-else 6";
} }
else { else {
print "Failure 6"; assert false, "if-then-else 6";
} }
if ("foobar" == "foo" .. "bar") { if ("foobar" == "foo" .. "bar") {
print "Success 7"; assert true, "if-then-else 7";
} }
else { else {
print "Failure 7"; assert false, "if-then-else 7";
} }
if ("fizz" .. "le" == "fi" .. "zzle") { if ("fizz" .. "le" == "fi" .. "zzle") {
print "Success 8"; assert true, "if-then-else 8";
} }
else { else {
print "Failure 8"; assert false, "if-then-else 8";
} }
@@ -1,46 +1,46 @@
//literals //literals
if (true) if (true)
print "Success 1"; assert true, "if-then-else 1";
else else
print "Failure 1"; assert false, "if-then-else 1";
//false literals //false literals
if (false) if (false)
print "Failure 2"; assert false, "if-then-else 2";
else else
print "Success 2"; assert true, "if-then-else 2";
//conditionals //conditionals
if (1 < 2) if (1 < 2)
print "Success 3"; assert true, "if-then-else 3";
if (1 > 2) if (1 > 2)
print "Failure 3"; assert false, "if-then-else 3";
//variables //variables
var a = 42; var a = 42;
if (a) if (a)
print "Success 4"; assert true, "if-then-else 4";
else else
print "Failure 4"; assert false, "if-then-else 4";
if (a == 42) if (a == 42)
print "Success 5"; assert true, "if-then-else 5";
else else
print "Failure 5"; assert false, "if-then-else 5";
//concatenated strings //concatenated strings
if ("foo" .. "bar" == "foobar") if ("foo" .. "bar" == "foobar")
print "Success 6"; assert true, "if-then-else 6";
else else
print "Failure 6"; assert false, "if-then-else 6";
if ("foobar" == "foo" .. "bar") if ("foobar" == "foo" .. "bar")
print "Success 7"; assert true, "if-then-else 7";
else else
print "Failure 7"; assert false, "if-then-else 7";
if ("fizz" .. "le" == "fi" .. "zzle") if ("fizz" .. "le" == "fi" .. "zzle")
print "Success 8"; assert true, "if-then-else 8";
else else
print "Failure 8"; assert false, "if-then-else 8";
+7 -6
View File
@@ -1,17 +1,18 @@
//shadowing //shadowing
var answer = 42; var answer = 42;
print answer; //42
assert answer == 42;
{ {
var answer = 7; var answer = 7;
print answer; //7 assert answer == 7;
} }
print answer; //42 assert answer == 42;
//rebinding //rebinding
var question = 42; var question = 42;
print question; //42 assert question == 42;
{ {
var question = question; var question = question;
print question; //42 assert question == 42;
} }
print question; //42 assert question == 42;
View File
@@ -0,0 +1 @@
//This file left intentionally blank
+1 -1
View File
@@ -157,4 +157,4 @@ print !false; //true
print a; print a;
} }
//TODO: type casting //TODO: type casting
@@ -4,6 +4,7 @@
#include <string.h> #include <string.h>
int main(void) { int main(void) {
//TODO: Test not yet implemented
printf(TOY_CC_WARN "Test not yet implemented: %s\n" TOY_CC_RESET, __FILE__); printf(TOY_CC_WARN "Test not yet implemented: %s\n" TOY_CC_RESET, __FILE__);
return 0; return 0;
} }
+1
View File
@@ -117,6 +117,7 @@ int test_functions_from_bytecodes(void) {
} }
int test_functions_from_callbacks(void) { int test_functions_from_callbacks(void) {
//TODO: Test not yet implemented
printf(TOY_CC_WARN "WIP test not yet implemented: %s\n" TOY_CC_RESET, __FILE__); printf(TOY_CC_WARN "WIP test not yet implemented: %s\n" TOY_CC_RESET, __FILE__);
return 0; return 0;
} }