refactor: move benchmark directory under test and update all references

The benchmark directory is relocated from the project root into the test directory, and all scripts, documentation links, and gitignore paths are updated accordingly. The test runner is also refactored to explicitly walk subdirectories (core, io, language, limit) instead of using a single test root, and a new test/README.md is added to document the test suite structure. Additionally, the constructor test for the Foo class is updated to add a zero-arity constructor and adjust expected output strings.
This commit is contained in:
Bob Nystrom
2015-03-14 19:45:56 +00:00
parent af58528e88
commit c4ef964f92
562 changed files with 32 additions and 8 deletions
+16
View File
@@ -0,0 +1,16 @@
class Foo {
new { _field = "Foo field" }
closeOverGet {
return new Fn { _field }
}
closeOverSet {
return new Fn { _field = "new value" }
}
}
var foo = new Foo
IO.print(foo.closeOverGet.call()) // expect: Foo field
foo.closeOverSet.call()
IO.print(foo.closeOverGet.call()) // expect: new value
+5
View File
@@ -0,0 +1,5 @@
class Foo {
write { IO.print(_field) }
}
(new Foo).write // expect: null
@@ -0,0 +1,5 @@
class Foo {
static bar {
new Fn { _field = "wat" } // expect error
}
}
@@ -0,0 +1,5 @@
class Foo {
static bar {
_field = "wat" // expect error
}
}
@@ -0,0 +1,14 @@
// Refering to an instance method in a nested static class should *not* walk
// out to find the nearest enclosing instance method. We could make that work,
// but it's confusing to users, and would require some tricky work to make sure
// the enclosing instance is closed over.
class Outer {
foo {
class Inner {
static bar {
_field = "nope" // expect error
}
}
}
}
+26
View File
@@ -0,0 +1,26 @@
class Foo {
set(a, b, c, d, e) {
_a = a
_b = b
_c = c
_d = d
_e = e
}
write {
IO.print(_a)
IO.print(_b)
IO.print(_c)
IO.print(_d)
IO.print(_e)
}
}
var foo = new Foo
foo.set(1, 2, 3, 4, 5)
foo.write
// expect: 1
// expect: 2
// expect: 3
// expect: 4
// expect: 5
+18
View File
@@ -0,0 +1,18 @@
class Outer {
method {
_field = "outer"
IO.print(_field) // expect: outer
class Inner {
method {
_field = "inner"
IO.print(_field) // expect: inner
}
}
(new Inner).method
IO.print(_field) // expect: outer
}
}
(new Outer).method
+37
View File
@@ -0,0 +1,37 @@
// This test exists mainly to make sure the GC traces instance fields.
class Node {
set(left, value, right) {
_left = left
_value = value
_right = right
}
write {
if (_left is Node) {
_left.write
}
IO.print(_value)
if (_right is Node) {
_right.write
}
}
}
var a = new Node
a.set(null, "a", null)
var b = new Node
b.set(null, "b", null)
var c = new Node
c.set(a, "c", b)
a = null
b = null
var d = new Node
d.set(c, "d", null)
c = null
d.write
// expect: a
// expect: c
// expect: b
// expect: d
+1
View File
@@ -0,0 +1 @@
_field = "wat" // expect error
+9
View File
@@ -0,0 +1,9 @@
class Foo {
write { IO.print(_field) } // Compile a use of the field...
init { _field = "value" } // ...before an assignment to it.
}
var foo = new Foo
// But invoke them in the right order.
foo.init
foo.write // expect: value