Reorganize tests.

This commit is contained in:
Bob Nystrom
2013-11-26 22:52:00 -08:00
parent 897a396599
commit 56449cdbef
72 changed files with 0 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
class Foo {
method { 0 }
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 }
}
var foo = Foo.new
io.write(foo.method) // expect: 0
io.write(foo.method(1)) // expect: 1
io.write(foo.method(1, 2)) // expect: 3
io.write(foo.method(1, 2, 3)) // expect: 6
io.write(foo.method(1, 2, 3, 4)) // expect: 10
io.write(foo.method(1, 2, 3, 4, 5)) // expect: 15
io.write(foo.method(1, 2, 3, 4, 5, 6)) // expect: 21
io.write(foo.method(1, 2, 3, 4, 5, 6, 7)) // expect: 28
io.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8)) // expect: 36
io.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9)) // expect: 45
io.write(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) // expect: 55
+31
View File
@@ -0,0 +1,31 @@
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 }
! { "prefix !" }
- { "prefix -" }
}
var foo = Foo.new
io.write(foo + "a") // expect: infix + a
io.write(foo - "a") // expect: infix - a
io.write(foo * "a") // expect: infix * a
io.write(foo / "a") // expect: infix / a
io.write(foo % "a") // expect: infix % a
io.write(foo < "a") // expect: infix < a
io.write(foo > "a") // expect: infix > a
io.write(foo <= "a") // expect: infix <= a
io.write(foo >= "a") // expect: infix >= a
io.write(foo == "a") // expect: infix == a
io.write(foo != "a") // expect: infix != a
io.write(!foo) // expect: prefix !
io.write(-foo) // expect: prefix -
+13
View File
@@ -0,0 +1,13 @@
class Foo {
bar { "on instance" }
static bar { "on metaclass" }
bar(arg) { "on instance " + arg }
static bar(arg) { "on metaclass " + arg }
}
io.write("on metaclass " + "arg") // expect: on metaclass arg
io.write(Foo.new.bar) // expect: on instance
io.write(Foo.bar) // expect: on metaclass
io.write(Foo.new.bar("arg")) // expect: on instance arg
io.write(Foo.bar("arg")) // expect: on metaclass arg