added lox test files

This commit is contained in:
Moritz Gmeiner 2024-08-03 02:44:12 +02:00
commit 0f3d0a15f0
268 changed files with 7497 additions and 3 deletions

32
lox.t/precedence.lox Normal file
View file

@ -0,0 +1,32 @@
// * has higher precedence than +.
print 2 + 3 * 4; // expect: 14
// * has higher precedence than -.
print 20 - 3 * 4; // expect: 8
// / has higher precedence than +.
print 2 + 6 / 3; // expect: 4
// / has higher precedence than -.
print 2 - 6 / 3; // expect: 0
// < has higher precedence than ==.
print false == 2 < 1; // expect: true
// > has higher precedence than ==.
print false == 1 > 2; // expect: true
// <= has higher precedence than ==.
print false == 2 <= 1; // expect: true
// >= has higher precedence than ==.
print false == 1 >= 2; // expect: true
// 1 - 1 is not space-sensitive.
print 1 - 1; // expect: 0
print 1 -1; // expect: 0
print 1- 1; // expect: 0
print 1-1; // expect: 0
// Using () for grouping.
print (2 * (6 - (2 + 2))); // expect: 4