lang: Add more tests for class and include

This commit is contained in:
James Shubin
2019-07-20 01:33:42 -04:00
parent da2a5f72bd
commit b3f15e1ddc
27 changed files with 128 additions and 0 deletions

View File

@@ -0,0 +1 @@
Vertex: test[t1]

View File

@@ -0,0 +1,5 @@
$x1 = "t1"
class foo {
test $x1 {}
}
include foo

View File

@@ -0,0 +1 @@
Vertex: test[t1]

View File

@@ -0,0 +1,5 @@
include foo
class foo {
test $x1 {}
}
$x1 = "t1"

View File

@@ -0,0 +1 @@
Vertex: test[t1]

View File

@@ -0,0 +1,5 @@
$x1 = "bad1"
class foo($x1) {
test $x1 {}
}
include foo("t1")

View File

@@ -0,0 +1,2 @@
Vertex: test[t1]
Vertex: test[t2]

View File

@@ -0,0 +1,7 @@
$x1 = "t1"
class foo {
test $x1 {}
test $x2 {}
}
include foo
$x2 = "t2"

View File

@@ -0,0 +1,2 @@
Vertex: test[t1: t1]
Vertex: test[t2: t2]

View File

@@ -0,0 +1,7 @@
$x1 = "bad1"
class foo($x1, $x2) {
test "t1: " + $x2 {} # swapped
test "t2: " + $x1 {}
}
include foo($x2, "t1")
$x2 = "t2"

View File

@@ -0,0 +1,3 @@
Vertex: test[t0: t0]
Vertex: test[t1: t1]
Vertex: test[t2: t2]

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

View File

@@ -0,0 +1 @@
# err: err2: class `bar` does not exist in this scope

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

View File

@@ -0,0 +1 @@
Vertex: test[t1]

View File

@@ -0,0 +1,4 @@
class foo {
test $x1 {} # capture the var
}
$x1 = "t1"

View File

@@ -0,0 +1,4 @@
$x1 = "bad1"
include defs.foo
import "defs.mcl" # out of order for fun

View File

@@ -0,0 +1 @@
# err: err2: recursive reference while setting scope: not a dag

View File

@@ -0,0 +1,6 @@
class c1 {
include c2
}
class c2 {
include c1
}

View File

@@ -0,0 +1 @@
# err: err2: recursive reference while setting scope: not a dag

View File

@@ -0,0 +1,9 @@
class c1($cond) {
test "nope" {}
if $cond {
include c1(false)
} else {
test "done" {}
}
}
include c1(true)

View File

@@ -0,0 +1 @@
Vertex: test[d]

View File

@@ -0,0 +1,10 @@
$msg = "a"
class shadowme($msg) {
$msg = "c"
if true {
$msg = "d" # this is used!
test $msg {}
}
}
include shadowme("b")

View File

@@ -0,0 +1 @@
Vertex: test[c]

View File

@@ -0,0 +1,10 @@
$msg = "a"
class shadowme($msg) {
$msg = "c"
if true {
$msg = "d"
}
test $msg {}
}
include shadowme("b")

View File

@@ -0,0 +1,2 @@
Vertex: test[a]
Vertex: test[hello]

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