Tests... LOTS OF TESTS

This commit is contained in:
apio 2022-08-26 17:05:03 +02:00
parent 6ce5d406bb
commit 792a689005
44 changed files with 222 additions and 45 deletions

View File

@ -0,0 +1,9 @@
{
"file": "body-invalid-expr.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/body-invalid-expr.sp:2:7: \u001b[31;49merror: \u001b[0;0mInvalid syntax\n2 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

View File

@ -1,3 +1,3 @@
let @main : i32 in {
1 + 3 * 5
0 5 +
}

View File

@ -0,0 +1,9 @@
{
"file": "body-not-math-expr.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/body-not-math-expr.sp:2:5: \u001b[31;49merror: \u001b[0;0mexpected a number\n2 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

View File

@ -0,0 +1,3 @@
let @main : i32 in {
syscall1(60, 1); // sys_exit(1)
}

9
tests/declare-main.json Normal file
View File

@ -0,0 +1,9 @@
{
"file": "declare-main.sp",
"compile": {
"flags": [],
"exit-code": 0,
"stdout": "",
"stderr": ""
}
}

1
tests/declare-main.sp Normal file
View File

@ -0,0 +1 @@
let @main : i32;

9
tests/empty-let.json Normal file
View File

@ -0,0 +1,9 @@
{
"file": "empty-let.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/empty-let.sp:1:4: \u001b[31;49merror: \u001b[0;0mExpected @\n1 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

1
tests/empty-let.sp Normal file
View File

@ -0,0 +1 @@
let;

9
tests/empty.json Normal file
View File

@ -0,0 +1,9 @@
{
"file": "empty.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/empty.sp:1:1: \u001b[31;49merror: \u001b[0;0mExpected let\n1 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

0
tests/empty.sp Normal file
View File

View File

@ -0,0 +1,14 @@
{
"file": "exit-failure-calculated.sp",
"compile": {
"flags": [],
"exit-code": 0,
"stdout": "",
"stderr": ""
},
"run": {
"exit-code": 3,
"stdout": "",
"stderr": ""
}
}

View File

@ -0,0 +1,3 @@
let @main : i32 in {
15 / 3 - 2
}

View File

@ -1,5 +1,5 @@
{
"file": "calc.sp",
"file": "exit-failure.sp",
"compile": {
"flags": [],
"exit-code": 0,
@ -7,7 +7,7 @@
"stderr": ""
},
"run": {
"exit-code": 16,
"exit-code": 1,
"stdout": "",
"stderr": ""
}

3
tests/exit-failure.sp Normal file
View File

@ -0,0 +1,3 @@
let @main : i32 in {
1
}

View File

@ -0,0 +1,14 @@
{
"file": "exit-success-calculated.sp",
"compile": {
"flags": [],
"exit-code": 0,
"stdout": "",
"stderr": ""
},
"run": {
"exit-code": 0,
"stdout": "",
"stderr": ""
}
}

View File

@ -0,0 +1,3 @@
let @main : i32 in {
3 * 5 - 15
}

14
tests/exit-success.json Normal file
View File

@ -0,0 +1,14 @@
{
"file": "exit-success.sp",
"compile": {
"flags": [],
"exit-code": 0,
"stdout": "",
"stderr": ""
},
"run": {
"exit-code": 0,
"stdout": "",
"stderr": ""
}
}

3
tests/exit-success.sp Normal file
View File

@ -0,0 +1,3 @@
let @main : i32 in {
0
}

9
tests/float-expr.json Normal file
View File

@ -0,0 +1,9 @@
{
"file": "float-expr.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1m\u001b[31;49merror: \u001b[0;0mInvalid function main\n"
}
}

3
tests/float-expr.sp Normal file
View File

@ -0,0 +1,3 @@
let @main : i32 in {
3.141592
}

View File

@ -0,0 +1,9 @@
{
"file": "function-no-in.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/function-no-in.sp:1:17: \u001b[31;49merror: \u001b[0;0mExpected 'in' or semicolon\n1 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

3
tests/function-no-in.sp Normal file
View File

@ -0,0 +1,3 @@
let @main : i32 {
0
}

View File

@ -1,9 +0,0 @@
{
"file": "import-inexistent.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/import-inexistent.sp:1:1: \u001b[31;49merror: \u001b[0;0mExpected let\n1 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

View File

@ -1,5 +0,0 @@
import penguin_boi;
let @main in {
6 + 3
}

9
tests/invalid-type.json Normal file
View File

@ -0,0 +1,9 @@
{
"file": "invalid-type.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/invalid-type.sp:1:13: \u001b[31;49merror: \u001b[0;0mExpected type name\n1 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

3
tests/invalid-type.sp Normal file
View File

@ -0,0 +1,3 @@
let @main : u56 in {
0
}

View File

@ -0,0 +1,9 @@
{
"file": "lex-multiple-periods.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "\u001b[1;1mtests/lex-multiple-periods.sp:2:9: \u001b[33;49mwarning: \u001b[0;0mfloats can only have one dot\n2 3.45.6\n \u001b[33;49m^\u001b[0;0m\n",
"stderr": "\u001b[1;1mtests/lex-multiple-periods.sp:2:9: \u001b[31;49merror: \u001b[0;0mInvalid syntax\n2 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

View File

@ -0,0 +1,3 @@
let @main : i32 in {
3.45.6
}

View File

@ -0,0 +1,9 @@
{
"file": "lex-unfinished-string.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/lex-unfinished-string.sp:2:19: \u001b[31;49merror: \u001b[0;0mexpected end of string but got newline\n2 'This is a test\n \u001b[31;49m^\u001b[0;0m\n"
}
}

View File

@ -0,0 +1,3 @@
let @main : i32 in {
'This is a test
}

View File

@ -0,0 +1,9 @@
{
"file": "lex-unknown-symbol.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/lex-unknown-symbol.sp:2:5: \u001b[31;49merror: \u001b[0;0munknown character\n2 %4\n \u001b[31;49m^\u001b[0;0m\n"
}
}

View File

@ -0,0 +1,3 @@
let @main : i32 in {
%4
}

9
tests/missing-main.json Normal file
View File

@ -0,0 +1,9 @@
{
"file": "missing-main.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1m\u001b[31;49merror: \u001b[0;0mMissing entry point: main\n"
}
}

1
tests/missing-main.sp Normal file
View File

@ -0,0 +1 @@
let @hello : i64;

View File

@ -1,9 +0,0 @@
{
"file": "simple.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/simple.sp:1:1: \u001b[31;49merror: \u001b[0;0mExpected let\n1 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

View File

@ -1,5 +0,0 @@
const { outln } from @'core/io';
let @main in {
outln('Hello, world!');
}

View File

@ -0,0 +1,9 @@
{
"file": "unended-function.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/unended-function.sp:1:11: \u001b[31;49merror: \u001b[0;0mExpected 'in', colon or semicolon\n1 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

View File

@ -0,0 +1 @@
let @main

View File

@ -0,0 +1,9 @@
{
"file": "unmatched-bracket.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/unmatched-bracket.sp:2:7: \u001b[31;49merror: \u001b[0;0mInvalid syntax\n2 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

View File

@ -0,0 +1,2 @@
let @main : i32 in {
0

View File

@ -0,0 +1,9 @@
{
"file": "unmatched-type.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1m\u001b[31;49merror: \u001b[0;0mInvalid function main\n"
}
}

3
tests/unmatched-type.sp Normal file
View File

@ -0,0 +1,3 @@
let @main : void in {
0
}

View File

@ -1,9 +0,0 @@
{
"file": "wimport.sp",
"compile": {
"flags": [],
"exit-code": 1,
"stdout": "",
"stderr": "\u001b[1;1mtests/wimport.sp:1:1: \u001b[31;49merror: \u001b[0;0mExpected let\n1 \n \u001b[31;49m^\u001b[0;0m\n"
}
}

View File

@ -1,5 +0,0 @@
import tests/wimport;
let @main in {
0
}