feat: add new tests

This commit is contained in:
samsonium
2026-10-21 04:00:03 +03:00
parent 80f07dc7c6
commit e49ebba346
13 changed files with 145 additions and 99 deletions
+2
View File
@@ -0,0 +1,2 @@
printline(1 + );
+3
View File
@@ -0,0 +1,3 @@
int value = 42
printline(value);
+4
View File
@@ -0,0 +1,4 @@
if (true)
{
printline("missing closing brace");
@@ -0,0 +1,2 @@
printline("unterminated string);
+7
View File
@@ -0,0 +1,7 @@
// Arithmetic precedence and operators.
printline(2 + 2 * 2);
printline(-1 + 1);
printline(2 ^ 2);
printline(4 % 2);
printline(10 / 2);
+25
View File
@@ -0,0 +1,25 @@
class Point
{
int x;
int y;
fn move(int dx, int dy)
{
this.x = this.x + dx;
this.y = this.y + dy;
}
}
Point point = new Point;
point.x = 1;
point.y = 2;
point.move(9, 8);
if (point.x == 10 && point.y == 10)
printline("class method passed");
else
{
printline("class method failed");
exit(1);
}
+5
View File
@@ -0,0 +1,5 @@
// Line comments are ignored by the parser.
printline('single-quoted string');;;;;
printline("");
printline("double-quoted string");
+21
View File
@@ -0,0 +1,21 @@
bool flag = true;
if (!flag)
{
printline("unexpected false");
exit(1);
}
else if (2 + 2 >= 4)
{
printline("condition passed");
}
else
{
printline("unexpected branch");
exit(1);
}
{
printline("standalone block");
}
+21
View File
@@ -0,0 +1,21 @@
fn fib(int n) int
{
if (n <= 1)
return n;
return fib(n - 1) + fib(n - 2);
}
fn sum(uint a, uint b) uint
{
return a + b;
}
if (fib(7) == 13 && sum(2, 2) == 4)
printline("functions passed");
else
{
printline("functions failed");
exit(1);
}
+23
View File
@@ -0,0 +1,23 @@
class Item
{
int value;
}
fn maybe_item(bool create) Item
{
if (create)
return new Item;
return null;
}
Item empty = maybe_item(false);
Item present = maybe_item(true);
if (empty == null && present != null)
printline("null handling passed");
else
{
printline("null handling failed");
exit(1);
}
+13
View File
@@ -0,0 +1,13 @@
uint work_it = 21 * 2 ^ 2;
int make_it = 10;
u64 do_it;
do_it = 15;
char make_us;
str floyd = "hello, Pink Floyd!";
bool flag = true;
printline(work_it);
printline(make_it + do_it);
printline(floyd);
printline(flag);