Make IO a static class instead of a singleton.

This commit is contained in:
Bob Nystrom
2013-12-21 19:25:09 -08:00
parent 24a6f4cd8c
commit 6c3aa85228
119 changed files with 532 additions and 536 deletions
+9 -9
View File
@@ -1,32 +1,32 @@
var a = [1, 2, 3]
a.removeAt(0)
io.write(a) // expect: [2, 3]
IO.write(a) // expect: [2, 3]
var b = [1, 2, 3]
b.removeAt(1)
io.write(b) // expect: [1, 3]
IO.write(b) // expect: [1, 3]
var c = [1, 2, 3]
c.removeAt(2)
io.write(c) // expect: [1, 2]
IO.write(c) // expect: [1, 2]
// Index backwards from end.
var d = [1, 2, 3]
d.removeAt(-3)
io.write(d) // expect: [2, 3]
IO.write(d) // expect: [2, 3]
var e = [1, 2, 3]
e.removeAt(-2)
io.write(e) // expect: [1, 3]
IO.write(e) // expect: [1, 3]
var f = [1, 2, 3]
f.removeAt(-1)
io.write(f) // expect: [1, 2]
IO.write(f) // expect: [1, 2]
// Out of bounds.
// TODO: Signal error in better way.
io.write([1, 2, 3].removeAt(3)) // expect: null
io.write([1, 2, 3].removeAt(-4)) // expect: null
IO.write([1, 2, 3].removeAt(3)) // expect: null
IO.write([1, 2, 3].removeAt(-4)) // expect: null
// Return the removed value.
io.write([3, 4, 5].removeAt(1)) // expect: 4
IO.write([3, 4, 5].removeAt(1)) // expect: 4