lang: Add more tests for class and include
This commit is contained in:
1
lang/interpret_test/TestAstFunc2/class-capture1.output
Normal file
1
lang/interpret_test/TestAstFunc2/class-capture1.output
Normal file
@@ -0,0 +1 @@
|
||||
Vertex: test[t1]
|
||||
5
lang/interpret_test/TestAstFunc2/class-capture1/main.mcl
Normal file
5
lang/interpret_test/TestAstFunc2/class-capture1/main.mcl
Normal file
@@ -0,0 +1,5 @@
|
||||
$x1 = "t1"
|
||||
class foo {
|
||||
test $x1 {}
|
||||
}
|
||||
include foo
|
||||
1
lang/interpret_test/TestAstFunc2/class-capture2.output
Normal file
1
lang/interpret_test/TestAstFunc2/class-capture2.output
Normal file
@@ -0,0 +1 @@
|
||||
Vertex: test[t1]
|
||||
5
lang/interpret_test/TestAstFunc2/class-capture2/main.mcl
Normal file
5
lang/interpret_test/TestAstFunc2/class-capture2/main.mcl
Normal file
@@ -0,0 +1,5 @@
|
||||
include foo
|
||||
class foo {
|
||||
test $x1 {}
|
||||
}
|
||||
$x1 = "t1"
|
||||
1
lang/interpret_test/TestAstFunc2/class-capture3.output
Normal file
1
lang/interpret_test/TestAstFunc2/class-capture3.output
Normal file
@@ -0,0 +1 @@
|
||||
Vertex: test[t1]
|
||||
5
lang/interpret_test/TestAstFunc2/class-capture3/main.mcl
Normal file
5
lang/interpret_test/TestAstFunc2/class-capture3/main.mcl
Normal file
@@ -0,0 +1,5 @@
|
||||
$x1 = "bad1"
|
||||
class foo($x1) {
|
||||
test $x1 {}
|
||||
}
|
||||
include foo("t1")
|
||||
2
lang/interpret_test/TestAstFunc2/class-capture4.output
Normal file
2
lang/interpret_test/TestAstFunc2/class-capture4.output
Normal file
@@ -0,0 +1,2 @@
|
||||
Vertex: test[t1]
|
||||
Vertex: test[t2]
|
||||
7
lang/interpret_test/TestAstFunc2/class-capture4/main.mcl
Normal file
7
lang/interpret_test/TestAstFunc2/class-capture4/main.mcl
Normal file
@@ -0,0 +1,7 @@
|
||||
$x1 = "t1"
|
||||
class foo {
|
||||
test $x1 {}
|
||||
test $x2 {}
|
||||
}
|
||||
include foo
|
||||
$x2 = "t2"
|
||||
2
lang/interpret_test/TestAstFunc2/class-capture5.output
Normal file
2
lang/interpret_test/TestAstFunc2/class-capture5.output
Normal file
@@ -0,0 +1,2 @@
|
||||
Vertex: test[t1: t1]
|
||||
Vertex: test[t2: t2]
|
||||
7
lang/interpret_test/TestAstFunc2/class-capture5/main.mcl
Normal file
7
lang/interpret_test/TestAstFunc2/class-capture5/main.mcl
Normal file
@@ -0,0 +1,7 @@
|
||||
$x1 = "bad1"
|
||||
class foo($x1, $x2) {
|
||||
test "t1: " + $x2 {} # swapped
|
||||
test "t2: " + $x1 {}
|
||||
}
|
||||
include foo($x2, "t1")
|
||||
$x2 = "t2"
|
||||
3
lang/interpret_test/TestAstFunc2/class-capture6.output
Normal file
3
lang/interpret_test/TestAstFunc2/class-capture6.output
Normal file
@@ -0,0 +1,3 @@
|
||||
Vertex: test[t0: t0]
|
||||
Vertex: test[t1: t1]
|
||||
Vertex: test[t2: t2]
|
||||
12
lang/interpret_test/TestAstFunc2/class-capture6/main.mcl
Normal file
12
lang/interpret_test/TestAstFunc2/class-capture6/main.mcl
Normal file
@@ -0,0 +1,12 @@
|
||||
$x1 = "bad1"
|
||||
class foo($x1, $x2) {
|
||||
include bar
|
||||
test "t1: " + $x1 {}
|
||||
test "t2: " + $x2 {}
|
||||
class bar {
|
||||
test "t0: " + $x0 {}
|
||||
}
|
||||
}
|
||||
include foo("t1", $x2)
|
||||
$x2 = "t2"
|
||||
$x0 = "t0"
|
||||
1
lang/interpret_test/TestAstFunc2/class-capture7.output
Normal file
1
lang/interpret_test/TestAstFunc2/class-capture7.output
Normal file
@@ -0,0 +1 @@
|
||||
# err: err2: class `bar` does not exist in this scope
|
||||
9
lang/interpret_test/TestAstFunc2/class-capture7/main.mcl
Normal file
9
lang/interpret_test/TestAstFunc2/class-capture7/main.mcl
Normal file
@@ -0,0 +1,9 @@
|
||||
class foo {
|
||||
test "t1" {}
|
||||
class bar { # unused definition
|
||||
test "t0" {}
|
||||
}
|
||||
}
|
||||
include foo
|
||||
# This sort of thing is not currently supported, and not sure if it ever will.
|
||||
include bar # nope!
|
||||
1
lang/interpret_test/TestAstFunc2/class-capture8.output
Normal file
1
lang/interpret_test/TestAstFunc2/class-capture8.output
Normal file
@@ -0,0 +1 @@
|
||||
Vertex: test[t1]
|
||||
4
lang/interpret_test/TestAstFunc2/class-capture8/defs.mcl
Normal file
4
lang/interpret_test/TestAstFunc2/class-capture8/defs.mcl
Normal file
@@ -0,0 +1,4 @@
|
||||
class foo {
|
||||
test $x1 {} # capture the var
|
||||
}
|
||||
$x1 = "t1"
|
||||
4
lang/interpret_test/TestAstFunc2/class-capture8/main.mcl
Normal file
4
lang/interpret_test/TestAstFunc2/class-capture8/main.mcl
Normal file
@@ -0,0 +1,4 @@
|
||||
$x1 = "bad1"
|
||||
include defs.foo
|
||||
|
||||
import "defs.mcl" # out of order for fun
|
||||
1
lang/interpret_test/TestAstFunc2/class-recursion1.output
Normal file
1
lang/interpret_test/TestAstFunc2/class-recursion1.output
Normal file
@@ -0,0 +1 @@
|
||||
# err: err2: recursive reference while setting scope: not a dag
|
||||
@@ -0,0 +1,6 @@
|
||||
class c1 {
|
||||
include c2
|
||||
}
|
||||
class c2 {
|
||||
include c1
|
||||
}
|
||||
1
lang/interpret_test/TestAstFunc2/class-recursion2.output
Normal file
1
lang/interpret_test/TestAstFunc2/class-recursion2.output
Normal file
@@ -0,0 +1 @@
|
||||
# err: err2: recursive reference while setting scope: not a dag
|
||||
@@ -0,0 +1,9 @@
|
||||
class c1($cond) {
|
||||
test "nope" {}
|
||||
if $cond {
|
||||
include c1(false)
|
||||
} else {
|
||||
test "done" {}
|
||||
}
|
||||
}
|
||||
include c1(true)
|
||||
1
lang/interpret_test/TestAstFunc2/class-shadowing1.output
Normal file
1
lang/interpret_test/TestAstFunc2/class-shadowing1.output
Normal file
@@ -0,0 +1 @@
|
||||
Vertex: test[d]
|
||||
10
lang/interpret_test/TestAstFunc2/class-shadowing1/main.mcl
Normal file
10
lang/interpret_test/TestAstFunc2/class-shadowing1/main.mcl
Normal file
@@ -0,0 +1,10 @@
|
||||
$msg = "a"
|
||||
class shadowme($msg) {
|
||||
$msg = "c"
|
||||
if true {
|
||||
$msg = "d" # this is used!
|
||||
test $msg {}
|
||||
}
|
||||
}
|
||||
|
||||
include shadowme("b")
|
||||
1
lang/interpret_test/TestAstFunc2/class-shadowing2.output
Normal file
1
lang/interpret_test/TestAstFunc2/class-shadowing2.output
Normal file
@@ -0,0 +1 @@
|
||||
Vertex: test[c]
|
||||
10
lang/interpret_test/TestAstFunc2/class-shadowing2/main.mcl
Normal file
10
lang/interpret_test/TestAstFunc2/class-shadowing2/main.mcl
Normal file
@@ -0,0 +1,10 @@
|
||||
$msg = "a"
|
||||
class shadowme($msg) {
|
||||
$msg = "c"
|
||||
if true {
|
||||
$msg = "d"
|
||||
}
|
||||
test $msg {}
|
||||
}
|
||||
|
||||
include shadowme("b")
|
||||
2
lang/interpret_test/TestAstFunc2/class-shadowing3.output
Normal file
2
lang/interpret_test/TestAstFunc2/class-shadowing3.output
Normal file
@@ -0,0 +1,2 @@
|
||||
Vertex: test[a]
|
||||
Vertex: test[hello]
|
||||
17
lang/interpret_test/TestAstFunc2/class-shadowing3/main.mcl
Normal file
17
lang/interpret_test/TestAstFunc2/class-shadowing3/main.mcl
Normal file
@@ -0,0 +1,17 @@
|
||||
$foo = "a"
|
||||
|
||||
class c1($cond) {
|
||||
$foo = "b" # this var is NOT exported into the parent scope on include
|
||||
if $cond {
|
||||
$foo = "c"
|
||||
}
|
||||
test "hello" {}
|
||||
}
|
||||
include c1(true)
|
||||
|
||||
# If the $foo did get exported from the `c1` scope, then the binding could
|
||||
# change over time as `$cond` alternated between true and false. This would be
|
||||
# error prone, and also require a higher-order FRP, which would add complexity
|
||||
# but little value.
|
||||
|
||||
test $foo {}
|
||||
Reference in New Issue
Block a user