feat: replace IO class with System class and remove separate IO module
- Delete wren_io.c, wren_io.h, and io.wren source files - Remove multi-arity print overloads and IO.read/IO.time methods - Add System class with print, printAll, write, writeAll methods to core.wren - Update all documentation examples and README to use System.print instead of IO.print
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
// Ordered range.
|
||||
IO.print((2..5).contains(1)) // expect: false
|
||||
IO.print((2..5).contains(2)) // expect: true
|
||||
IO.print((2..5).contains(5)) // expect: true
|
||||
IO.print((2..5).contains(6)) // expect: false
|
||||
System.print((2..5).contains(1)) // expect: false
|
||||
System.print((2..5).contains(2)) // expect: true
|
||||
System.print((2..5).contains(5)) // expect: true
|
||||
System.print((2..5).contains(6)) // expect: false
|
||||
|
||||
// Backwards range.
|
||||
IO.print((5..2).contains(1)) // expect: false
|
||||
IO.print((5..2).contains(2)) // expect: true
|
||||
IO.print((5..2).contains(5)) // expect: true
|
||||
IO.print((5..2).contains(6)) // expect: false
|
||||
System.print((5..2).contains(1)) // expect: false
|
||||
System.print((5..2).contains(2)) // expect: true
|
||||
System.print((5..2).contains(5)) // expect: true
|
||||
System.print((5..2).contains(6)) // expect: false
|
||||
|
||||
// Exclusive ordered range.
|
||||
IO.print((2...5).contains(1)) // expect: false
|
||||
IO.print((2...5).contains(2)) // expect: true
|
||||
IO.print((2...5).contains(5)) // expect: false
|
||||
IO.print((2...5).contains(6)) // expect: false
|
||||
System.print((2...5).contains(1)) // expect: false
|
||||
System.print((2...5).contains(2)) // expect: true
|
||||
System.print((2...5).contains(5)) // expect: false
|
||||
System.print((2...5).contains(6)) // expect: false
|
||||
|
||||
// Exclusive backwards range.
|
||||
IO.print((5...2).contains(1)) // expect: false
|
||||
IO.print((5...2).contains(2)) // expect: false
|
||||
IO.print((5...2).contains(5)) // expect: true
|
||||
IO.print((5...2).contains(6)) // expect: false
|
||||
System.print((5...2).contains(1)) // expect: false
|
||||
System.print((5...2).contains(2)) // expect: false
|
||||
System.print((5...2).contains(5)) // expect: true
|
||||
System.print((5...2).contains(6)) // expect: false
|
||||
|
||||
@@ -3,15 +3,15 @@ var b = 2..6
|
||||
var c = 2...5
|
||||
var d = 2...6
|
||||
|
||||
IO.print(a == 2..5) // expect: true
|
||||
IO.print(a == 2..6) // expect: false
|
||||
IO.print(c == 2...5) // expect: true
|
||||
IO.print(c == 2...6) // expect: false
|
||||
System.print(a == 2..5) // expect: true
|
||||
System.print(a == 2..6) // expect: false
|
||||
System.print(c == 2...5) // expect: true
|
||||
System.print(c == 2...6) // expect: false
|
||||
|
||||
IO.print(b != 2..5) // expect: true
|
||||
IO.print(b != 2..6) // expect: false
|
||||
IO.print(d != 2...5) // expect: true
|
||||
IO.print(d != 2...6) // expect: false
|
||||
System.print(b != 2..5) // expect: true
|
||||
System.print(b != 2..6) // expect: false
|
||||
System.print(d != 2...5) // expect: true
|
||||
System.print(d != 2...6) // expect: false
|
||||
|
||||
IO.print(a != c) // expect: true
|
||||
IO.print(b != d) // expect: true
|
||||
System.print(a != c) // expect: true
|
||||
System.print(b != d) // expect: true
|
||||
@@ -1,25 +1,25 @@
|
||||
// Ordered range.
|
||||
IO.print((2..5).from) // expect: 2
|
||||
IO.print((3..3).from) // expect: 3
|
||||
IO.print((0..3).from) // expect: 0
|
||||
IO.print((-5..3).from) // expect: -5
|
||||
IO.print((-5..-2).from) // expect: -5
|
||||
System.print((2..5).from) // expect: 2
|
||||
System.print((3..3).from) // expect: 3
|
||||
System.print((0..3).from) // expect: 0
|
||||
System.print((-5..3).from) // expect: -5
|
||||
System.print((-5..-2).from) // expect: -5
|
||||
|
||||
// Backwards range.
|
||||
IO.print((5..2).from) // expect: 5
|
||||
IO.print((3..0).from) // expect: 3
|
||||
IO.print((3..-5).from) // expect: 3
|
||||
IO.print((-2..-5).from) // expect: -2
|
||||
System.print((5..2).from) // expect: 5
|
||||
System.print((3..0).from) // expect: 3
|
||||
System.print((3..-5).from) // expect: 3
|
||||
System.print((-2..-5).from) // expect: -2
|
||||
|
||||
// Exclusive ordered range.
|
||||
IO.print((2...5).from) // expect: 2
|
||||
IO.print((3...3).from) // expect: 3
|
||||
IO.print((0...3).from) // expect: 0
|
||||
IO.print((-5...3).from) // expect: -5
|
||||
IO.print((-5...-2).from) // expect: -5
|
||||
System.print((2...5).from) // expect: 2
|
||||
System.print((3...3).from) // expect: 3
|
||||
System.print((0...3).from) // expect: 0
|
||||
System.print((-5...3).from) // expect: -5
|
||||
System.print((-5...-2).from) // expect: -5
|
||||
|
||||
// Exclusive backwards range.
|
||||
IO.print((5...2).from) // expect: 5
|
||||
IO.print((3...0).from) // expect: 3
|
||||
IO.print((3...-5).from) // expect: 3
|
||||
IO.print((-2...-5).from) // expect: -2
|
||||
System.print((5...2).from) // expect: 5
|
||||
System.print((3...0).from) // expect: 3
|
||||
System.print((3...-5).from) // expect: 3
|
||||
System.print((-2...-5).from) // expect: -2
|
||||
|
||||
+18
-18
@@ -1,25 +1,25 @@
|
||||
// Ordered range.
|
||||
IO.print((2..5).from) // expect: 2
|
||||
IO.print((3..3).from) // expect: 3
|
||||
IO.print((0..3).from) // expect: 0
|
||||
IO.print((-5..3).from) // expect: -5
|
||||
IO.print((-5..-2).from) // expect: -5
|
||||
System.print((2..5).from) // expect: 2
|
||||
System.print((3..3).from) // expect: 3
|
||||
System.print((0..3).from) // expect: 0
|
||||
System.print((-5..3).from) // expect: -5
|
||||
System.print((-5..-2).from) // expect: -5
|
||||
|
||||
// Backwards range.
|
||||
IO.print((5..2).from) // expect: 5
|
||||
IO.print((3..0).from) // expect: 3
|
||||
IO.print((3..-5).from) // expect: 3
|
||||
IO.print((-2..-5).from) // expect: -2
|
||||
System.print((5..2).from) // expect: 5
|
||||
System.print((3..0).from) // expect: 3
|
||||
System.print((3..-5).from) // expect: 3
|
||||
System.print((-2..-5).from) // expect: -2
|
||||
|
||||
// Exclusive ordered range.
|
||||
IO.print((2...5).from) // expect: 2
|
||||
IO.print((3...3).from) // expect: 3
|
||||
IO.print((0...3).from) // expect: 0
|
||||
IO.print((-5...3).from) // expect: -5
|
||||
IO.print((-5...-2).from) // expect: -5
|
||||
System.print((2...5).from) // expect: 2
|
||||
System.print((3...3).from) // expect: 3
|
||||
System.print((0...3).from) // expect: 0
|
||||
System.print((-5...3).from) // expect: -5
|
||||
System.print((-5...-2).from) // expect: -5
|
||||
|
||||
// Exclusive backwards range.
|
||||
IO.print((5...2).from) // expect: 5
|
||||
IO.print((3...0).from) // expect: 3
|
||||
IO.print((3...-5).from) // expect: 3
|
||||
IO.print((-2...-5).from) // expect: -2
|
||||
System.print((5...2).from) // expect: 5
|
||||
System.print((3...0).from) // expect: 3
|
||||
System.print((3...-5).from) // expect: 3
|
||||
System.print((-2...-5).from) // expect: -2
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
IO.print((0..0).isInclusive) // expect: true
|
||||
IO.print((0...0).isInclusive) // expect: false
|
||||
System.print((0..0).isInclusive) // expect: true
|
||||
System.print((0...0).isInclusive) // expect: false
|
||||
|
||||
IO.print((-1..1).isInclusive) // expect: true
|
||||
IO.print((-1...1).isInclusive) // expect: false
|
||||
System.print((-1..1).isInclusive) // expect: true
|
||||
System.print((-1...1).isInclusive) // expect: false
|
||||
|
||||
@@ -1,35 +1,35 @@
|
||||
// Inclusive.
|
||||
var range = 1..3
|
||||
IO.print(range.iterate(null)) // expect: 1
|
||||
IO.print(range.iterate(1)) // expect: 2
|
||||
IO.print(range.iterate(2)) // expect: 3
|
||||
IO.print(range.iterate(3)) // expect: false
|
||||
IO.print(range.iterate(4)) // expect: false
|
||||
System.print(range.iterate(null)) // expect: 1
|
||||
System.print(range.iterate(1)) // expect: 2
|
||||
System.print(range.iterate(2)) // expect: 3
|
||||
System.print(range.iterate(3)) // expect: false
|
||||
System.print(range.iterate(4)) // expect: false
|
||||
|
||||
// Exclusive
|
||||
range = 1...3
|
||||
IO.print(range.iterate(null)) // expect: 1
|
||||
IO.print(range.iterate(1)) // expect: 2
|
||||
IO.print(range.iterate(2)) // expect: false
|
||||
System.print(range.iterate(null)) // expect: 1
|
||||
System.print(range.iterate(1)) // expect: 2
|
||||
System.print(range.iterate(2)) // expect: false
|
||||
|
||||
// Negative inclusive range.
|
||||
range = 3..1
|
||||
IO.print(range.iterate(null)) // expect: 3
|
||||
IO.print(range.iterate(3)) // expect: 2
|
||||
IO.print(range.iterate(2)) // expect: 1
|
||||
IO.print(range.iterate(1)) // expect: false
|
||||
System.print(range.iterate(null)) // expect: 3
|
||||
System.print(range.iterate(3)) // expect: 2
|
||||
System.print(range.iterate(2)) // expect: 1
|
||||
System.print(range.iterate(1)) // expect: false
|
||||
|
||||
// Negative exclusive range.
|
||||
range = 3...1
|
||||
IO.print(range.iterate(null)) // expect: 3
|
||||
IO.print(range.iterate(3)) // expect: 2
|
||||
IO.print(range.iterate(2)) // expect: false
|
||||
System.print(range.iterate(null)) // expect: 3
|
||||
System.print(range.iterate(3)) // expect: 2
|
||||
System.print(range.iterate(2)) // expect: false
|
||||
|
||||
// Empty inclusive range.
|
||||
range = 1..1
|
||||
IO.print(range.iterate(null)) // expect: 1
|
||||
IO.print(range.iterate(1)) // expect: false
|
||||
System.print(range.iterate(null)) // expect: 1
|
||||
System.print(range.iterate(1)) // expect: false
|
||||
|
||||
// Empty exclusive range.
|
||||
range = 1...1
|
||||
IO.print(range.iterate(null)) // expect: false
|
||||
System.print(range.iterate(null)) // expect: false
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// Starts at "from" and adds 1.0 each iteration.
|
||||
|
||||
for (n in 1.3..4.5) IO.print(n)
|
||||
for (n in 1.3..4.5) System.print(n)
|
||||
// expect: 1.3
|
||||
// expect: 2.3
|
||||
// expect: 3.3
|
||||
// expect: 4.3
|
||||
|
||||
for (n in 1.3...4.5) IO.print(n)
|
||||
for (n in 1.3...4.5) System.print(n)
|
||||
// expect: 1.3
|
||||
// expect: 2.3
|
||||
// expect: 3.3
|
||||
// expect: 4.3
|
||||
|
||||
for (n in 1.3...4.3) IO.print(n)
|
||||
for (n in 1.3...4.3) System.print(n)
|
||||
// expect: 1.3
|
||||
// expect: 2.3
|
||||
// expect: 3.3
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
var range = 1..3
|
||||
IO.print(range.iteratorValue(1)) // expect: 1
|
||||
IO.print(range.iteratorValue(2)) // expect: 2
|
||||
IO.print(range.iteratorValue(3)) // expect: 3
|
||||
System.print(range.iteratorValue(1)) // expect: 1
|
||||
System.print(range.iteratorValue(2)) // expect: 2
|
||||
System.print(range.iteratorValue(3)) // expect: 3
|
||||
|
||||
// Doesn't bother to bounds check.
|
||||
IO.print(range.iteratorValue(-2)) // expect: -2
|
||||
IO.print(range.iteratorValue(5)) // expect: 5
|
||||
System.print(range.iteratorValue(-2)) // expect: -2
|
||||
System.print(range.iteratorValue(5)) // expect: 5
|
||||
|
||||
// Or type check.
|
||||
IO.print(range.iteratorValue("s")) // expect: s
|
||||
System.print(range.iteratorValue("s")) // expect: s
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var a = 1..3
|
||||
|
||||
IO.print(a.join) // expect: 123
|
||||
IO.print(a.join(", ")) // expect: 1, 2, 3
|
||||
System.print(a.join) // expect: 123
|
||||
System.print(a.join(", ")) // expect: 1, 2, 3
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
var a = 1..3
|
||||
var b = a.map {|x| x + 1 }.toList
|
||||
IO.print(b) // expect: [2, 3, 4]
|
||||
System.print(b) // expect: [2, 3, 4]
|
||||
|
||||
+18
-18
@@ -1,25 +1,25 @@
|
||||
// Ordered range.
|
||||
IO.print((2..5).max) // expect: 5
|
||||
IO.print((3..3).max) // expect: 3
|
||||
IO.print((0..3).max) // expect: 3
|
||||
IO.print((-5..3).max) // expect: 3
|
||||
IO.print((-5..-2).max) // expect: -2
|
||||
System.print((2..5).max) // expect: 5
|
||||
System.print((3..3).max) // expect: 3
|
||||
System.print((0..3).max) // expect: 3
|
||||
System.print((-5..3).max) // expect: 3
|
||||
System.print((-5..-2).max) // expect: -2
|
||||
|
||||
// Backwards range.
|
||||
IO.print((5..2).max) // expect: 5
|
||||
IO.print((3..0).max) // expect: 3
|
||||
IO.print((3..-5).max) // expect: 3
|
||||
IO.print((-2..-5).max) // expect: -2
|
||||
System.print((5..2).max) // expect: 5
|
||||
System.print((3..0).max) // expect: 3
|
||||
System.print((3..-5).max) // expect: 3
|
||||
System.print((-2..-5).max) // expect: -2
|
||||
|
||||
// Exclusive ordered range.
|
||||
IO.print((2...5).max) // expect: 5
|
||||
IO.print((3...3).max) // expect: 3
|
||||
IO.print((0...3).max) // expect: 3
|
||||
IO.print((-5...3).max) // expect: 3
|
||||
IO.print((-5...-2).max) // expect: -2
|
||||
System.print((2...5).max) // expect: 5
|
||||
System.print((3...3).max) // expect: 3
|
||||
System.print((0...3).max) // expect: 3
|
||||
System.print((-5...3).max) // expect: 3
|
||||
System.print((-5...-2).max) // expect: -2
|
||||
|
||||
// Exclusive backwards range.
|
||||
IO.print((5...2).max) // expect: 5
|
||||
IO.print((3...0).max) // expect: 3
|
||||
IO.print((3...-5).max) // expect: 3
|
||||
IO.print((-2...-5).max) // expect: -2
|
||||
System.print((5...2).max) // expect: 5
|
||||
System.print((3...0).max) // expect: 3
|
||||
System.print((3...-5).max) // expect: 3
|
||||
System.print((-2...-5).max) // expect: -2
|
||||
|
||||
+18
-18
@@ -1,25 +1,25 @@
|
||||
// Ordered range.
|
||||
IO.print((2..5).min) // expect: 2
|
||||
IO.print((3..3).min) // expect: 3
|
||||
IO.print((0..3).min) // expect: 0
|
||||
IO.print((-5..3).min) // expect: -5
|
||||
IO.print((-5..-2).min) // expect: -5
|
||||
System.print((2..5).min) // expect: 2
|
||||
System.print((3..3).min) // expect: 3
|
||||
System.print((0..3).min) // expect: 0
|
||||
System.print((-5..3).min) // expect: -5
|
||||
System.print((-5..-2).min) // expect: -5
|
||||
|
||||
// Backwards range.
|
||||
IO.print((5..2).min) // expect: 2
|
||||
IO.print((3..0).min) // expect: 0
|
||||
IO.print((3..-5).min) // expect: -5
|
||||
IO.print((-2..-5).min) // expect: -5
|
||||
System.print((5..2).min) // expect: 2
|
||||
System.print((3..0).min) // expect: 0
|
||||
System.print((3..-5).min) // expect: -5
|
||||
System.print((-2..-5).min) // expect: -5
|
||||
|
||||
// Exclusive ordered range.
|
||||
IO.print((2...5).min) // expect: 2
|
||||
IO.print((3...3).min) // expect: 3
|
||||
IO.print((0...3).min) // expect: 0
|
||||
IO.print((-5...3).min) // expect: -5
|
||||
IO.print((-5...-2).min) // expect: -5
|
||||
System.print((2...5).min) // expect: 2
|
||||
System.print((3...3).min) // expect: 3
|
||||
System.print((0...3).min) // expect: 0
|
||||
System.print((-5...3).min) // expect: -5
|
||||
System.print((-5...-2).min) // expect: -5
|
||||
|
||||
// Exclusive backwards range.
|
||||
IO.print((5...2).min) // expect: 2
|
||||
IO.print((3...0).min) // expect: 0
|
||||
IO.print((3...-5).min) // expect: -5
|
||||
IO.print((-2...-5).min) // expect: -5
|
||||
System.print((5...2).min) // expect: 2
|
||||
System.print((3...0).min) // expect: 0
|
||||
System.print((3...-5).min) // expect: -5
|
||||
System.print((-2...-5).min) // expect: -5
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var range = 1..10
|
||||
|
||||
IO.print(range.reduce {|a, b| a + b }) // expect: 55
|
||||
IO.print(range.reduce(100) {|a, b| a < b ? a : b }) // expect: 1
|
||||
System.print(range.reduce {|a, b| a + b }) // expect: 55
|
||||
System.print(range.reduce(100) {|a, b| a < b ? a : b }) // expect: 1
|
||||
|
||||
+18
-18
@@ -1,25 +1,25 @@
|
||||
// Ordered range.
|
||||
IO.print((2..5).to) // expect: 5
|
||||
IO.print((3..3).to) // expect: 3
|
||||
IO.print((0..3).to) // expect: 3
|
||||
IO.print((-5..3).to) // expect: 3
|
||||
IO.print((-5..-2).to) // expect: -2
|
||||
System.print((2..5).to) // expect: 5
|
||||
System.print((3..3).to) // expect: 3
|
||||
System.print((0..3).to) // expect: 3
|
||||
System.print((-5..3).to) // expect: 3
|
||||
System.print((-5..-2).to) // expect: -2
|
||||
|
||||
// Backwards range.
|
||||
IO.print((5..2).to) // expect: 2
|
||||
IO.print((3..0).to) // expect: 0
|
||||
IO.print((3..-5).to) // expect: -5
|
||||
IO.print((-2..-5).to) // expect: -5
|
||||
System.print((5..2).to) // expect: 2
|
||||
System.print((3..0).to) // expect: 0
|
||||
System.print((3..-5).to) // expect: -5
|
||||
System.print((-2..-5).to) // expect: -5
|
||||
|
||||
// Exclusive ordered range.
|
||||
IO.print((2...5).to) // expect: 5
|
||||
IO.print((3...3).to) // expect: 3
|
||||
IO.print((0...3).to) // expect: 3
|
||||
IO.print((-5...3).to) // expect: 3
|
||||
IO.print((-5...-2).to) // expect: -2
|
||||
System.print((2...5).to) // expect: 5
|
||||
System.print((3...3).to) // expect: 3
|
||||
System.print((0...3).to) // expect: 3
|
||||
System.print((-5...3).to) // expect: 3
|
||||
System.print((-5...-2).to) // expect: -2
|
||||
|
||||
// Exclusive backwards range.
|
||||
IO.print((5...2).to) // expect: 2
|
||||
IO.print((3...0).to) // expect: 0
|
||||
IO.print((3...-5).to) // expect: -5
|
||||
IO.print((-2...-5).to) // expect: -5
|
||||
System.print((5...2).to) // expect: 2
|
||||
System.print((3...0).to) // expect: 0
|
||||
System.print((3...-5).to) // expect: -5
|
||||
System.print((-2...-5).to) // expect: -5
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
IO.print(1..3) // expect: 1..3
|
||||
IO.print(12345.6789..12345.6789) // expect: 12345.6789..12345.6789
|
||||
IO.print(-100..-300) // expect: -100..-300
|
||||
System.print(1..3) // expect: 1..3
|
||||
System.print(12345.6789..12345.6789) // expect: 12345.6789..12345.6789
|
||||
System.print(-100..-300) // expect: -100..-300
|
||||
|
||||
IO.print(1...3) // expect: 1...3
|
||||
IO.print(12345.6789...12345.6789) // expect: 12345.6789...12345.6789
|
||||
IO.print(-100...-300) // expect: -100...-300
|
||||
System.print(1...3) // expect: 1...3
|
||||
System.print(12345.6789...12345.6789) // expect: 12345.6789...12345.6789
|
||||
System.print(-100...-300) // expect: -100...-300
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
var range = 2..5
|
||||
|
||||
IO.print(range is Range) // expect: true
|
||||
IO.print(range is Sequence) // expect: true
|
||||
IO.print(range is Object) // expect: true
|
||||
IO.print(range is String) // expect: false
|
||||
IO.print(range.type == Range) // expect: true
|
||||
System.print(range is Range) // expect: true
|
||||
System.print(range is Sequence) // expect: true
|
||||
System.print(range is Object) // expect: true
|
||||
System.print(range is String) // expect: false
|
||||
System.print(range.type == Range) // expect: true
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
var a = 1..3
|
||||
var b = a.where {|x| x > 1 }.toList
|
||||
IO.print(b) // expect: [2, 3]
|
||||
System.print(b) // expect: [2, 3]
|
||||
|
||||
var c = a.where {|x| x > 10 }.toList
|
||||
IO.print(c) // expect: []
|
||||
System.print(c) // expect: []
|
||||
|
||||
Reference in New Issue
Block a user