added tests

This commit is contained in:
Moritz Gmeiner 2024-09-01 19:15:55 +02:00
commit 660464638f
255 changed files with 7220 additions and 3 deletions

View 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

View 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

View file

@ -0,0 +1,2 @@
var a = "a";
(a) = "value"; // Error at '=': Invalid assignment target.

View file

@ -0,0 +1,3 @@
var a = "a";
var b = "b";
a + b = "value"; // Error at '=': Invalid assignment target.

View 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
}

View file

@ -0,0 +1,2 @@
var a = "a";
!a = "value"; // Error at '=': Invalid assignment target.

View 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

View file

@ -0,0 +1,7 @@
class Foo {
Foo() {
this = "value"; // Error at '=': Invalid assignment target.
}
}
Foo();

View file

@ -0,0 +1 @@
unknown = "what"; // Error: Undefined variable 'unknown'.