forked from Mirror/wren
"IO" -> "System".
Get rid of the separate opt-in IO class and replace it with a core System class. - Remove wren_io.c, wren_io.h, and io.wren. - Remove the flags that disable it. - Remove the overloads for print() with different arity. (It was an experiment, but I don't think it's that useful.) - Remove IO.read(). That will reappear using libuv in the CLI at some point. - Remove IO.time. Doesn't seem to have been used. - Update all of the tests, docs, etc. I'm sorry for all the breakage this causes, but I think "System" is a better name for this class (it makes it natural to add things like "System.gc()") and frees up "IO" for referring to the CLI's IO module.
This commit is contained in:
@ -4,6 +4,6 @@ var c = "c"
|
||||
|
||||
// Assignment is right-associative.
|
||||
a = b = c
|
||||
IO.print(a) // expect: c
|
||||
IO.print(b) // expect: c
|
||||
IO.print(c) // expect: c
|
||||
System.print(a) // expect: c
|
||||
System.print(b) // expect: c
|
||||
System.print(c) // expect: c
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
var a = "before"
|
||||
IO.print(a) // expect: before
|
||||
System.print(a) // expect: before
|
||||
|
||||
a = "after"
|
||||
IO.print(a) // expect: after
|
||||
System.print(a) // expect: after
|
||||
|
||||
IO.print(a = "arg") // expect: arg
|
||||
IO.print(a) // expect: arg
|
||||
System.print(a = "arg") // expect: arg
|
||||
System.print(a) // expect: arg
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
Fn.new {
|
||||
var a = "before"
|
||||
IO.print(a) // expect: before
|
||||
System.print(a) // expect: before
|
||||
|
||||
a = "after"
|
||||
IO.print(a) // expect: after
|
||||
System.print(a) // expect: after
|
||||
|
||||
IO.print(a = "arg") // expect: arg
|
||||
IO.print(a) // expect: arg
|
||||
System.print(a = "arg") // expect: arg
|
||||
System.print(a) // expect: arg
|
||||
}.call()
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
var a = "a"
|
||||
var b = "b"
|
||||
a = b = "chain"
|
||||
IO.print(a) // expect: chain
|
||||
IO.print(a) // expect: chain
|
||||
System.print(a) // expect: chain
|
||||
System.print(a) // expect: chain
|
||||
|
||||
// Assignment on RHS of variable.
|
||||
var c = a = "var"
|
||||
IO.print(a) // expect: var
|
||||
IO.print(c) // expect: var
|
||||
System.print(a) // expect: var
|
||||
System.print(c) // expect: var
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
// << have higher precedence than |.
|
||||
IO.print(2 | 1 << 1) // expect: 2
|
||||
IO.print(1 << 1 | 2) // expect: 2
|
||||
System.print(2 | 1 << 1) // expect: 2
|
||||
System.print(1 << 1 | 2) // expect: 2
|
||||
|
||||
// << has higher precedence than &.
|
||||
IO.print(2 & 1 << 1) // expect: 2
|
||||
IO.print(1 << 1 & 2) // expect: 2
|
||||
System.print(2 & 1 << 1) // expect: 2
|
||||
System.print(1 << 1 & 2) // expect: 2
|
||||
|
||||
// << has higher precedence than ^.
|
||||
IO.print(2 ^ 1 << 1) // expect: 0
|
||||
IO.print(1 << 1 ^ 2) // expect: 0
|
||||
System.print(2 ^ 1 << 1) // expect: 0
|
||||
System.print(1 << 1 ^ 2) // expect: 0
|
||||
|
||||
// & has higher precedence than |.
|
||||
IO.print(1 & 1 | 2) // expect: 3
|
||||
IO.print(2 | 1 & 1) // expect: 3
|
||||
System.print(1 & 1 | 2) // expect: 3
|
||||
System.print(2 | 1 & 1) // expect: 3
|
||||
|
||||
// & has higher precedence than ^.
|
||||
IO.print(1 & 1 ^ 2) // expect: 3
|
||||
IO.print(2 ^ 1 & 1) // expect: 3
|
||||
System.print(1 & 1 ^ 2) // expect: 3
|
||||
System.print(2 ^ 1 & 1) // expect: 3
|
||||
|
||||
// ^ has higher precedence than |.
|
||||
IO.print(1 ^ 1 | 1) // expect: 1
|
||||
IO.print(1 | 1 ^ 1) // expect: 1
|
||||
System.print(1 ^ 1 | 1) // expect: 1
|
||||
System.print(1 | 1 ^ 1) // expect: 1
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
var f
|
||||
for (i in [1, 2, 3]) {
|
||||
var j = 4
|
||||
f = Fn.new { IO.print(i + j) }
|
||||
f = Fn.new { System.print(i + j) }
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
var f
|
||||
while (true) {
|
||||
var i = "i"
|
||||
f = Fn.new { IO.print(i) }
|
||||
f = Fn.new { System.print(i) }
|
||||
break
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
for (i in 0..10) {
|
||||
IO.print(i)
|
||||
System.print(i)
|
||||
|
||||
{
|
||||
var a = "a"
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
for (i in [1, 2, 3, 4, 5]) {
|
||||
IO.print(i)
|
||||
System.print(i)
|
||||
if (i > 2) break
|
||||
IO.print(i)
|
||||
System.print(i)
|
||||
}
|
||||
// expect: 1
|
||||
// expect: 1
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var i = 0
|
||||
while (true) {
|
||||
i = i + 1
|
||||
IO.print(i)
|
||||
System.print(i)
|
||||
if (i > 2) break
|
||||
IO.print(i)
|
||||
System.print(i)
|
||||
}
|
||||
// expect: 1
|
||||
// expect: 1
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
for (i in 0..2) {
|
||||
IO.print("outer ", i)
|
||||
System.print("outer " + i.toString)
|
||||
if (i > 1) break
|
||||
|
||||
for (j in 0..2) {
|
||||
IO.print("inner ", j)
|
||||
System.print("inner " + j.toString)
|
||||
if (j > 1) break
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
var i = 0
|
||||
while (true) {
|
||||
IO.print("outer ", i)
|
||||
System.print("outer " + i.toString)
|
||||
if (i > 1) break
|
||||
|
||||
var j = 0
|
||||
while (true) {
|
||||
IO.print("inner ", j)
|
||||
System.print("inner " + j.toString)
|
||||
if (j > 1) break
|
||||
|
||||
j = j + 1
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
foreign class Foo {
|
||||
bar {
|
||||
// Can't read a field.
|
||||
IO.print(_bar) // expect error
|
||||
System.print(_bar) // expect error
|
||||
|
||||
// Or write one.
|
||||
_bar = "value" // expect error
|
||||
|
||||
@ -2,11 +2,11 @@ class foo {
|
||||
construct new() {}
|
||||
|
||||
static callFoo {
|
||||
IO.print(foo)
|
||||
System.print(foo)
|
||||
}
|
||||
|
||||
callFoo {
|
||||
IO.print(foo)
|
||||
System.print(foo)
|
||||
}
|
||||
|
||||
foo { "instance foo method" }
|
||||
|
||||
@ -2,11 +2,11 @@ class Foo {
|
||||
construct new() {}
|
||||
|
||||
static sayName {
|
||||
IO.print(Foo)
|
||||
System.print(Foo)
|
||||
}
|
||||
|
||||
sayName {
|
||||
IO.print(Foo)
|
||||
System.print(Foo)
|
||||
}
|
||||
|
||||
static toString { "Foo!" }
|
||||
|
||||
@ -4,15 +4,15 @@ var g = null
|
||||
{
|
||||
var local = "local"
|
||||
f = Fn.new {
|
||||
IO.print(local)
|
||||
System.print(local)
|
||||
local = "after f"
|
||||
IO.print(local)
|
||||
System.print(local)
|
||||
}
|
||||
|
||||
g = Fn.new {
|
||||
IO.print(local)
|
||||
System.print(local)
|
||||
local = "after g"
|
||||
IO.print(local)
|
||||
System.print(local)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ var f = null
|
||||
|
||||
Fn.new {|param|
|
||||
f = Fn.new {
|
||||
IO.print(param)
|
||||
System.print(param)
|
||||
}
|
||||
}.call("param")
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ Fn.new {
|
||||
var a = "a"
|
||||
var b = "b"
|
||||
Fn.new {
|
||||
IO.print(b) // expect: b
|
||||
IO.print(a) // expect: a
|
||||
System.print(b) // expect: b
|
||||
System.print(a) // expect: a
|
||||
}.call()
|
||||
}.call()
|
||||
|
||||
@ -5,7 +5,7 @@ class Foo {
|
||||
|
||||
method(param) {
|
||||
F = Fn.new {
|
||||
IO.print(param)
|
||||
System.print(param)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@ var f = null
|
||||
{
|
||||
var local = "local"
|
||||
f = Fn.new {
|
||||
IO.print(local)
|
||||
System.print(local)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ var foo = null
|
||||
construct new() {}
|
||||
|
||||
method {
|
||||
IO.print(local)
|
||||
System.print(local)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -7,9 +7,9 @@ Fn.new {
|
||||
Fn.new {
|
||||
var c = "c"
|
||||
f = Fn.new {
|
||||
IO.print(a)
|
||||
IO.print(b)
|
||||
IO.print(c)
|
||||
System.print(a)
|
||||
System.print(b)
|
||||
System.print(c)
|
||||
}
|
||||
}.call()
|
||||
}.call()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
{
|
||||
var local = "local"
|
||||
Fn.new {
|
||||
IO.print(local) // expect: local
|
||||
System.print(local) // expect: local
|
||||
}.call()
|
||||
}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
construct new() {}
|
||||
|
||||
method {
|
||||
IO.print(local)
|
||||
System.print(local)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,8 +3,8 @@ var f = null
|
||||
{
|
||||
var a = "a"
|
||||
f = Fn.new {
|
||||
IO.print(a)
|
||||
IO.print(a)
|
||||
System.print(a)
|
||||
System.print(a)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
|
||||
{
|
||||
var a = "a"
|
||||
f = Fn.new { IO.print(a) }
|
||||
f = Fn.new { System.print(a) }
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
var foo = "closure"
|
||||
Fn.new {
|
||||
{
|
||||
IO.print(foo) // expect: closure
|
||||
System.print(foo) // expect: closure
|
||||
var foo = "shadow"
|
||||
IO.print(foo) // expect: shadow
|
||||
System.print(foo) // expect: shadow
|
||||
}
|
||||
IO.print(foo) // expect: closure
|
||||
System.print(foo) // expect: closure
|
||||
}.call()
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
// In middle of line.
|
||||
IO.print/* ... */(/* */"ok"/* */) // expect: ok
|
||||
System.print/* ... */(/* */"ok"/* */) // expect: ok
|
||||
|
||||
// Nested.
|
||||
IO.print(/* in /* nest */ out */"ok") // expect: ok
|
||||
System.print(/* in /* nest */ out */"ok") // expect: ok
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
IO.print("ok") // expect: ok
|
||||
System.print("ok") // expect: ok
|
||||
/* comment */
|
||||
@ -1,2 +1,2 @@
|
||||
IO.print("ok") // expect: ok
|
||||
System.print("ok") // expect: ok
|
||||
// comment
|
||||
@ -8,4 +8,4 @@
|
||||
|
||||
// TODO: What about combining characters?
|
||||
|
||||
IO.print("ok") // expect: ok
|
||||
System.print("ok") // expect: ok
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
// expect error line 3
|
||||
IO.print("nope") /*
|
||||
System.print("nope") /*
|
||||
oops
|
||||
@ -1,4 +1,4 @@
|
||||
// expect error line 4
|
||||
IO.print("nope") /* /* /*
|
||||
System.print("nope") /* /* /*
|
||||
*/
|
||||
oops
|
||||
@ -1,7 +1,7 @@
|
||||
// Newline after '?'.
|
||||
IO.print(true ?
|
||||
System.print(true ?
|
||||
"yes" : "no") // expect: yes
|
||||
|
||||
// Newline after ':'.
|
||||
IO.print(false ? "yes" :
|
||||
System.print(false ? "yes" :
|
||||
"no") // expect: no
|
||||
|
||||
@ -5,52 +5,52 @@ class Foo {
|
||||
}
|
||||
|
||||
// Condition precedence.
|
||||
IO.print(true ? 1 : 2) // expect: 1
|
||||
IO.print((true) ? 1 : 2) // expect: 1
|
||||
IO.print([true][0] ? 1 : 2) // expect: 1
|
||||
IO.print(Foo.bar ? 1 : 2) // expect: 1
|
||||
IO.print(3..4 ? 1 : 2) // expect: 1
|
||||
IO.print(3 * 4 ? 1 : 2) // expect: 1
|
||||
IO.print(3 + 4 ? 1 : 2) // expect: 1
|
||||
IO.print(true || false ? 1 : 2) // expect: 1
|
||||
IO.print(!false ? 1 : 2) // expect: 1
|
||||
IO.print(~0 ? 1 : 2) // expect: 1
|
||||
IO.print(3 is Num ? 1 : 2) // expect: 1
|
||||
IO.print(Foo.new() ? 1 : 2) // expect: 1
|
||||
System.print(true ? 1 : 2) // expect: 1
|
||||
System.print((true) ? 1 : 2) // expect: 1
|
||||
System.print([true][0] ? 1 : 2) // expect: 1
|
||||
System.print(Foo.bar ? 1 : 2) // expect: 1
|
||||
System.print(3..4 ? 1 : 2) // expect: 1
|
||||
System.print(3 * 4 ? 1 : 2) // expect: 1
|
||||
System.print(3 + 4 ? 1 : 2) // expect: 1
|
||||
System.print(true || false ? 1 : 2) // expect: 1
|
||||
System.print(!false ? 1 : 2) // expect: 1
|
||||
System.print(~0 ? 1 : 2) // expect: 1
|
||||
System.print(3 is Num ? 1 : 2) // expect: 1
|
||||
System.print(Foo.new() ? 1 : 2) // expect: 1
|
||||
|
||||
var a = 0
|
||||
IO.print(a = 3 ? 1 : 2) // expect: 1
|
||||
IO.print(a) // expect: 1
|
||||
System.print(a = 3 ? 1 : 2) // expect: 1
|
||||
System.print(a) // expect: 1
|
||||
|
||||
// Then branch precedence.
|
||||
IO.print(true ? (1) : 2) // expect: 1
|
||||
IO.print(true ? [1][0] : 2) // expect: 1
|
||||
IO.print(true ? Foo.baz : 2) // expect: 1
|
||||
IO.print(true ? 3..4 : 2) // expect: 3..4
|
||||
IO.print(true ? 3 * 4 : 2) // expect: 12
|
||||
IO.print(true ? 3 + 4 : 2) // expect: 7
|
||||
IO.print(true ? 1 || false : 2) // expect: 1
|
||||
IO.print(true ? !true : 2) // expect: false
|
||||
IO.print(true ? ~0 : 2) // expect: 4294967295
|
||||
IO.print(true ? 3 is Bool : 2) // expect: false
|
||||
IO.print(true ? Foo.new() : 2) // expect: instance of Foo
|
||||
System.print(true ? (1) : 2) // expect: 1
|
||||
System.print(true ? [1][0] : 2) // expect: 1
|
||||
System.print(true ? Foo.baz : 2) // expect: 1
|
||||
System.print(true ? 3..4 : 2) // expect: 3..4
|
||||
System.print(true ? 3 * 4 : 2) // expect: 12
|
||||
System.print(true ? 3 + 4 : 2) // expect: 7
|
||||
System.print(true ? 1 || false : 2) // expect: 1
|
||||
System.print(true ? !true : 2) // expect: false
|
||||
System.print(true ? ~0 : 2) // expect: 4294967295
|
||||
System.print(true ? 3 is Bool : 2) // expect: false
|
||||
System.print(true ? Foo.new() : 2) // expect: instance of Foo
|
||||
|
||||
IO.print(true ? a = 5 : 2) // expect: 5
|
||||
IO.print(a) // expect: 5
|
||||
System.print(true ? a = 5 : 2) // expect: 5
|
||||
System.print(a) // expect: 5
|
||||
|
||||
// Else branch precedence.
|
||||
IO.print(false ? 1 : (2)) // expect: 2
|
||||
IO.print(false ? 1 : [2][0]) // expect: 2
|
||||
IO.print(false ? 2 : Foo.baz) // expect: 1
|
||||
IO.print(false ? 1 : 3..4) // expect: 3..4
|
||||
IO.print(false ? 1 : 3 * 4) // expect: 12
|
||||
IO.print(false ? 1 : 3 + 4) // expect: 7
|
||||
IO.print(false ? 1 : 2 || false) // expect: 2
|
||||
IO.print(false ? 1 : !false) // expect: true
|
||||
IO.print(false ? 1 : ~0) // expect: 4294967295
|
||||
IO.print(false ? 1 : 3 is Num) // expect: true
|
||||
IO.print(false ? 1 : Foo.new()) // expect: instance of Foo
|
||||
System.print(false ? 1 : (2)) // expect: 2
|
||||
System.print(false ? 1 : [2][0]) // expect: 2
|
||||
System.print(false ? 2 : Foo.baz) // expect: 1
|
||||
System.print(false ? 1 : 3..4) // expect: 3..4
|
||||
System.print(false ? 1 : 3 * 4) // expect: 12
|
||||
System.print(false ? 1 : 3 + 4) // expect: 7
|
||||
System.print(false ? 1 : 2 || false) // expect: 2
|
||||
System.print(false ? 1 : !false) // expect: true
|
||||
System.print(false ? 1 : ~0) // expect: 4294967295
|
||||
System.print(false ? 1 : 3 is Num) // expect: true
|
||||
System.print(false ? 1 : Foo.new()) // expect: instance of Foo
|
||||
|
||||
// Associativity.
|
||||
IO.print(true ? 2 : true ? 4 : 5) // expect: 2
|
||||
IO.print(false ? 2 : true ? 4 : 5) // expect: 4
|
||||
System.print(true ? 2 : true ? 4 : 5) // expect: 2
|
||||
System.print(false ? 2 : true ? 4 : 5) // expect: 4
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
true ? IO.print("ok") : IO.print("no") // expect: ok
|
||||
false ? IO.print("no") : IO.print("ok") // expect: ok
|
||||
true ? System.print("ok") : System.print("no") // expect: ok
|
||||
false ? System.print("no") : System.print("ok") // expect: ok
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class Foo {
|
||||
this +(value) { // expect error
|
||||
IO.print("ok")
|
||||
System.print("ok")
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class Foo {
|
||||
this -(value) { // expect error
|
||||
IO.print("ok")
|
||||
System.print("ok")
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class Foo {
|
||||
this name=(value) { // expect error
|
||||
IO.print("ok")
|
||||
System.print("ok")
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class Foo {
|
||||
this [value] { // expect error
|
||||
IO.print("ok")
|
||||
System.print("ok")
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class Foo {
|
||||
this ! { // expect error
|
||||
IO.print("ok")
|
||||
System.print("ok")
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
construct new() {
|
||||
IO.print("ok")
|
||||
System.print("ok")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -5,10 +5,10 @@ class Foo {
|
||||
toString { _field }
|
||||
}
|
||||
|
||||
IO.print(Foo.named()) // expect: named
|
||||
IO.print(Foo.other()) // expect: other
|
||||
System.print(Foo.named()) // expect: named
|
||||
System.print(Foo.other()) // expect: other
|
||||
|
||||
// Returns the new instance.
|
||||
var foo = Foo.named()
|
||||
IO.print(foo is Foo) // expect: true
|
||||
IO.print(foo.toString) // expect: named
|
||||
System.print(foo is Foo) // expect: true
|
||||
System.print(foo.toString) // expect: named
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class Foo {
|
||||
this new { // expect error
|
||||
IO.print("ok")
|
||||
System.print("ok")
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
class A {
|
||||
construct new(arg) {
|
||||
IO.print("new A ", arg)
|
||||
System.print("new A " + arg)
|
||||
_field = arg
|
||||
}
|
||||
|
||||
@ -10,7 +10,7 @@ class A {
|
||||
class B is A {
|
||||
construct new(arg1, arg2) {
|
||||
super(arg2)
|
||||
IO.print("new B ", arg1)
|
||||
System.print("new B " + arg1)
|
||||
_field = arg1
|
||||
}
|
||||
|
||||
@ -20,7 +20,7 @@ class B is A {
|
||||
class C is B {
|
||||
construct new() {
|
||||
super("one", "two")
|
||||
IO.print("new C")
|
||||
System.print("new C")
|
||||
_field = "c"
|
||||
}
|
||||
|
||||
@ -31,10 +31,10 @@ var c = C.new()
|
||||
// expect: new A two
|
||||
// expect: new B one
|
||||
// expect: new C
|
||||
IO.print(c is A) // expect: true
|
||||
IO.print(c is B) // expect: true
|
||||
IO.print(c is C) // expect: true
|
||||
System.print(c is A) // expect: true
|
||||
System.print(c is B) // expect: true
|
||||
System.print(c is C) // expect: true
|
||||
|
||||
IO.print(c.aField) // expect: two
|
||||
IO.print(c.bField) // expect: one
|
||||
IO.print(c.cField) // expect: c
|
||||
System.print(c.aField) // expect: two
|
||||
System.print(c.bField) // expect: one
|
||||
System.print(c.cField) // expect: c
|
||||
|
||||
@ -4,4 +4,4 @@
|
||||
if (true) {}
|
||||
if (false) {} else {}
|
||||
|
||||
IO.print("ok") // expect: ok
|
||||
System.print("ok") // expect: ok
|
||||
@ -4,16 +4,16 @@ var closure
|
||||
{
|
||||
var a = "before"
|
||||
fiber = Fiber.new {
|
||||
IO.print(a)
|
||||
System.print(a)
|
||||
Fiber.yield()
|
||||
a = "after"
|
||||
Fiber.yield()
|
||||
IO.print(a)
|
||||
System.print(a)
|
||||
a = "final"
|
||||
}
|
||||
|
||||
closure = Fn.new {
|
||||
IO.print(a)
|
||||
System.print(a)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,6 +11,6 @@ class Foo {
|
||||
}
|
||||
|
||||
var foo = Foo.new()
|
||||
IO.print(foo.closeOverGet.call()) // expect: Foo field
|
||||
System.print(foo.closeOverGet.call()) // expect: Foo field
|
||||
foo.closeOverSet.call()
|
||||
IO.print(foo.closeOverGet.call()) // expect: new value
|
||||
System.print(foo.closeOverGet.call()) // expect: new value
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
construct new() {}
|
||||
write { IO.print(_field) }
|
||||
write { System.print(_field) }
|
||||
}
|
||||
|
||||
Foo.new().write // expect: null
|
||||
|
||||
@ -10,11 +10,11 @@ class Foo {
|
||||
}
|
||||
|
||||
write {
|
||||
IO.print(_a)
|
||||
IO.print(_b)
|
||||
IO.print(_c)
|
||||
IO.print(_d)
|
||||
IO.print(_e)
|
||||
System.print(_a)
|
||||
System.print(_b)
|
||||
System.print(_c)
|
||||
System.print(_d)
|
||||
System.print(_e)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -3,19 +3,19 @@ class Outer {
|
||||
|
||||
method {
|
||||
_field = "outer"
|
||||
IO.print(_field) // expect: outer
|
||||
System.print(_field) // expect: outer
|
||||
|
||||
class Inner {
|
||||
construct new() {}
|
||||
|
||||
method {
|
||||
_field = "inner"
|
||||
IO.print(_field) // expect: inner
|
||||
System.print(_field) // expect: inner
|
||||
}
|
||||
}
|
||||
|
||||
Inner.new().method
|
||||
IO.print(_field) // expect: outer
|
||||
System.print(_field) // expect: outer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@ class Node {
|
||||
_left.write()
|
||||
}
|
||||
|
||||
IO.print(_value)
|
||||
System.print(_value)
|
||||
|
||||
if (_right is Node) {
|
||||
_right.write()
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
class Foo {
|
||||
construct new() {}
|
||||
write { IO.print(_field) } // Compile a use of the field...
|
||||
write { System.print(_field) } // Compile a use of the field...
|
||||
init { _field = "value" } // ...before an assignment to it.
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
var list = []
|
||||
|
||||
for (i in [1, 2, 3]) {
|
||||
list.add(Fn.new { IO.print(i) })
|
||||
list.add(Fn.new { System.print(i) })
|
||||
}
|
||||
|
||||
for (f in list) f.call()
|
||||
|
||||
@ -2,7 +2,7 @@ var list = []
|
||||
|
||||
for (i in [1, 2, 3]) {
|
||||
var j = i + 1
|
||||
list.add(Fn.new { IO.print(j) })
|
||||
list.add(Fn.new { System.print(j) })
|
||||
}
|
||||
|
||||
for (f in list) f.call()
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
for // expect error
|
||||
(i in [1, 2, 3]) IO.print(i)
|
||||
(i in [1, 2, 3]) System.print(i)
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
for (i // expect error
|
||||
in [1]) IO.print(i)
|
||||
in [1]) System.print(i)
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
var f = Fn.new {
|
||||
IO.print("evaluate sequence")
|
||||
System.print("evaluate sequence")
|
||||
return [1, 2, 3]
|
||||
}
|
||||
|
||||
for (i in f.call()) IO.print(i)
|
||||
for (i in f.call()) System.print(i)
|
||||
// expect: evaluate sequence
|
||||
// expect: 1
|
||||
// expect: 2
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
var f = Fn.new {
|
||||
for (i in [1, 2, 3]) {
|
||||
return Fn.new { IO.print(i) }
|
||||
return Fn.new { System.print(i) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,5 +4,5 @@ var f = Fn.new {
|
||||
}
|
||||
}
|
||||
|
||||
IO.print(f.call())
|
||||
System.print(f.call())
|
||||
// expect: 1
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
// Single-expression body.
|
||||
for (i in [1]) IO.print(i)
|
||||
for (i in [1]) System.print(i)
|
||||
// expect: 1
|
||||
|
||||
// Block body.
|
||||
for (i in [1]) {
|
||||
IO.print(i)
|
||||
System.print(i)
|
||||
}
|
||||
// expect: 1
|
||||
|
||||
// Newline after "in".
|
||||
for (i in
|
||||
[1]) IO.print(i)
|
||||
[1]) System.print(i)
|
||||
// expect: 1
|
||||
@ -6,27 +6,27 @@ class Iter {
|
||||
|
||||
// False and null are false.
|
||||
for (n in Iter.new(false)) {
|
||||
IO.print("bad")
|
||||
System.print("bad")
|
||||
break
|
||||
}
|
||||
|
||||
for (n in Iter.new(null)) {
|
||||
IO.print("bad")
|
||||
System.print("bad")
|
||||
break
|
||||
}
|
||||
|
||||
// Everything else is true.
|
||||
for (n in Iter.new(true)) {
|
||||
IO.print("true") // expect: true
|
||||
System.print("true") // expect: true
|
||||
break
|
||||
}
|
||||
|
||||
for (n in Iter.new(0)) {
|
||||
IO.print(0) // expect: 0
|
||||
System.print(0) // expect: 0
|
||||
break
|
||||
}
|
||||
|
||||
for (n in Iter.new("")) {
|
||||
IO.print("string") // expect: string
|
||||
System.print("string") // expect: string
|
||||
break
|
||||
}
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
var f = Fn.new {}
|
||||
IO.print(f.call()) // expect: null
|
||||
System.print(f.call()) // expect: null
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var f = Fn.new {
|
||||
// Hi.
|
||||
}
|
||||
IO.print(f.call()) // expect: null
|
||||
System.print(f.call()) // expect: null
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
Fn.new { IO.print("ok") // expect error
|
||||
Fn.new { System.print("ok") // expect error
|
||||
}.call()
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
Fn.new {
|
||||
IO.print("ok") } // expect error
|
||||
System.print("ok") } // expect error
|
||||
@ -1,50 +1,50 @@
|
||||
var f0 = Fn.new { 0 }
|
||||
IO.print(f0.call()) // expect: 0
|
||||
System.print(f0.call()) // expect: 0
|
||||
|
||||
var f1 = Fn.new {|a| a }
|
||||
IO.print(f1.call(1)) // expect: 1
|
||||
System.print(f1.call(1)) // expect: 1
|
||||
|
||||
var f2 = Fn.new {|a, b| a + b }
|
||||
IO.print(f2.call(1, 2)) // expect: 3
|
||||
System.print(f2.call(1, 2)) // expect: 3
|
||||
|
||||
var f3 = Fn.new {|a, b, c| a + b + c }
|
||||
IO.print(f3.call(1, 2, 3)) // expect: 6
|
||||
System.print(f3.call(1, 2, 3)) // expect: 6
|
||||
|
||||
var f4 = Fn.new {|a, b, c, d| a + b + c + d }
|
||||
IO.print(f4.call(1, 2, 3, 4)) // expect: 10
|
||||
System.print(f4.call(1, 2, 3, 4)) // expect: 10
|
||||
|
||||
var f5 = Fn.new {|a, b, c, d, e| a + b + c + d + e }
|
||||
IO.print(f5.call(1, 2, 3, 4, 5)) // expect: 15
|
||||
System.print(f5.call(1, 2, 3, 4, 5)) // expect: 15
|
||||
|
||||
var f6 = Fn.new {|a, b, c, d, e, f| a + b + c + d + e + f }
|
||||
IO.print(f6.call(1, 2, 3, 4, 5, 6)) // expect: 21
|
||||
System.print(f6.call(1, 2, 3, 4, 5, 6)) // expect: 21
|
||||
|
||||
var f7 = Fn.new {|a, b, c, d, e, f, g| a + b + c + d + e + f + g }
|
||||
IO.print(f7.call(1, 2, 3, 4, 5, 6, 7)) // expect: 28
|
||||
System.print(f7.call(1, 2, 3, 4, 5, 6, 7)) // expect: 28
|
||||
|
||||
var f8 = Fn.new {|a, b, c, d, e, f, g, h| a + b + c + d + e + f + g + h }
|
||||
IO.print(f8.call(1, 2, 3, 4, 5, 6, 7, 8)) // expect: 36
|
||||
System.print(f8.call(1, 2, 3, 4, 5, 6, 7, 8)) // expect: 36
|
||||
|
||||
var f9 = Fn.new {|a, b, c, d, e, f, g, h, i| a + b + c + d + e + f + g + h + i }
|
||||
IO.print(f9.call(1, 2, 3, 4, 5, 6, 7, 8, 9)) // expect: 45
|
||||
System.print(f9.call(1, 2, 3, 4, 5, 6, 7, 8, 9)) // expect: 45
|
||||
|
||||
var f10 = Fn.new {|a, b, c, d, e, f, g, h, i, j| a + b + c + d + e + f + g + h + i + j }
|
||||
IO.print(f10.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) // expect: 55
|
||||
System.print(f10.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) // expect: 55
|
||||
|
||||
var f11 = Fn.new {|a, b, c, d, e, f, g, h, i, j, k| a + b + c + d + e + f + g + h + i + j + k }
|
||||
IO.print(f11.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) // expect: 66
|
||||
System.print(f11.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) // expect: 66
|
||||
|
||||
var f12 = Fn.new {|a, b, c, d, e, f, g, h, i, j, k, l| a + b + c + d + e + f + g + h + i + j + k + l }
|
||||
IO.print(f12.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) // expect: 78
|
||||
System.print(f12.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) // expect: 78
|
||||
|
||||
var f13 = Fn.new {|a, b, c, d, e, f, g, h, i, j, k, l, m| a + b + c + d + e + f + g + h + i + j + k + l + m }
|
||||
IO.print(f13.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) // expect: 91
|
||||
System.print(f13.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) // expect: 91
|
||||
|
||||
var f14 = Fn.new {|a, b, c, d, e, f, g, h, i, j, k, l, m, n| a + b + c + d + e + f + g + h + i + j + k + l + m + n }
|
||||
IO.print(f14.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) // expect: 105
|
||||
System.print(f14.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) // expect: 105
|
||||
|
||||
var f15 = Fn.new {|a, b, c, d, e, f, g, h, i, j, k, l, m, n, o| a + b + c + d + e + f + g + h + i + j + k + l + m + n + o }
|
||||
IO.print(f15.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) // expect: 120
|
||||
System.print(f15.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) // expect: 120
|
||||
|
||||
var f16 = Fn.new {|a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p| a + b + c + d + e + f + g + h + i + j + k + l + m + n + o + p }
|
||||
IO.print(f16.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) // expect: 136
|
||||
System.print(f16.call(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) // expect: 136
|
||||
|
||||
@ -1,25 +1,25 @@
|
||||
// Single expression body.
|
||||
Fn.new { IO.print("ok") }.call() // expect: ok
|
||||
Fn.new { System.print("ok") }.call() // expect: ok
|
||||
|
||||
// Curly body.
|
||||
Fn.new {
|
||||
IO.print("ok") // expect: ok
|
||||
System.print("ok") // expect: ok
|
||||
}.call()
|
||||
|
||||
// Multiple statements.
|
||||
Fn.new {
|
||||
IO.print("1") // expect: 1
|
||||
IO.print("2") // expect: 2
|
||||
System.print("1") // expect: 1
|
||||
System.print("2") // expect: 2
|
||||
}.call()
|
||||
|
||||
// Extra newlines.
|
||||
Fn.new {
|
||||
|
||||
|
||||
IO.print("1") // expect: 1
|
||||
System.print("1") // expect: 1
|
||||
|
||||
|
||||
IO.print("2") // expect: 2
|
||||
System.print("2") // expect: 2
|
||||
|
||||
|
||||
}.call()
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
// A dangling else binds to the right-most if.
|
||||
if (true) if (false) IO.print("bad") else IO.print("good") // expect: good
|
||||
if (false) if (true) IO.print("bad") else IO.print("bad")
|
||||
if (true) if (false) System.print("bad") else System.print("good") // expect: good
|
||||
if (false) if (true) System.print("bad") else System.print("bad")
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Evaluate the 'else' expression if the condition is false.
|
||||
if (true) IO.print("good") else IO.print("bad") // expect: good
|
||||
if (false) IO.print("bad") else IO.print("good") // expect: good
|
||||
if (true) System.print("good") else System.print("bad") // expect: good
|
||||
if (false) System.print("bad") else System.print("good") // expect: good
|
||||
|
||||
// Allow block body.
|
||||
if (false) null else { IO.print("block") } // expect: block
|
||||
if (false) null else { System.print("block") } // expect: block
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
// Evaluate the 'then' expression if the condition is true.
|
||||
if (true) IO.print("good") // expect: good
|
||||
if (false) IO.print("bad")
|
||||
if (true) System.print("good") // expect: good
|
||||
if (false) System.print("bad")
|
||||
|
||||
// Allow block body.
|
||||
if (true) { IO.print("block") } // expect: block
|
||||
if (true) { System.print("block") } // expect: block
|
||||
|
||||
// Assignment in if condition.
|
||||
var a = false
|
||||
if (a = true) IO.print(a) // expect: true
|
||||
if (a = true) System.print(a) // expect: true
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
if // expect error
|
||||
(true) IO.print("bad")
|
||||
(true) System.print("bad")
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// False and null are false.
|
||||
if (false) IO.print("bad") else IO.print("false") // expect: false
|
||||
if (null) IO.print("bad") else IO.print("null") // expect: null
|
||||
if (false) System.print("bad") else System.print("false") // expect: false
|
||||
if (null) System.print("bad") else System.print("null") // expect: null
|
||||
|
||||
// Everything else is true.
|
||||
if (true) IO.print(true) // expect: true
|
||||
if (0) IO.print(0) // expect: 0
|
||||
if ("") IO.print("empty") // expect: empty
|
||||
if (true) System.print(true) // expect: true
|
||||
if (0) System.print(0) // expect: 0
|
||||
if ("") System.print("empty") // expect: empty
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// Sprinkle some carriage returns to ensure they are ignored anywhere:
|
||||
IO
|
||||
.print("one"
|
||||
System
|
||||
.print("one"
|
||||
)
|
||||
System.print
|
||||
("two")
|
||||
|
||||
@ -2,15 +2,15 @@ class Foo {
|
||||
construct new() {}
|
||||
|
||||
getter {
|
||||
IO.print("getter")
|
||||
System.print("getter")
|
||||
}
|
||||
|
||||
setter=(value) {
|
||||
IO.print("setter")
|
||||
System.print("setter")
|
||||
}
|
||||
|
||||
method(a) {
|
||||
IO.print("method")
|
||||
System.print("method")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,15 +2,15 @@ class Foo {
|
||||
construct new() {}
|
||||
|
||||
getter {
|
||||
IO.print("getter")
|
||||
System.print("getter")
|
||||
}
|
||||
|
||||
setter=(value) {
|
||||
IO.print("setter")
|
||||
System.print("setter")
|
||||
}
|
||||
|
||||
method(a) {
|
||||
IO.print("method")
|
||||
System.print("method")
|
||||
}
|
||||
|
||||
test {
|
||||
|
||||
@ -4,15 +4,15 @@ class Foo {
|
||||
bar { "getter" }
|
||||
|
||||
test {
|
||||
IO.print(bar) // expect: getter
|
||||
System.print(bar) // expect: getter
|
||||
|
||||
{
|
||||
IO.print(bar) // expect: getter
|
||||
System.print(bar) // expect: getter
|
||||
var bar = "local"
|
||||
IO.print(bar) // expect: local
|
||||
System.print(bar) // expect: local
|
||||
}
|
||||
|
||||
IO.print(bar) // expect: getter
|
||||
System.print(bar) // expect: getter
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ class Foo {
|
||||
construct new() {}
|
||||
|
||||
bar=(value) {
|
||||
IO.print("setter")
|
||||
System.print("setter")
|
||||
return value
|
||||
}
|
||||
|
||||
|
||||
@ -2,15 +2,15 @@ class Outer {
|
||||
construct new() {}
|
||||
|
||||
getter {
|
||||
IO.print("outer getter")
|
||||
System.print("outer getter")
|
||||
}
|
||||
|
||||
setter=(value) {
|
||||
IO.print("outer setter")
|
||||
System.print("outer setter")
|
||||
}
|
||||
|
||||
method(a) {
|
||||
IO.print("outer method")
|
||||
System.print("outer method")
|
||||
}
|
||||
|
||||
test {
|
||||
@ -22,15 +22,15 @@ class Outer {
|
||||
construct new() {}
|
||||
|
||||
getter {
|
||||
IO.print("inner getter")
|
||||
System.print("inner getter")
|
||||
}
|
||||
|
||||
setter=(value) {
|
||||
IO.print("inner setter")
|
||||
System.print("inner setter")
|
||||
}
|
||||
|
||||
method(a) {
|
||||
IO.print("inner method")
|
||||
System.print("inner method")
|
||||
}
|
||||
|
||||
test {
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
class Foo {
|
||||
static getter {
|
||||
IO.print("getter")
|
||||
System.print("getter")
|
||||
}
|
||||
|
||||
static setter=(value) {
|
||||
IO.print("setter")
|
||||
System.print("setter")
|
||||
}
|
||||
|
||||
static method(a) {
|
||||
IO.print("method")
|
||||
System.print("method")
|
||||
}
|
||||
|
||||
static test {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
class Foo {
|
||||
static methodOnFoo { IO.print("foo") }
|
||||
static methodOnFoo { System.print("foo") }
|
||||
}
|
||||
|
||||
class Bar is Foo {}
|
||||
|
||||
@ -7,8 +7,8 @@ class Foo {
|
||||
}
|
||||
|
||||
fooPrint {
|
||||
IO.print(_field1)
|
||||
IO.print(_field2)
|
||||
System.print(_field1)
|
||||
System.print(_field2)
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,8 +21,8 @@ class Bar is Foo {
|
||||
}
|
||||
|
||||
barPrint {
|
||||
IO.print(_field1)
|
||||
IO.print(_field2)
|
||||
System.print(_field1)
|
||||
System.print(_field2)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@ var ClosureType
|
||||
|
||||
{
|
||||
var a = "a"
|
||||
ClosureType = Fn.new { IO.print(a) }.type
|
||||
ClosureType = Fn.new { System.print(a) }.type
|
||||
}
|
||||
|
||||
class Subclass is ClosureType {} // expect runtime error: Class 'Subclass' cannot inherit from built-in class 'Fn'.
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
class Foo {
|
||||
methodOnFoo { IO.print("foo") }
|
||||
method(a) { IO.print("foo") }
|
||||
method(a, b, c) { IO.print("foo") }
|
||||
override { IO.print("foo") }
|
||||
methodOnFoo { System.print("foo") }
|
||||
method(a) { System.print("foo") }
|
||||
method(a, b, c) { System.print("foo") }
|
||||
override { System.print("foo") }
|
||||
}
|
||||
|
||||
class Bar is Foo {
|
||||
construct new() {}
|
||||
methodOnBar { IO.print("bar") }
|
||||
method(a, b) { IO.print("bar") }
|
||||
method(a, b, c, d) { IO.print("bar") }
|
||||
override { IO.print("bar") }
|
||||
methodOnBar { System.print("bar") }
|
||||
method(a, b) { System.print("bar") }
|
||||
method(a, b, c, d) { System.print("bar") }
|
||||
override { System.print("bar") }
|
||||
}
|
||||
|
||||
var bar = Bar.new()
|
||||
|
||||
@ -26,11 +26,11 @@ class Bar is Foo {
|
||||
}
|
||||
|
||||
var bar = Bar.new()
|
||||
IO.print(bar.closeOverFooGet.call().call()) // expect: Foo field
|
||||
IO.print(bar.closeOverBarGet.call().call()) // expect: Bar field
|
||||
System.print(bar.closeOverFooGet.call().call()) // expect: Foo field
|
||||
System.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
|
||||
System.print(bar.closeOverFooGet.call().call()) // expect: new foo value
|
||||
System.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
|
||||
System.print(bar.closeOverFooGet.call().call()) // expect: new foo value
|
||||
System.print(bar.closeOverBarGet.call().call()) // expect: new bar value
|
||||
|
||||
@ -11,12 +11,12 @@ var a = A.new()
|
||||
var b = B.new()
|
||||
var c = C.new()
|
||||
|
||||
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
|
||||
System.print(a is A) // expect: true
|
||||
System.print(a is B) // expect: false
|
||||
System.print(a is C) // expect: false
|
||||
System.print(b is A) // expect: true
|
||||
System.print(b is B) // expect: true
|
||||
System.print(b is C) // expect: false
|
||||
System.print(c is A) // expect: true
|
||||
System.print(c is B) // expect: true
|
||||
System.print(c is C) // expect: true
|
||||
|
||||
@ -1,33 +1,33 @@
|
||||
IO.print(Num is Class) // expect: true
|
||||
IO.print(true is Bool) // expect: true
|
||||
IO.print(Fn.new { 1 } is Fn) // expect: true
|
||||
IO.print(123 is Num) // expect: true
|
||||
IO.print(null is Null) // expect: true
|
||||
IO.print("s" is String) // expect: true
|
||||
System.print(Num is Class) // expect: true
|
||||
System.print(true is Bool) // expect: true
|
||||
System.print(Fn.new { 1 } is Fn) // expect: true
|
||||
System.print(123 is Num) // expect: true
|
||||
System.print(null is Null) // expect: true
|
||||
System.print("s" is String) // expect: true
|
||||
|
||||
IO.print(Num is Bool) // expect: false
|
||||
IO.print(null is Class) // expect: false
|
||||
IO.print(true is Fn) // expect: false
|
||||
IO.print(Fn.new { 1 } is Num) // expect: false
|
||||
IO.print("s" is Null) // expect: false
|
||||
IO.print(123 is String) // expect: false
|
||||
System.print(Num is Bool) // expect: false
|
||||
System.print(null is Class) // expect: false
|
||||
System.print(true is Fn) // expect: false
|
||||
System.print(Fn.new { 1 } is Num) // expect: false
|
||||
System.print("s" is Null) // expect: false
|
||||
System.print(123 is String) // expect: false
|
||||
|
||||
// Everything extends Object.
|
||||
IO.print(Num is Object) // expect: true
|
||||
IO.print(null is Object) // expect: true
|
||||
IO.print(true is Object) // expect: true
|
||||
IO.print(Fn.new { 1 } is Object) // expect: true
|
||||
IO.print("s" is Object) // expect: true
|
||||
IO.print(123 is Object) // expect: true
|
||||
System.print(Num is Object) // expect: true
|
||||
System.print(null is Object) // expect: true
|
||||
System.print(true is Object) // expect: true
|
||||
System.print(Fn.new { 1 } is Object) // expect: true
|
||||
System.print("s" is Object) // expect: true
|
||||
System.print(123 is Object) // expect: true
|
||||
|
||||
// Classes extend Class.
|
||||
IO.print(Num is Class) // expect: true
|
||||
IO.print(null is Class) // expect: false
|
||||
IO.print(true is Class) // expect: false
|
||||
IO.print(Fn.new { 1 } is Class) // expect: false
|
||||
IO.print("s" is Class) // expect: false
|
||||
IO.print(123 is Class) // expect: false
|
||||
System.print(Num is Class) // expect: true
|
||||
System.print(null is Class) // expect: false
|
||||
System.print(true is Class) // expect: false
|
||||
System.print(Fn.new { 1 } is Class) // expect: false
|
||||
System.print("s" is Class) // expect: false
|
||||
System.print(123 is Class) // expect: false
|
||||
|
||||
// Ignore newline after "is".
|
||||
IO.print(123 is
|
||||
System.print(123 is
|
||||
Num) // expect: true
|
||||
@ -8,4 +8,4 @@ for (i in 0..195) {
|
||||
list.removeAt(-1)
|
||||
}
|
||||
|
||||
IO.print(list) // expect: [0, 1, 2, 3, 4]
|
||||
System.print(list) // expect: [0, 1, 2, 3, 4]
|
||||
|
||||
@ -6,19 +6,19 @@ var list = [
|
||||
|
||||
]
|
||||
|
||||
IO.print(list[0]) // expect: a
|
||||
IO.print(list[1]) // expect: b
|
||||
System.print(list[0]) // expect: a
|
||||
System.print(list[1]) // expect: b
|
||||
|
||||
// Newline after trailing comma.
|
||||
list = ["c",
|
||||
|
||||
]
|
||||
|
||||
IO.print(list[0]) // expect: c
|
||||
System.print(list[0]) // expect: c
|
||||
|
||||
// Newline in empty list.
|
||||
list = [
|
||||
|
||||
]
|
||||
|
||||
IO.print(list.count) // expect: 0
|
||||
System.print(list.count) // expect: 0
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
var list = ["a", "b",]
|
||||
|
||||
IO.print(list[0]) // expect: a
|
||||
IO.print(list[1]) // expect: b
|
||||
System.print(list[0]) // expect: a
|
||||
System.print(list[1]) // expect: b
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
// Note: These tests implicitly depend on ints being truthy.
|
||||
// Also rely on IO.print() returning its argument.
|
||||
// Also rely on System.print() returning its argument.
|
||||
|
||||
// Return the first non-true argument.
|
||||
IO.print(false && 1) // expect: false
|
||||
IO.print(true && 1) // expect: 1
|
||||
IO.print(1 && 2 && false) // expect: false
|
||||
System.print(false && 1) // expect: false
|
||||
System.print(true && 1) // expect: 1
|
||||
System.print(1 && 2 && false) // expect: false
|
||||
|
||||
// Return the last argument if all are true.
|
||||
IO.print(1 && true) // expect: true
|
||||
IO.print(1 && 2 && 3) // expect: 3
|
||||
System.print(1 && true) // expect: true
|
||||
System.print(1 && 2 && 3) // expect: 3
|
||||
|
||||
// Short-circuit at the first false argument.
|
||||
IO.print(true) && // expect: true
|
||||
IO.print(false) && // expect: false
|
||||
IO.print(false) // should not print
|
||||
System.print(true) && // expect: true
|
||||
System.print(false) && // expect: false
|
||||
System.print(false) // should not print
|
||||
|
||||
// Swallow a trailing newline.
|
||||
IO.print(true &&
|
||||
System.print(true &&
|
||||
true) // expect: true
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// False and null are false.
|
||||
IO.print(false && "bad") // expect: false
|
||||
IO.print(null && "bad") // expect: null
|
||||
System.print(false && "bad") // expect: false
|
||||
System.print(null && "bad") // expect: null
|
||||
|
||||
// Everything else is true.
|
||||
IO.print(true && "ok") // expect: ok
|
||||
IO.print(0 && "ok") // expect: ok
|
||||
IO.print("" && "ok") // expect: ok
|
||||
System.print(true && "ok") // expect: ok
|
||||
System.print(0 && "ok") // expect: ok
|
||||
System.print("" && "ok") // expect: ok
|
||||
|
||||
@ -1,20 +1,20 @@
|
||||
// Note: These tests implicitly depend on ints being truthy.
|
||||
// Also rely on IO.print() returning its argument.
|
||||
// Also rely on System.print() returning its argument.
|
||||
|
||||
// Return the first true argument.
|
||||
IO.print(1 || true) // expect: 1
|
||||
IO.print(false || 1) // expect: 1
|
||||
IO.print(false || false || true) // expect: true
|
||||
System.print(1 || true) // expect: 1
|
||||
System.print(false || 1) // expect: 1
|
||||
System.print(false || false || true) // expect: true
|
||||
|
||||
// Return the last argument if all are false.
|
||||
IO.print(false || false) // expect: false
|
||||
IO.print(false || false || false) // expect: false
|
||||
System.print(false || false) // expect: false
|
||||
System.print(false || false || false) // expect: false
|
||||
|
||||
// Short-circuit at the first true argument.
|
||||
IO.print(false) || // expect: false
|
||||
IO.print(true) || // expect: true
|
||||
IO.print(true) // should not print
|
||||
System.print(false) || // expect: false
|
||||
System.print(true) || // expect: true
|
||||
System.print(true) // should not print
|
||||
|
||||
// Swallow a trailing newline.
|
||||
IO.print(true ||
|
||||
System.print(true ||
|
||||
true) // expect: true
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
// False and null are false.
|
||||
IO.print(false || "ok") // expect: ok
|
||||
IO.print(null || "ok") // expect: ok
|
||||
System.print(false || "ok") // expect: ok
|
||||
System.print(null || "ok") // expect: ok
|
||||
|
||||
// Everything else is true.
|
||||
IO.print(true || "ok") // expect: true
|
||||
IO.print(0 || "ok") // expect: 0
|
||||
IO.print("s" || "ok") // expect: s
|
||||
System.print(true || "ok") // expect: true
|
||||
System.print(0 || "ok") // expect: 0
|
||||
System.print("s" || "ok") // expect: s
|
||||
|
||||
@ -64,13 +64,13 @@ for (fish in fishes) {
|
||||
map[fish] = fish.count
|
||||
}
|
||||
|
||||
IO.print(map.count) // expect: 249
|
||||
System.print(map.count) // expect: 249
|
||||
|
||||
for (n in 0...150) {
|
||||
map.remove(fishes[n])
|
||||
}
|
||||
|
||||
IO.print(map.count) // expect: 99
|
||||
System.print(map.count) // expect: 99
|
||||
|
||||
// Make sure we can still find all of the remaining ones.
|
||||
var contained = 0
|
||||
@ -78,4 +78,4 @@ for (n in 150...249) {
|
||||
if (map.containsKey(fishes[n])) contained = contained + 1
|
||||
}
|
||||
|
||||
IO.print(contained) // expect: 99
|
||||
System.print(contained) // expect: 99
|
||||
|
||||
@ -9,19 +9,19 @@ var map = {
|
||||
|
||||
}
|
||||
|
||||
IO.print(map["a"]) // expect: a value
|
||||
IO.print(map["b"]) // expect: b value
|
||||
System.print(map["a"]) // expect: a value
|
||||
System.print(map["b"]) // expect: b value
|
||||
|
||||
// Newline after trailing comma.
|
||||
map = {"c": "c value",
|
||||
|
||||
}
|
||||
|
||||
IO.print(map["c"]) // expect: c value
|
||||
System.print(map["c"]) // expect: c value
|
||||
|
||||
// Newline in empty map.
|
||||
map = {
|
||||
|
||||
}
|
||||
|
||||
IO.print(map.count) // expect: 0
|
||||
System.print(map.count) // expect: 0
|
||||
|
||||
@ -3,5 +3,5 @@ var map = {
|
||||
"b": 2,
|
||||
}
|
||||
|
||||
IO.print(map["a"]) // expect: 1
|
||||
IO.print(map["b"]) // expect: 2
|
||||
System.print(map["a"]) // expect: 1
|
||||
System.print(map["b"]) // expect: 2
|
||||
|
||||
@ -21,21 +21,21 @@ class Foo {
|
||||
}
|
||||
|
||||
var foo = Foo.new()
|
||||
IO.print(foo.method) // expect: getter
|
||||
IO.print(foo.method()) // expect: no args
|
||||
IO.print(foo.method(1)) // expect: 1
|
||||
IO.print(foo.method(1, 2)) // expect: 3
|
||||
IO.print(foo.method(1, 2, 3)) // expect: 6
|
||||
IO.print(foo.method(1, 2, 3, 4)) // expect: 10
|
||||
IO.print(foo.method(1, 2, 3, 4, 5)) // expect: 15
|
||||
IO.print(foo.method(1, 2, 3, 4, 5, 6)) // expect: 21
|
||||
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7)) // expect: 28
|
||||
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8)) // expect: 36
|
||||
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9)) // expect: 45
|
||||
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) // expect: 55
|
||||
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) // expect: 66
|
||||
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) // expect: 78
|
||||
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) // expect: 91
|
||||
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) // expect: 105
|
||||
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) // expect: 120
|
||||
IO.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) // expect: 136
|
||||
System.print(foo.method) // expect: getter
|
||||
System.print(foo.method()) // expect: no args
|
||||
System.print(foo.method(1)) // expect: 1
|
||||
System.print(foo.method(1, 2)) // expect: 3
|
||||
System.print(foo.method(1, 2, 3)) // expect: 6
|
||||
System.print(foo.method(1, 2, 3, 4)) // expect: 10
|
||||
System.print(foo.method(1, 2, 3, 4, 5)) // expect: 15
|
||||
System.print(foo.method(1, 2, 3, 4, 5, 6)) // expect: 21
|
||||
System.print(foo.method(1, 2, 3, 4, 5, 6, 7)) // expect: 28
|
||||
System.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8)) // expect: 36
|
||||
System.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9)) // expect: 45
|
||||
System.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)) // expect: 55
|
||||
System.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)) // expect: 66
|
||||
System.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)) // expect: 78
|
||||
System.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13)) // expect: 91
|
||||
System.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14)) // expect: 105
|
||||
System.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15)) // expect: 120
|
||||
System.print(foo.method(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16)) // expect: 136
|
||||
|
||||
@ -3,4 +3,4 @@ class Foo {
|
||||
bar {}
|
||||
}
|
||||
|
||||
IO.print(Foo.new().bar) // expect: null
|
||||
System.print(Foo.new().bar) // expect: null
|
||||
|
||||
@ -5,4 +5,4 @@ class Foo {
|
||||
}
|
||||
}
|
||||
|
||||
IO.print(Foo.new().thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum) // expect: result
|
||||
System.print(Foo.new().thisHasAMethodNameThatIsExactly64CharactersLongWhichIsTheMaximum) // expect: result
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user