mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-11 22:28:45 +01:00
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:
16
test/language/static_field/closure.wren
Normal file
16
test/language/static_field/closure.wren
Normal file
@ -0,0 +1,16 @@
|
||||
class Foo {
|
||||
static initialize { __field = "Foo field" }
|
||||
|
||||
static closeOverGet {
|
||||
return new Fn { __field }
|
||||
}
|
||||
|
||||
static closeOverSet {
|
||||
return new Fn { __field = "new value" }
|
||||
}
|
||||
}
|
||||
|
||||
Foo.initialize
|
||||
IO.print(Foo.closeOverGet.call()) // expect: Foo field
|
||||
Foo.closeOverSet.call()
|
||||
IO.print(Foo.closeOverGet.call()) // expect: new value
|
||||
5
test/language/static_field/default_to_null.wren
Normal file
5
test/language/static_field/default_to_null.wren
Normal file
@ -0,0 +1,5 @@
|
||||
class Foo {
|
||||
static write { IO.print(__field) }
|
||||
}
|
||||
|
||||
Foo.write // expect: null
|
||||
25
test/language/static_field/in_instance_method.wren
Normal file
25
test/language/static_field/in_instance_method.wren
Normal file
@ -0,0 +1,25 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
(new Foo).set(1, 2, 3, 4, 5)
|
||||
(new Foo).write
|
||||
// expect: 1
|
||||
// expect: 2
|
||||
// expect: 3
|
||||
// expect: 4
|
||||
// expect: 5
|
||||
25
test/language/static_field/multiple.wren
Normal file
25
test/language/static_field/multiple.wren
Normal file
@ -0,0 +1,25 @@
|
||||
class Foo {
|
||||
static set(a, b, c, d, e) {
|
||||
__a = a
|
||||
__b = b
|
||||
__c = c
|
||||
__d = d
|
||||
__e = e
|
||||
}
|
||||
|
||||
static write {
|
||||
IO.print(__a)
|
||||
IO.print(__b)
|
||||
IO.print(__c)
|
||||
IO.print(__d)
|
||||
IO.print(__e)
|
||||
}
|
||||
}
|
||||
|
||||
Foo.set(1, 2, 3, 4, 5)
|
||||
Foo.write
|
||||
// expect: 1
|
||||
// expect: 2
|
||||
// expect: 3
|
||||
// expect: 4
|
||||
// expect: 5
|
||||
34
test/language/static_field/nested_class.wren
Normal file
34
test/language/static_field/nested_class.wren
Normal file
@ -0,0 +1,34 @@
|
||||
class Outer {
|
||||
static staticMethod {
|
||||
__field = "outer"
|
||||
IO.print(__field) // expect: outer
|
||||
|
||||
class Inner {
|
||||
static staticMethod {
|
||||
__field = "inner"
|
||||
IO.print(__field) // expect: inner
|
||||
}
|
||||
}
|
||||
|
||||
Inner.staticMethod
|
||||
IO.print(__field) // expect: outer
|
||||
}
|
||||
|
||||
instanceMethod {
|
||||
__field = "outer"
|
||||
IO.print(__field) // expect: outer
|
||||
|
||||
class Inner {
|
||||
instanceMethod {
|
||||
__field = "inner"
|
||||
IO.print(__field) // expect: inner
|
||||
}
|
||||
}
|
||||
|
||||
(new Inner).instanceMethod
|
||||
IO.print(__field) // expect: outer
|
||||
}
|
||||
}
|
||||
|
||||
Outer.staticMethod
|
||||
(new Outer).instanceMethod
|
||||
1
test/language/static_field/outside_class.wren
Normal file
1
test/language/static_field/outside_class.wren
Normal file
@ -0,0 +1 @@
|
||||
__field = "wat" // expect error
|
||||
8
test/language/static_field/use_before_set.wren
Normal file
8
test/language/static_field/use_before_set.wren
Normal file
@ -0,0 +1,8 @@
|
||||
class Foo {
|
||||
static write { IO.print(__field) } // Compile a use of the field...
|
||||
static init { __field = "value" } // ...before an assignment to it.
|
||||
}
|
||||
|
||||
// But invoke them in the right order.
|
||||
Foo.init
|
||||
Foo.write // expect: value
|
||||
Reference in New Issue
Block a user