diff --git a/source/toy_ast.c b/source/toy_ast.c index bb7de9d..5269df9 100644 --- a/source/toy_ast.c +++ b/source/toy_ast.c @@ -16,7 +16,7 @@ void Toy_private_appendAstBlock(Toy_Bucket** bucketHandle, Toy_Ast* block, Toy_A //first, check if we're an empty head if (block->block.child == NULL) { 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 diff --git a/source/toy_compiler.c b/source/toy_compiler.c index 51e4d05..5c0621e 100644 --- a/source/toy_compiler.c +++ b/source/toy_compiler.c @@ -1287,8 +1287,7 @@ static unsigned int writeBytecodeFromAst(Toy_Bytecode** mb, Toy_Ast* ast) { break; case TOY_AST_END: - fprintf(stderr, TOY_CC_ERROR "COMPILER ERROR: Invalid AST type found: Unknown 'end'\n" TOY_CC_RESET); - (*mb)->panic = true; + //NO-OP break; } diff --git a/tests/scripts/test_fibonacci.toy b/tests/scripts/test_algo_fibonacci.toy similarity index 100% rename from tests/scripts/test_fibonacci.toy rename to tests/scripts/test_algo_fibonacci.toy diff --git a/tests/scripts/test_arrays.toy b/tests/scripts/test_array.toy similarity index 100% rename from tests/scripts/test_arrays.toy rename to tests/scripts/test_array.toy diff --git a/tests/scripts/test_attribute.toy b/tests/scripts/test_attribute.toy new file mode 100644 index 0000000..e2f2524 --- /dev/null +++ b/tests/scripts/test_attribute.toy @@ -0,0 +1 @@ +//TODO: empty test script \ No newline at end of file diff --git a/tests/scripts/test_control_flow.toy b/tests/scripts/test_control_flow.toy deleted file mode 100644 index 2b98bd7..0000000 --- a/tests/scripts/test_control_flow.toy +++ /dev/null @@ -1,9 +0,0 @@ -//these are allowed -/* EMPTY */; -if (true) { } -if (true) pass; - - -//these are not allowed -// if (true) /* EMPTY */; - diff --git a/tests/scripts/test_closures.toy b/tests/scripts/test_function_closures.toy similarity index 100% rename from tests/scripts/test_closures.toy rename to tests/scripts/test_function_closures.toy diff --git a/tests/scripts/test_first_class_functions.toy b/tests/scripts/test_function_first_class_citizens.toy similarity index 100% rename from tests/scripts/test_first_class_functions.toy rename to tests/scripts/test_function_first_class_citizens.toy diff --git a/tests/scripts/test_functions.toy b/tests/scripts/test_functions.toy new file mode 100644 index 0000000..e2f2524 --- /dev/null +++ b/tests/scripts/test_functions.toy @@ -0,0 +1 @@ +//TODO: empty test script \ No newline at end of file diff --git a/tests/scripts/test_keyword_assert.toy b/tests/scripts/test_keyword_assert.toy index 154d2bd..1767db9 100644 --- a/tests/scripts/test_keyword_assert.toy +++ b/tests/scripts/test_keyword_assert.toy @@ -11,3 +11,5 @@ assert 1 < 2; //assert with an optional message assert true, "Assertion message"; + +//TODO: add mustfails \ No newline at end of file diff --git a/tests/scripts/test_keyword_for_break_continue.toy b/tests/scripts/test_keyword_for_break_continue.toy new file mode 100644 index 0000000..e69de29 diff --git a/tests/scripts/test_keyword_if_then_else.toy b/tests/scripts/test_keyword_if_then_else.toy index 9fe8d5e..9a00fac 100644 --- a/tests/scripts/test_keyword_if_then_else.toy +++ b/tests/scripts/test_keyword_if_then_else.toy @@ -1,65 +1,62 @@ //literals if (true) { - print "Success 1"; + assert true, "if-then-else 1"; } else { - print "Failure 1"; + assert false, "if-then-else 1"; } //false literals if (false) { - print "Failure 2"; + assert false, "if-then-else 2"; } else { - print "Success 2"; + assert true, "if-then-else 2"; } //conditionals if (1 < 2) { - print "Success 3"; + assert true, "if-then-else 3"; } if (1 > 2) { - print "Failure 3"; + assert false, "if-then-else 3"; } - //variables var a = 42; if (a) { - print "Success 4"; + assert true, "if-then-else 4"; } else { - print "Failure 4"; + assert false, "if-then-else 4"; } - if (a == 42) { - print "Success 5"; + assert true, "if-then-else 5"; } else { - print "Failure 5"; + assert false, "if-then-else 5"; } //concatenated strings if ("foo" .. "bar" == "foobar") { - print "Success 6"; + assert true, "if-then-else 6"; } else { - print "Failure 6"; + assert false, "if-then-else 6"; } - if ("foobar" == "foo" .. "bar") { - print "Success 7"; + assert true, "if-then-else 7"; } else { - print "Failure 7"; + assert false, "if-then-else 7"; } if ("fizz" .. "le" == "fi" .. "zzle") { - print "Success 8"; + assert true, "if-then-else 8"; } else { - print "Failure 8"; + assert false, "if-then-else 8"; } diff --git a/tests/scripts/test_keyword_if_then_else_no_braces.toy b/tests/scripts/test_keyword_if_then_else_no_braces.toy index 9aeeb42..c432f00 100644 --- a/tests/scripts/test_keyword_if_then_else_no_braces.toy +++ b/tests/scripts/test_keyword_if_then_else_no_braces.toy @@ -1,46 +1,46 @@ //literals if (true) - print "Success 1"; + assert true, "if-then-else 1"; else - print "Failure 1"; + assert false, "if-then-else 1"; //false literals if (false) - print "Failure 2"; + assert false, "if-then-else 2"; else - print "Success 2"; + assert true, "if-then-else 2"; //conditionals if (1 < 2) - print "Success 3"; + assert true, "if-then-else 3"; if (1 > 2) - print "Failure 3"; + assert false, "if-then-else 3"; //variables var a = 42; if (a) - print "Success 4"; + assert true, "if-then-else 4"; else - print "Failure 4"; + assert false, "if-then-else 4"; if (a == 42) - print "Success 5"; + assert true, "if-then-else 5"; else - print "Failure 5"; + assert false, "if-then-else 5"; //concatenated strings if ("foo" .. "bar" == "foobar") - print "Success 6"; + assert true, "if-then-else 6"; else - print "Failure 6"; + assert false, "if-then-else 6"; if ("foobar" == "foo" .. "bar") - print "Success 7"; + assert true, "if-then-else 7"; else - print "Failure 7"; + assert false, "if-then-else 7"; if ("fizz" .. "le" == "fi" .. "zzle") - print "Success 8"; + assert true, "if-then-else 8"; else - print "Failure 8"; + assert false, "if-then-else 8"; diff --git a/tests/scripts/test_scopes.toy b/tests/scripts/test_scopes.toy index 985267b..02ae591 100644 --- a/tests/scripts/test_scopes.toy +++ b/tests/scripts/test_scopes.toy @@ -1,17 +1,18 @@ //shadowing var answer = 42; -print answer; //42 + +assert answer == 42; { var answer = 7; - print answer; //7 + assert answer == 7; } -print answer; //42 +assert answer == 42; //rebinding var question = 42; -print question; //42 +assert question == 42; { var question = question; - print question; //42 + assert question == 42; } -print question; //42 +assert question == 42; diff --git a/tests/scripts/test_source_empty.toy b/tests/scripts/test_source_empty.toy new file mode 100644 index 0000000..e69de29 diff --git a/tests/scripts/test_source_empty_with_comments.toy b/tests/scripts/test_source_empty_with_comments.toy new file mode 100644 index 0000000..f062d8b --- /dev/null +++ b/tests/scripts/test_source_empty_with_comments.toy @@ -0,0 +1 @@ +//This file left intentionally blank \ No newline at end of file diff --git a/tests/scripts/test_case_sensitive_types.toy b/tests/scripts/test_type_names.toy similarity index 100% rename from tests/scripts/test_case_sensitive_types.toy rename to tests/scripts/test_type_names.toy diff --git a/tests/scripts/test_variables.toy b/tests/scripts/test_variables.toy index ab1e397..82c15cb 100644 --- a/tests/scripts/test_variables.toy +++ b/tests/scripts/test_variables.toy @@ -157,4 +157,4 @@ print !false; //true print a; } -//TODO: type casting +//TODO: type casting \ No newline at end of file diff --git a/tests/units/test_attributes.c b/tests/units/test_attribute.c similarity index 84% rename from tests/units/test_attributes.c rename to tests/units/test_attribute.c index 303b58a..9b811ec 100644 --- a/tests/units/test_attributes.c +++ b/tests/units/test_attribute.c @@ -4,6 +4,7 @@ #include int main(void) { + //TODO: Test not yet implemented printf(TOY_CC_WARN "Test not yet implemented: %s\n" TOY_CC_RESET, __FILE__); return 0; } \ No newline at end of file diff --git a/tests/units/test_function.c b/tests/units/test_function.c index 37979d4..49239f3 100644 --- a/tests/units/test_function.c +++ b/tests/units/test_function.c @@ -117,6 +117,7 @@ int test_functions_from_bytecodes(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__); return 0; }