New tests

This commit is contained in:
Productive2 2021-01-10 19:44:00 +01:00
parent 30fb134a74
commit 338a3b0535
5 changed files with 97 additions and 1 deletions

18
tests/japl/callchain.jpl Normal file
View File

@ -0,0 +1,18 @@
fun add2(x)
{
return x + 2;
}
fun sub2(x)
{
return x - 2;
}
fun mul2(x)
{
return x * 2;
}
print(add2(sub2(mul2(sub2(5)))));
//5-2=3
//3*2=6
//output:6

View File

@ -0,0 +1,42 @@
var x = 4;
var y = 5;
var z = 6;
if (x < y)
print("1");//output:1
else
print("2");
if (x == y)
print("3");//output:4
else
print("4");
if (x > y)
print("5");//output:6
else if (x < y)
print("6");
if (y >= 5)
print("7");//output:7
else
print("8");
if (z >= 5)
print("9");//output:9
else
print("10");
if (x <= 4)
print("11");//output:11
else
print("12");
if (2 <= y)
print("13");//output:13
else
print("14");
if (8 <= z)
print("15");
else
print("16");//output:16

22
tests/japl/is.jpl Normal file
View File

@ -0,0 +1,22 @@
var x = 4;
var y = x;
print(x is y);//output:false
print(x is x);//output:true
print(x is 4);//output:false
var z = true;
var u = true;
print(z is u);//output:true
print(z is x);//output:false
print(z is z);//output:true
var l = false;
print((not l) is z);//output:true
print(l is z);//output:false
print((l is z) is l);//output:true
var k;
print(k is nil);//output:true

12
tests/japl/strings.jpl Normal file
View File

@ -0,0 +1,12 @@
var left = "left";
var right = "right";
var directions = left + " " + right;
print(directions);//output:left right
var longstring = directions * 5;
print(longstring);//output:left rightleft rightleft rightleft rightleft right
left = left + " side";
print(left);//output:left side
right = "side: " + right;
print(right);//output:side: right

View File

@ -26,7 +26,9 @@ import multibyte, os, strformat, times, re, terminal
# Exceptions for tests that represent not-yet implemented behaviour
const exceptions = ["all.jpl"]
const exceptions = ["all.jpl", "for_with_function.jpl"]
# for_with_function.jpl probably contains an algorithmic error too
# TODO: fix that test
type LogLevel {.pure.} = enum
Debug, # always written to file only (large outputs, such as the entire output of the failing test or stacktrace)