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
+40
View File
@@ -0,0 +1,40 @@
class Foo {
method { "getter" }
method() { "no args" }
method(a) { a }
method(a, b) { a + b }
method(a, b, c) { a + b + c }
method(a, b, c, d) { a + b + c + d }
method(a, b, c, d, e) { a + b + c + d + e }
method(a, b, c, d, e, f) { a + b + c + d + e + f }
method(a, b, c, d, e, f, g) { a + b + c + d + e + f + g }
method(a, b, c, d, e, f, g, h) { a + b + c + d + e + f + g + h }
method(a, b, c, d, e, f, g, h, i) { a + b + c + d + e + f + g + h + i }
method(a, b, c, d, e, f, g, h, i, j) { a + b + c + d + e + f + g + h + i + j }
method(a, b, c, d, e, f, g, h, i, j, k) { a + b + c + d + e + f + g + h + i + j + k}
method(a, b, c, d, e, f, g, h, i, j, k, l) { a + b + c + d + e + f + g + h + i + j + k + l}
method(a, b, c, d, e, f, g, h, i, j, k, l, m) { a + b + c + d + e + f + g + h + i + j + k + l + m}
method(a, b, c, d, e, f, g, h, i, j, k, l, m, n) { a + b + c + d + e + f + g + h + i + j + k + l + m + n}
method(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) { a + b + c + d + e + f + g + h + i + j + k + l + m + n + o}
method(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) { a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p}
}
var foo = new Foo
IO.print(foo.method) // expect: getter
IO.print(foo.method()) // expect: no args
IO.print(foo.method(1)) // expect: 1
IO.print(foo.method(1, 2)) // expect: 3
IO.print(foo.method(1, 2, 3)) // expect: 6
IO.print(foo.method(1, 2, 3, 4)) // expect: 10
IO.print(foo.method(1, 2, 3, 4, 5)) // expect: 15
IO.print(foo.method(1, 2, 3, 4, 5, 6)) // expect: 21
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7)) // expect: 28
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8)) // expect: 36
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9)) // expect: 45
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) // expect: 55
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) // expect: 66
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) // expect: 78
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) // expect: 91
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) // expect: 105
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) // expect: 120
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) // expect: 136
@@ -0,0 +1,4 @@
// Don't want to actually execute it.
if (false) {
0.thisIsAMethodNameThatExceedsTheMaximumNameLengthOf64CharactersBy1 // expect error
}
+5
View File
@@ -0,0 +1,5 @@
class Foo {
bar {}
}
IO.print((new Foo).bar) // expect: null
@@ -0,0 +1,3 @@
var list = [1, 2]
list[] // expect error
"don't actually want error here, but cascades from above" // expect error
@@ -0,0 +1,3 @@
class Foo {
[] { "empty" } // expect error
}
+7
View File
@@ -0,0 +1,7 @@
class Foo {
thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum {
return "result"
}
}
IO.print((new Foo).thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum) // expect: result
File diff suppressed because it is too large Load Diff
+5
View File
@@ -0,0 +1,5 @@
class Foo {
thisIsAMethodNameThatExceedsTheMaximumNameLengthOf64CharactersBy1 { // expect error
"body"
}
}
+20
View File
@@ -0,0 +1,20 @@
class Foo {
method(a, b) { "method " + a + " " + b }
[a, b] { "subscript " + a + " " + b }
}
var foo = new Foo
// Allow newlines after commas and before ")".
IO.print(foo.method("a",
"b"
)) // expect: method a b
// Allow newlines after commas and before "]".
IO.print(foo["a",
"b"
]) // expect: subscript a b
+3
View File
@@ -0,0 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod // expect runtime error: Foo does not implement 'someUnknownMethod'.
@@ -0,0 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) // expect runtime error: Foo does not implement 'someUnknownMethod(_,_,_,_,_,_,_,_,_,_,_)'.
@@ -0,0 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod(1, 2) // expect runtime error: Foo does not implement 'someUnknownMethod(_,_)'.
@@ -0,0 +1,3 @@
class Foo {}
(new Foo).someUnknownMethod(1) // expect runtime error: Foo does not implement 'someUnknownMethod(_)'.
+37
View File
@@ -0,0 +1,37 @@
class Foo {
+(other) { "infix + " + other }
-(other) { "infix - " + other }
*(other) { "infix * " + other }
/(other) { "infix / " + other }
%(other) { "infix % " + other }
<(other) { "infix < " + other }
>(other) { "infix > " + other }
<=(other) { "infix <= " + other }
>=(other) { "infix >= " + other }
==(other) { "infix == " + other }
!=(other) { "infix != " + other }
&(other) { "infix & " + other }
|(other) { "infix | " + other }
! { "prefix !" }
~ { "prefix ~" }
- { "prefix -" }
}
var foo = new Foo
IO.print(foo + "a") // expect: infix + a
IO.print(foo - "a") // expect: infix - a
IO.print(foo * "a") // expect: infix * a
IO.print(foo / "a") // expect: infix / a
IO.print(foo % "a") // expect: infix % a
IO.print(foo < "a") // expect: infix < a
IO.print(foo > "a") // expect: infix > a
IO.print(foo <= "a") // expect: infix <= a
IO.print(foo >= "a") // expect: infix >= a
IO.print(foo == "a") // expect: infix == a
IO.print(foo != "a") // expect: infix != a
IO.print(foo & "a") // expect: infix & a
IO.print(foo | "a") // expect: infix | a
IO.print(!foo) // expect: prefix !
IO.print(~foo) // expect: prefix ~
IO.print(-foo) // expect: prefix -
+12
View File
@@ -0,0 +1,12 @@
class Foo {
bar { "on instance" }
static bar { "on metaclass" }
bar(arg) { "on instance " + arg }
static bar(arg) { "on metaclass " + arg }
}
IO.print((new Foo).bar) // expect: on instance
IO.print(Foo.bar) // expect: on metaclass
IO.print((new Foo).bar("arg")) // expect: on instance arg
IO.print(Foo.bar("arg")) // expect: on metaclass arg
@@ -0,0 +1,3 @@
class Foo {}
Foo.bar // expect runtime error: Foo metaclass does not implement 'bar'.
@@ -0,0 +1,16 @@
class Foo {
[a] { "1-subscript " + a }
[a, b] { "2-subscript " + a + " " + b }
[a, b, c] { "3-subscript " + a + " " + b + " " + c }
[a]=(value) { "1-subscript setter " + a + " = " + value }
[a, b]=(value) { "2-subscript setter " + a + " " + b + " = " + value }
[a, b, c]=(value) { "3-subscript setter " + a + " " + b + " " + c + " = " + value }
}
var foo = new Foo
IO.print(foo["a"]) // expect: 1-subscript a
IO.print(foo["a", "b"]) // expect: 2-subscript a b
IO.print(foo["a", "b", "c"]) // expect: 3-subscript a b c
IO.print(foo["a"] = "value") // expect: 1-subscript setter a = value
IO.print(foo["a", "b"] = "value") // expect: 2-subscript setter a b = value
IO.print(foo["a", "b", "c"] = "value") // expect: 3-subscript setter a b c = value
@@ -0,0 +1,2 @@
var list = []
list[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] = 17 // expect error
@@ -0,0 +1,2 @@
var list = []
list[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17] // expect error
@@ -0,0 +1 @@
IO.print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17) // expect error
@@ -0,0 +1,4 @@
class Foo {
// 17 parameters.
method(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q) { "!" } // expect error
}