Reorganize tests and benchmark scripts.

Mainly to get rid of one top level directory. But this will
also be useful when there are tests of the embedding API.
This commit is contained in:
Bob Nystrom
2015-03-14 12:45:56 -07:00
parent e2a72282a1
commit 64eccdd9be
562 changed files with 32 additions and 8 deletions
@@ -0,0 +1,25 @@
var f = null
var g = null
{
var local = "local"
f = new Fn {
IO.print(local)
local = "after f"
IO.print(local)
}
g = new Fn {
IO.print(local)
local = "after g"
IO.print(local)
}
}
f.call()
// expect: local
// expect: after f
g.call()
// expect: after f
// expect: after g
@@ -0,0 +1,9 @@
var f = null
new Fn {|param|
f = new Fn {
IO.print(param)
}
}.call("param")
f.call() // expect: param
@@ -0,0 +1,13 @@
// This is a regression test. There was a bug where if an upvalue for an
// earlier local (here "a") was captured *after* a later one ("b"), then Wren
// would crash because it walked to the end of the upvalue list (correct), but
// then didn't handle not finding the variable.
new Fn {
var a = "a"
var b = "b"
new Fn {
IO.print(b) // expect: b
IO.print(a) // expect: a
}.call()
}.call()
@@ -0,0 +1,12 @@
var F = null
class Foo {
method(param) {
F = new Fn {
IO.print(param)
}
}
}
(new Foo).method("param")
F.call() // expect: param
@@ -0,0 +1,10 @@
var f = null
{
var local = "local"
f = new Fn {
IO.print(local)
}
}
f.call() // expect: local
@@ -0,0 +1,14 @@
var foo = null
{
var local = "local"
class Foo {
method {
IO.print(local)
}
}
foo = new Foo
}
foo.method // expect: local
+21
View File
@@ -0,0 +1,21 @@
var f = null
new Fn {
var a = "a"
new Fn {
var b = "b"
new Fn {
var c = "c"
f = new Fn {
IO.print(a)
IO.print(b)
IO.print(c)
}
}.call()
}.call()
}.call()
f.call()
// expect: a
// expect: b
// expect: c
@@ -0,0 +1,6 @@
{
var local = "local"
new Fn {
IO.print(local) // expect: local
}.call()
}
@@ -0,0 +1,10 @@
{
var local = "local"
class Foo {
method {
IO.print(local)
}
}
(new Foo).method // expect: local
}
@@ -0,0 +1,13 @@
var f = null
{
var a = "a"
f = new Fn {
IO.print(a)
IO.print(a)
}
}
f.call()
// expect: a
// expect: a
@@ -0,0 +1,17 @@
{
var f = null
{
var a = "a"
f = new Fn { IO.print(a) }
}
{
// Since a is out of scope, the local slot will be reused by b. Make sure
// that f still closes over a.
var b = "b"
f.call() // expect: a
}
}
// TODO: Maximum number of closed-over variables (directly and/or indirect).
@@ -0,0 +1,11 @@
{
var foo = "closure"
new Fn {
{
IO.print(foo) // expect: closure
var foo = "shadow"
IO.print(foo) // expect: shadow
}
IO.print(foo) // expect: closure
}.call()
}