Updated and revised some tests
This commit is contained in:
+1
-1
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
//TODO: empty test script
|
||||
@@ -1,9 +0,0 @@
|
||||
//these are allowed
|
||||
/* EMPTY */;
|
||||
if (true) { }
|
||||
if (true) pass;
|
||||
|
||||
|
||||
//these are not allowed
|
||||
// if (true) /* EMPTY */;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
//TODO: empty test script
|
||||
@@ -11,3 +11,5 @@ assert 1 < 2;
|
||||
|
||||
//assert with an optional message
|
||||
assert true, "Assertion message";
|
||||
|
||||
//TODO: add mustfails
|
||||
@@ -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";
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
//This file left intentionally blank
|
||||
@@ -157,4 +157,4 @@ print !false; //true
|
||||
print a;
|
||||
}
|
||||
|
||||
//TODO: type casting
|
||||
//TODO: type casting
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <string.h>
|
||||
|
||||
int main(void) {
|
||||
//TODO: Test not yet implemented
|
||||
printf(TOY_CC_WARN "Test not yet implemented: %s\n" TOY_CC_RESET, __FILE__);
|
||||
return 0;
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user