new testing infrastructure

This commit is contained in:
Francesco Cozzuto
2023-01-22 02:22:44 +01:00
parent 533cf01920
commit 1780826a97
145 changed files with 1432 additions and 938 deletions
@@ -0,0 +1,16 @@
@type [compiler]
@source
fun X() {}
@bytecode
PUSHFUN fun, 0, "X";
JUMP end;
fun:
RETURN 0;
end:
ASS "X";
POP 1;
EXIT;
@@ -0,0 +1,18 @@
@type [compiler]
@source
fun X() "Hello, world!";
@bytecode
PUSHFUN fun, 0, "X";
JUMP end;
fun:
PUSHSTR "Hello, world!";
POP 1;
RETURN 0;
end:
ASS "X";
POP 1;
EXIT;
@@ -0,0 +1,23 @@
@type [compiler]
@source
fun X() {
"Hello, world!";
return false;
}
@bytecode
PUSHFUN fun, 0, "X";
JUMP end;
fun:
PUSHSTR "Hello, world!";
POP 1;
PUSHFLS;
RETURN 1;
RETURN 0;
end:
ASS "X";
POP 1;
EXIT;
@@ -0,0 +1,22 @@
@type [compiler]
@source
fun nop(a) {
return a;
}
@bytecode
PUSHFUN fun, 1, "nop";
JUMP end;
fun:
ASS "a";
POP 1;
PUSHVAR "a";
RETURN 1;
RETURN 0;
end:
ASS "nop";
POP 1;
EXIT;
@@ -0,0 +1,26 @@
@type [compiler]
@source
fun add(a, b) {
return a + b;
}
@bytecode
PUSHFUN fun, 2, "add";
JUMP end;
fun:
ASS "b";
POP 1;
ASS "a";
POP 1;
PUSHVAR "a";
PUSHVAR "b";
ADD;
RETURN 1;
RETURN 0;
end:
ASS "add";
POP 1;
EXIT;
@@ -0,0 +1,24 @@
@type [compiler]
@source
fun nop(a: None) {
return a;
}
@bytecode
PUSHFUN fun, 1, "nop";
JUMP end;
fun:
PUSHVAR "None";
CHECKTYPE 0, "a";
ASS "a";
POP 1;
PUSHVAR "a";
RETURN 1;
RETURN 0;
end:
ASS "nop";
POP 1;
EXIT;
@@ -0,0 +1,28 @@
@type [compiler]
@source
fun add(a: int, b) {
return a + b;
}
@bytecode
PUSHFUN fun, 2, "add";
JUMP end;
fun:
ASS "b";
POP 1;
PUSHVAR "int";
CHECKTYPE 0, "a";
ASS "a";
POP 1;
PUSHVAR "a";
PUSHVAR "b";
ADD;
RETURN 1;
RETURN 0;
end:
ASS "add";
POP 1;
EXIT;
@@ -0,0 +1,28 @@
@type [compiler]
@source
fun add(a, b: int) {
return a + b;
}
@bytecode
PUSHFUN fun, 2, "add";
JUMP end;
fun:
PUSHVAR "int";
CHECKTYPE 1, "b";
ASS "b";
POP 1;
ASS "a";
POP 1;
PUSHVAR "a";
PUSHVAR "b";
ADD;
RETURN 1;
RETURN 0;
end:
ASS "add";
POP 1;
EXIT;
@@ -0,0 +1,30 @@
@type [compiler]
@source
fun add(a: int, b: int) {
return a + b;
}
@bytecode
PUSHFUN fun, 2, "add";
JUMP end;
fun:
PUSHVAR "int";
CHECKTYPE 1, "b";
ASS "b";
POP 1;
PUSHVAR "int";
CHECKTYPE 0, "a";
ASS "a";
POP 1;
PUSHVAR "a";
PUSHVAR "b";
ADD;
RETURN 1;
RETURN 0;
end:
ASS "add";
POP 1;
EXIT;
@@ -0,0 +1,34 @@
@type [compiler]
@source
fun add(a: int | float, b: bool | Map) {
return a + b;
}
@bytecode
PUSHFUN fun, 2, "add";
JUMP end;
fun:
PUSHVAR "bool";
PUSHVAR "Map";
STP;
CHECKTYPE 1, "b";
ASS "b";
POP 1;
PUSHVAR "int";
PUSHVAR "float";
STP;
CHECKTYPE 0, "a";
ASS "a";
POP 1;
PUSHVAR "a";
PUSHVAR "b";
ADD;
RETURN 1;
RETURN 0;
end:
ASS "add";
POP 1;
EXIT;
@@ -0,0 +1,26 @@
@type [compiler]
@source
fun nop(a = 1)
{}
@bytecode
PUSHFUN nop, 1, "nop";
JUMP nop_end;
nop:
PUSHTYP;
PUSHNNETYP;
EQL;
JUMPIFNOTANDPOP not_none;
POP 1;
PUSHINT 1;
not_none:
ASS "a";
POP 1;
RETURN 0;
nop_end:
ASS "nop";
POP 1;
EXIT;
@@ -0,0 +1,28 @@
@type [compiler]
@source
fun nop(a = 1, b)
{}
@bytecode
PUSHFUN nop, 2, "nop";
JUMP nop_end;
nop:
ASS "b";
POP 1;
PUSHTYP;
PUSHNNETYP;
EQL;
JUMPIFNOTANDPOP not_none;
POP 1;
PUSHINT 1;
not_none:
ASS "a";
POP 1;
RETURN 0;
nop_end:
ASS "nop";
POP 1;
EXIT;
@@ -0,0 +1,28 @@
@type [compiler]
@source
fun nop(a, b = true)
{}
@bytecode
PUSHFUN nop, 2, "nop";
JUMP nop_end;
nop:
PUSHTYP;
PUSHNNETYP;
EQL;
JUMPIFNOTANDPOP not_none;
POP 1;
PUSHTRU;
not_none:
ASS "b";
POP 1;
ASS "a";
POP 1;
RETURN 0;
nop_end:
ASS "nop";
POP 1;
EXIT;
@@ -0,0 +1,28 @@
@type [compiler]
@source
fun nop(a: int = 1)
{}
@bytecode
PUSHFUN nop, 1, "nop";
JUMP nop_end;
nop:
PUSHTYP;
PUSHNNETYP;
EQL;
JUMPIFNOTANDPOP not_none;
POP 1;
PUSHINT 1;
not_none:
PUSHVAR "int";
CHECKTYPE 0, "a";
ASS "a";
POP 1;
RETURN 0;
nop_end:
ASS "nop";
POP 1;
EXIT;