"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:
@@ -8,4 +8,4 @@ for (i in 0...100) {
|
||||
if (i >= 10) map.remove(i - 10)
|
||||
}
|
||||
|
||||
IO.print(map.count) // expect: 10
|
||||
System.print(map.count) // expect: 10
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var a = {1: 1, 2: 2, 3: 3}
|
||||
a.clear()
|
||||
IO.print(a) // expect: {}
|
||||
IO.print(a.count) // expect: 0
|
||||
System.print(a) // expect: {}
|
||||
System.print(a.count) // expect: 0
|
||||
|
||||
// Returns null.
|
||||
IO.print({1: 2}.clear()) // expect: null
|
||||
System.print({1: 2}.clear()) // expect: null
|
||||
|
||||
@@ -4,8 +4,8 @@ var map = {
|
||||
"three": 3
|
||||
}
|
||||
|
||||
IO.print(map.containsKey("one")) // expect: true
|
||||
IO.print(map.containsKey("two")) // expect: true
|
||||
IO.print(map.containsKey("three")) // expect: true
|
||||
IO.print(map.containsKey("four")) // expect: false
|
||||
IO.print(map.containsKey("five")) // expect: false
|
||||
System.print(map.containsKey("one")) // expect: true
|
||||
System.print(map.containsKey("two")) // expect: true
|
||||
System.print(map.containsKey("three")) // expect: true
|
||||
System.print(map.containsKey("four")) // expect: false
|
||||
System.print(map.containsKey("five")) // expect: false
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
var map = {}
|
||||
IO.print(map.count) // expect: 0
|
||||
System.print(map.count) // expect: 0
|
||||
map["one"] = "value"
|
||||
IO.print(map.count) // expect: 1
|
||||
System.print(map.count) // expect: 1
|
||||
map["two"] = "value"
|
||||
IO.print(map.count) // expect: 2
|
||||
System.print(map.count) // expect: 2
|
||||
map["three"] = "value"
|
||||
IO.print(map.count) // expect: 3
|
||||
System.print(map.count) // expect: 3
|
||||
|
||||
// Adding existing key does not increase count.
|
||||
map["two"] = "new value"
|
||||
IO.print(map.count) // expect: 3
|
||||
System.print(map.count) // expect: 3
|
||||
|
||||
@@ -2,4 +2,4 @@ var map = {
|
||||
"": "empty string"
|
||||
}
|
||||
|
||||
IO.print(map[""]) // expect: empty string
|
||||
System.print(map[""]) // expect: empty string
|
||||
|
||||
@@ -4,23 +4,23 @@ var a = {"one": 1, "two": 2, "three": 3, "four": 4}.keys
|
||||
// entry table and the hashing process isn't specified. So we just validate
|
||||
// what we can assume about them.
|
||||
|
||||
IO.print(a.iterate(null) is Num) // expect: true
|
||||
IO.print(a.iterate(null) >= 0) // expect: true
|
||||
System.print(a.iterate(null) is Num) // expect: true
|
||||
System.print(a.iterate(null) >= 0) // expect: true
|
||||
|
||||
IO.print(a.iterate(0) is Num) // expect: true
|
||||
IO.print(a.iterate(0) > 0) // expect: true
|
||||
IO.print(a.iterate(1) is Num) // expect: true
|
||||
IO.print(a.iterate(1) > 0) // expect: true
|
||||
IO.print(a.iterate(2) is Num) // expect: true
|
||||
IO.print(a.iterate(2) > 0) // expect: true
|
||||
IO.print(a.iterate(3) is Num) // expect: true
|
||||
IO.print(a.iterate(3) > 0) // expect: true
|
||||
System.print(a.iterate(0) is Num) // expect: true
|
||||
System.print(a.iterate(0) > 0) // expect: true
|
||||
System.print(a.iterate(1) is Num) // expect: true
|
||||
System.print(a.iterate(1) > 0) // expect: true
|
||||
System.print(a.iterate(2) is Num) // expect: true
|
||||
System.print(a.iterate(2) > 0) // expect: true
|
||||
System.print(a.iterate(3) is Num) // expect: true
|
||||
System.print(a.iterate(3) > 0) // expect: true
|
||||
|
||||
var previous = -1
|
||||
var iterator = a.iterate(null)
|
||||
while (iterator) {
|
||||
IO.print(iterator > previous)
|
||||
IO.print(iterator is Num)
|
||||
System.print(iterator > previous)
|
||||
System.print(iterator is Num)
|
||||
previous = iterator
|
||||
iterator = a.iterate(iterator)
|
||||
}
|
||||
@@ -38,8 +38,8 @@ while (iterator) {
|
||||
// expect: true
|
||||
|
||||
// Out of bounds.
|
||||
IO.print(a.iterate(16)) // expect: false
|
||||
IO.print(a.iterate(-1)) // expect: false
|
||||
System.print(a.iterate(16)) // expect: false
|
||||
System.print(a.iterate(-1)) // expect: false
|
||||
|
||||
// Nothing to iterate in an empty map.
|
||||
IO.print({}.keys.iterate(null)) // expect: false
|
||||
System.print({}.keys.iterate(null)) // expect: false
|
||||
|
||||
@@ -12,17 +12,17 @@ var map = {
|
||||
fiber: "fiber"
|
||||
}
|
||||
|
||||
IO.print(map[null]) // expect: null value
|
||||
IO.print(map[true]) // expect: true value
|
||||
IO.print(map[false]) // expect: false value
|
||||
IO.print(map[0]) // expect: zero
|
||||
IO.print(map[1.2]) // expect: 1 point 2
|
||||
IO.print(map[List]) // expect: list class
|
||||
IO.print(map["null"]) // expect: string value
|
||||
IO.print(map[1..3]) // expect: 1 to 3
|
||||
IO.print(map[fiber]) // expect: fiber
|
||||
System.print(map[null]) // expect: null value
|
||||
System.print(map[true]) // expect: true value
|
||||
System.print(map[false]) // expect: false value
|
||||
System.print(map[0]) // expect: zero
|
||||
System.print(map[1.2]) // expect: 1 point 2
|
||||
System.print(map[List]) // expect: list class
|
||||
System.print(map["null"]) // expect: string value
|
||||
System.print(map[1..3]) // expect: 1 to 3
|
||||
System.print(map[fiber]) // expect: fiber
|
||||
|
||||
IO.print(map.count) // expect: 9
|
||||
System.print(map.count) // expect: 9
|
||||
|
||||
// Use the same keys (but sometimes different objects) to ensure keys have the
|
||||
// right equality semantics.
|
||||
@@ -35,13 +35,13 @@ map[[].type] = "new list class"
|
||||
map["nu" + "ll"] = "new string value"
|
||||
map[(3 - 2)..(1 + 2)] = "new 1 to 3"
|
||||
|
||||
IO.print(map[null]) // expect: new null value
|
||||
IO.print(map[true]) // expect: new true value
|
||||
IO.print(map[false]) // expect: new false value
|
||||
IO.print(map[0]) // expect: new zero
|
||||
IO.print(map[1.2]) // expect: new 1 point 2
|
||||
IO.print(map[List]) // expect: new list class
|
||||
IO.print(map["null"]) // expect: new string value
|
||||
IO.print(map[1..3]) // expect: new 1 to 3
|
||||
System.print(map[null]) // expect: new null value
|
||||
System.print(map[true]) // expect: new true value
|
||||
System.print(map[false]) // expect: new false value
|
||||
System.print(map[0]) // expect: new zero
|
||||
System.print(map[1.2]) // expect: new 1 point 2
|
||||
System.print(map[List]) // expect: new list class
|
||||
System.print(map["null"]) // expect: new string value
|
||||
System.print(map[1..3]) // expect: new 1 to 3
|
||||
|
||||
IO.print(map.count) // expect: 9
|
||||
System.print(map.count) // expect: 9
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var map = Map.new()
|
||||
|
||||
IO.print(map.count) // expect: 0
|
||||
IO.print(map) // expect: {}
|
||||
System.print(map.count) // expect: 0
|
||||
System.print(map) // expect: {}
|
||||
|
||||
@@ -4,15 +4,15 @@ var map = {
|
||||
"three": 3
|
||||
}
|
||||
|
||||
IO.print(map.count) // expect: 3
|
||||
IO.print(map.remove("two")) // expect: 2
|
||||
IO.print(map.count) // expect: 2
|
||||
IO.print(map.remove("three")) // expect: 3
|
||||
IO.print(map.count) // expect: 1
|
||||
System.print(map.count) // expect: 3
|
||||
System.print(map.remove("two")) // expect: 2
|
||||
System.print(map.count) // expect: 2
|
||||
System.print(map.remove("three")) // expect: 3
|
||||
System.print(map.count) // expect: 1
|
||||
|
||||
// Remove an already removed entry.
|
||||
IO.print(map.remove("two")) // expect: null
|
||||
IO.print(map.count) // expect: 1
|
||||
System.print(map.remove("two")) // expect: null
|
||||
System.print(map.count) // expect: 1
|
||||
|
||||
IO.print(map.remove("one")) // expect: 1
|
||||
IO.print(map.count) // expect: 0
|
||||
System.print(map.remove("one")) // expect: 1
|
||||
System.print(map.count) // expect: 0
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This is a regression test to ensure map handles a null entry array.
|
||||
|
||||
var map = {}
|
||||
IO.print(map["key"]) // expect: null
|
||||
System.print(map["key"]) // expect: null
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// Handle empty map.
|
||||
IO.print({}.toString) // expect: {}
|
||||
System.print({}.toString) // expect: {}
|
||||
|
||||
// Does not quote strings.
|
||||
IO.print({"1": "2"}.toString) // expect: {1: 2}
|
||||
System.print({"1": "2"}.toString) // expect: {1: 2}
|
||||
|
||||
// Nested maps.
|
||||
IO.print({1: {2: {}}}) // expect: {1: {2: {}}}
|
||||
System.print({1: {2: {}}}) // expect: {1: {2: {}}}
|
||||
|
||||
// Calls toString on elements.
|
||||
class Foo {
|
||||
@@ -13,12 +13,12 @@ class Foo {
|
||||
toString { "Foo.toString" }
|
||||
}
|
||||
|
||||
IO.print({1: Foo.new()}) // expect: {1: Foo.toString}
|
||||
System.print({1: Foo.new()}) // expect: {1: Foo.toString}
|
||||
|
||||
// Since iteration order is unspecified, we don't know what order the results
|
||||
// will be.
|
||||
var s = {1: 2, 3: 4, 5: 6}.toString
|
||||
IO.print(s == "{1: 2, 3: 4, 5: 6}" ||
|
||||
System.print(s == "{1: 2, 3: 4, 5: 6}" ||
|
||||
s == "{1: 2, 5: 6, 3: 4}" ||
|
||||
s == "{3: 4, 1: 2, 5: 6}" ||
|
||||
s == "{3: 4, 5: 6, 1: 2}" ||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
IO.print({} is Map) // expect: true
|
||||
System.print({} is Map) // expect: true
|
||||
// TODO: Abstract base class for associations.
|
||||
IO.print({} is Object) // expect: true
|
||||
IO.print({} is Bool) // expect: false
|
||||
IO.print({}.type == Map) // expect: true
|
||||
System.print({} is Object) // expect: true
|
||||
System.print({} is Bool) // expect: false
|
||||
System.print({}.type == Map) // expect: true
|
||||
|
||||
@@ -4,23 +4,23 @@ var a = {"one": 1, "two": 2, "three": 3, "four": 4}.values
|
||||
// entry table and the hashing process isn't specified. So we just validate
|
||||
// what we can assume about them.
|
||||
|
||||
IO.print(a.iterate(null) is Num) // expect: true
|
||||
IO.print(a.iterate(null) >= 0) // expect: true
|
||||
System.print(a.iterate(null) is Num) // expect: true
|
||||
System.print(a.iterate(null) >= 0) // expect: true
|
||||
|
||||
IO.print(a.iterate(0) is Num) // expect: true
|
||||
IO.print(a.iterate(0) > 0) // expect: true
|
||||
IO.print(a.iterate(1) is Num) // expect: true
|
||||
IO.print(a.iterate(1) > 0) // expect: true
|
||||
IO.print(a.iterate(2) is Num) // expect: true
|
||||
IO.print(a.iterate(2) > 0) // expect: true
|
||||
IO.print(a.iterate(3) is Num) // expect: true
|
||||
IO.print(a.iterate(3) > 0) // expect: true
|
||||
System.print(a.iterate(0) is Num) // expect: true
|
||||
System.print(a.iterate(0) > 0) // expect: true
|
||||
System.print(a.iterate(1) is Num) // expect: true
|
||||
System.print(a.iterate(1) > 0) // expect: true
|
||||
System.print(a.iterate(2) is Num) // expect: true
|
||||
System.print(a.iterate(2) > 0) // expect: true
|
||||
System.print(a.iterate(3) is Num) // expect: true
|
||||
System.print(a.iterate(3) > 0) // expect: true
|
||||
|
||||
var previous = -1
|
||||
var iterator = a.iterate(null)
|
||||
while (iterator) {
|
||||
IO.print(iterator > previous)
|
||||
IO.print(iterator is Num)
|
||||
System.print(iterator > previous)
|
||||
System.print(iterator is Num)
|
||||
previous = iterator
|
||||
iterator = a.iterate(iterator)
|
||||
}
|
||||
@@ -38,8 +38,8 @@ while (iterator) {
|
||||
// expect: true
|
||||
|
||||
// Out of bounds.
|
||||
IO.print(a.iterate(16)) // expect: false
|
||||
IO.print(a.iterate(-1)) // expect: false
|
||||
System.print(a.iterate(16)) // expect: false
|
||||
System.print(a.iterate(-1)) // expect: false
|
||||
|
||||
// Nothing to iterate in an empty map.
|
||||
IO.print({}.values.iterate(null)) // expect: false
|
||||
System.print({}.values.iterate(null)) // expect: false
|
||||
|
||||
Reference in New Issue
Block a user