mirror of
https://github.com/MorizzG/MLox.git
synced 2025-12-06 04:22:41 +00:00
added lox test files
This commit is contained in:
parent
821f5c62bc
commit
0f3d0a15f0
268 changed files with 7497 additions and 3 deletions
9
lox.t/assignment/associativity.lox
Normal file
9
lox.t/assignment/associativity.lox
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
var a = "a";
|
||||
var b = "b";
|
||||
var c = "c";
|
||||
|
||||
// Assignment is right-associative.
|
||||
a = b = c;
|
||||
print a; // expect: c
|
||||
print b; // expect: c
|
||||
print c; // expect: c
|
||||
8
lox.t/assignment/global.lox
Normal file
8
lox.t/assignment/global.lox
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
var a = "before";
|
||||
print a; // expect: before
|
||||
|
||||
a = "after";
|
||||
print a; // expect: after
|
||||
|
||||
print a = "arg"; // expect: arg
|
||||
print a; // expect: arg
|
||||
2
lox.t/assignment/grouping.lox
Normal file
2
lox.t/assignment/grouping.lox
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var a = "a";
|
||||
(a) = "value"; // Error at '=': Invalid assignment target.
|
||||
3
lox.t/assignment/infix_operator.lox
Normal file
3
lox.t/assignment/infix_operator.lox
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
var a = "a";
|
||||
var b = "b";
|
||||
a + b = "value"; // Error at '=': Invalid assignment target.
|
||||
10
lox.t/assignment/local.lox
Normal file
10
lox.t/assignment/local.lox
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
var a = "before";
|
||||
print a; // expect: before
|
||||
|
||||
a = "after";
|
||||
print a; // expect: after
|
||||
|
||||
print a = "arg"; // expect: arg
|
||||
print a; // expect: arg
|
||||
}
|
||||
2
lox.t/assignment/prefix_operator.lox
Normal file
2
lox.t/assignment/prefix_operator.lox
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var a = "a";
|
||||
!a = "value"; // Error at '=': Invalid assignment target.
|
||||
5
lox.t/assignment/syntax.lox
Normal file
5
lox.t/assignment/syntax.lox
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Assignment on RHS of variable.
|
||||
var a = "before";
|
||||
var c = a = "var";
|
||||
print a; // expect: var
|
||||
print c; // expect: var
|
||||
7
lox.t/assignment/to_this.lox
Normal file
7
lox.t/assignment/to_this.lox
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class Foo {
|
||||
Foo() {
|
||||
this = "value"; // Error at '=': Invalid assignment target.
|
||||
}
|
||||
}
|
||||
|
||||
Foo();
|
||||
1
lox.t/assignment/undefined.lox
Normal file
1
lox.t/assignment/undefined.lox
Normal file
|
|
@ -0,0 +1 @@
|
|||
unknown = "what"; // expect runtime error: Undefined variable 'unknown'.
|
||||
Loading…
Add table
Add a link
Reference in a new issue