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,10 @@
|
||||
var list = []
|
||||
|
||||
for (i in [1, 2, 3]) {
|
||||
list.add(new Fn { IO.print(i) })
|
||||
}
|
||||
|
||||
for (f in list) f.call()
|
||||
// expect: 1
|
||||
// expect: 2
|
||||
// expect: 3
|
||||
@@ -0,0 +1,11 @@
|
||||
var list = []
|
||||
|
||||
for (i in [1, 2, 3]) {
|
||||
var j = i + 1
|
||||
list.add(new Fn { IO.print(j) })
|
||||
}
|
||||
|
||||
for (f in list) f.call()
|
||||
// expect: 2
|
||||
// expect: 3
|
||||
// expect: 4
|
||||
@@ -0,0 +1,2 @@
|
||||
for // expect error
|
||||
(i in [1, 2, 3]) IO.print(i)
|
||||
@@ -0,0 +1,2 @@
|
||||
for (i // expect error
|
||||
in [1]) IO.print(i)
|
||||
@@ -0,0 +1,10 @@
|
||||
var f = new Fn {
|
||||
IO.print("evaluate sequence")
|
||||
return [1, 2, 3]
|
||||
}
|
||||
|
||||
for (i in f.call()) IO.print(i)
|
||||
// expect: evaluate sequence
|
||||
// expect: 1
|
||||
// expect: 2
|
||||
// expect: 3
|
||||
@@ -0,0 +1,9 @@
|
||||
var f = new Fn {
|
||||
for (i in [1, 2, 3]) {
|
||||
return new Fn { IO.print(i) }
|
||||
}
|
||||
}
|
||||
|
||||
var g = f.call()
|
||||
g.call()
|
||||
// expect: 1
|
||||
@@ -0,0 +1,8 @@
|
||||
var f = new Fn {
|
||||
for (i in [1, 2, 3]) {
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
IO.print(f.call())
|
||||
// expect: 1
|
||||
@@ -0,0 +1,14 @@
|
||||
// Single-expression body.
|
||||
for (i in [1]) IO.print(i)
|
||||
// expect: 1
|
||||
|
||||
// Block body.
|
||||
for (i in [1]) {
|
||||
IO.print(i)
|
||||
}
|
||||
// expect: 1
|
||||
|
||||
// Newline after "in".
|
||||
for (i in
|
||||
[1]) IO.print(i)
|
||||
// expect: 1
|
||||
@@ -0,0 +1,32 @@
|
||||
class Iter {
|
||||
new(value) { _value = value }
|
||||
iterate(iterator) { _value }
|
||||
iteratorValue(iterator) { "value" }
|
||||
}
|
||||
|
||||
// False and null are false.
|
||||
for (n in new Iter(false)) {
|
||||
IO.print("bad")
|
||||
break
|
||||
}
|
||||
|
||||
for (n in new Iter(null)) {
|
||||
IO.print("bad")
|
||||
break
|
||||
}
|
||||
|
||||
// Everything else is true.
|
||||
for (n in new Iter(true)) {
|
||||
IO.print("true") // expect: true
|
||||
break
|
||||
}
|
||||
|
||||
for (n in new Iter(0)) {
|
||||
IO.print(0) // expect: 0
|
||||
break
|
||||
}
|
||||
|
||||
for (n in new Iter("")) {
|
||||
IO.print("string") // expect: string
|
||||
break
|
||||
}
|
||||
Reference in New Issue
Block a user