Reorganize tests.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
class Foo {
|
||||
this bar { io.write("this bar") }
|
||||
this baz { io.write("this baz") }
|
||||
this bar(arg) { io.write("this bar " + arg) }
|
||||
|
||||
toString { "Foo" }
|
||||
}
|
||||
|
||||
// Different names.
|
||||
Foo.bar // expect: this bar
|
||||
Foo.baz // expect: this baz
|
||||
|
||||
// Can overload by arity.
|
||||
Foo.bar // expect: this bar
|
||||
Foo.bar("one") // expect: this bar one
|
||||
|
||||
// Returns the new instance.
|
||||
var foo = Foo.bar // expect: this bar
|
||||
io.write(foo is Foo) // expect: true
|
||||
io.write(foo.toString) // expect: Foo
|
||||
@@ -0,0 +1,13 @@
|
||||
io.write(Num == Num) // expect: true
|
||||
io.write(Num == Bool) // expect: false
|
||||
|
||||
// Not equal to other types.
|
||||
io.write(Num == 123) // expect: false
|
||||
io.write(Num == true) // expect: false
|
||||
|
||||
io.write(Num != Num) // expect: false
|
||||
io.write(Num != Bool) // expect: true
|
||||
|
||||
// Not equal to other types.
|
||||
io.write(Num != 123) // expect: true
|
||||
io.write(Num != true) // expect: true
|
||||
@@ -0,0 +1,27 @@
|
||||
class Foo {
|
||||
methodOnFoo { io.write("foo") }
|
||||
method(a) { io.write("foo") }
|
||||
method(a, b, c) { io.write("foo") }
|
||||
}
|
||||
|
||||
class Bar is Foo {
|
||||
methodOnBar { io.write("bar") }
|
||||
method(a, b) { io.write("bar") }
|
||||
method(a, b, c, d) { io.write("bar") }
|
||||
}
|
||||
|
||||
var bar = Bar.new
|
||||
bar.methodOnFoo // expect: foo
|
||||
bar.methodOnBar // expect: bar
|
||||
|
||||
// Methods with different arity do not shadow each other.
|
||||
bar.method(1) // expect: foo
|
||||
bar.method(1, 2) // expect: bar
|
||||
bar.method(1, 2, 3) // expect: foo
|
||||
bar.method(1, 2, 3, 4) // expect: bar
|
||||
|
||||
// TODO(bob): Overriding (or BETA-style refining?).
|
||||
// TODO(bob): Private fields.
|
||||
// TODO(bob): Super (or inner) calls.
|
||||
// TODO(bob): Grammar for what expressions can follow "is".
|
||||
// TODO(bob): Prevent extending built-in types.
|
||||
@@ -0,0 +1,4 @@
|
||||
class Foo {}
|
||||
|
||||
var foo = Foo.new
|
||||
io.write(foo is Foo) // expect: true
|
||||
@@ -0,0 +1,7 @@
|
||||
// Empty body.
|
||||
class A {}
|
||||
|
||||
// Newline body.
|
||||
class B {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user