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:
@@ -0,0 +1,7 @@
|
||||
class Foo {
|
||||
static methodOnFoo { IO.print("foo") }
|
||||
}
|
||||
|
||||
class Bar is Foo {}
|
||||
|
||||
Bar.methodOnFoo // expect runtime error: Bar metaclass does not implement 'methodOnFoo'.
|
||||
@@ -0,0 +1,35 @@
|
||||
class Foo {
|
||||
foo(a, b) {
|
||||
_field1 = a
|
||||
_field2 = b
|
||||
}
|
||||
|
||||
fooPrint {
|
||||
IO.print(_field1)
|
||||
IO.print(_field2)
|
||||
}
|
||||
}
|
||||
|
||||
class Bar is Foo {
|
||||
bar(a, b) {
|
||||
_field1 = a
|
||||
_field2 = b
|
||||
}
|
||||
|
||||
barPrint {
|
||||
IO.print(_field1)
|
||||
IO.print(_field2)
|
||||
}
|
||||
}
|
||||
|
||||
var bar = new Bar
|
||||
bar.foo("foo 1", "foo 2")
|
||||
bar.bar("bar 1", "bar 2")
|
||||
|
||||
bar.fooPrint
|
||||
// expect: foo 1
|
||||
// expect: foo 2
|
||||
|
||||
bar.barPrint
|
||||
// expect: bar 1
|
||||
// expect: bar 2
|
||||
@@ -0,0 +1 @@
|
||||
class Subclass is Class {} // expect runtime error: Subclass cannot inherit from Class.
|
||||
@@ -0,0 +1,8 @@
|
||||
var ClosureType
|
||||
|
||||
{
|
||||
var a = "a"
|
||||
ClosureType = new Fn { IO.print(a) }.type
|
||||
}
|
||||
|
||||
class Subclass is ClosureType {} // expect runtime error: Subclass cannot inherit from Fn.
|
||||
@@ -0,0 +1 @@
|
||||
class Subclass is Fiber {} // expect runtime error: Subclass cannot inherit from Fiber.
|
||||
@@ -0,0 +1 @@
|
||||
class Subclass is Fn {} // expect runtime error: Subclass cannot inherit from Fn.
|
||||
@@ -0,0 +1 @@
|
||||
class Subclass is List {} // expect runtime error: Subclass cannot inherit from List.
|
||||
@@ -0,0 +1 @@
|
||||
class Subclass is Map {} // expect runtime error: Subclass cannot inherit from Map.
|
||||
@@ -0,0 +1 @@
|
||||
class Foo is 123 {} // expect runtime error: Must inherit from a class.
|
||||
@@ -0,0 +1 @@
|
||||
class Subclass is Range {} // expect runtime error: Subclass cannot inherit from Range.
|
||||
@@ -0,0 +1 @@
|
||||
class Subclass is String {} // expect runtime error: Subclass cannot inherit from String.
|
||||
@@ -0,0 +1,26 @@
|
||||
class Foo {
|
||||
methodOnFoo { IO.print("foo") }
|
||||
method(a) { IO.print("foo") }
|
||||
method(a, b, c) { IO.print("foo") }
|
||||
override { IO.print("foo") }
|
||||
}
|
||||
|
||||
class Bar is Foo {
|
||||
methodOnBar { IO.print("bar") }
|
||||
method(a, b) { IO.print("bar") }
|
||||
method(a, b, c, d) { IO.print("bar") }
|
||||
override { IO.print("bar") }
|
||||
}
|
||||
|
||||
var bar = new Bar
|
||||
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
|
||||
bar.override // expect: bar
|
||||
|
||||
// TODO: Prevent extending built-in types.
|
||||
@@ -0,0 +1,36 @@
|
||||
class Foo {
|
||||
new { _field = "Foo field" }
|
||||
|
||||
closeOverFooGet {
|
||||
return new Fn { new Fn { _field } }
|
||||
}
|
||||
|
||||
closeOverFooSet {
|
||||
return new Fn { new Fn { _field = "new foo value" } }
|
||||
}
|
||||
}
|
||||
|
||||
class Bar is Foo {
|
||||
new {
|
||||
super
|
||||
_field = "Bar field"
|
||||
}
|
||||
|
||||
closeOverBarGet {
|
||||
return new Fn { new Fn { _field } }
|
||||
}
|
||||
|
||||
closeOverBarSet {
|
||||
return new Fn { new Fn { _field = "new bar value" } }
|
||||
}
|
||||
}
|
||||
|
||||
var bar = new Bar
|
||||
IO.print(bar.closeOverFooGet.call().call()) // expect: Foo field
|
||||
IO.print(bar.closeOverBarGet.call().call()) // expect: Bar field
|
||||
bar.closeOverFooSet.call().call()
|
||||
IO.print(bar.closeOverFooGet.call().call()) // expect: new foo value
|
||||
IO.print(bar.closeOverBarGet.call().call()) // expect: Bar field
|
||||
bar.closeOverBarSet.call().call()
|
||||
IO.print(bar.closeOverFooGet.call().call()) // expect: new foo value
|
||||
IO.print(bar.closeOverBarGet.call().call()) // expect: new bar value
|
||||
@@ -0,0 +1,16 @@
|
||||
class A {}
|
||||
class B is A {}
|
||||
class C is B {}
|
||||
var a = new A
|
||||
var b = new B
|
||||
var c = new C
|
||||
|
||||
IO.print(a is A) // expect: true
|
||||
IO.print(a is B) // expect: false
|
||||
IO.print(a is C) // expect: false
|
||||
IO.print(b is A) // expect: true
|
||||
IO.print(b is B) // expect: true
|
||||
IO.print(b is C) // expect: false
|
||||
IO.print(c is A) // expect: true
|
||||
IO.print(c is B) // expect: true
|
||||
IO.print(c is C) // expect: true
|
||||
Reference in New Issue
Block a user