refactor: move benchmark directory under test and update all references
The benchmark directory is relocated from the project root into the test directory, and all scripts, documentation links, and gitignore paths are updated accordingly. The test runner is also refactored to explicitly walk subdirectories (core, io, language, limit) instead of using a single test root, and a new test/README.md is added to document the test suite structure. Additionally, the constructor test for the Foo class is updated to add a zero-arity constructor and adjust expected output strings.
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
var a = 2..5
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
IO.print(a != c) // expect: true
|
||||
IO.print(b != d) // expect: true
|
||||
@@ -0,0 +1 @@
|
||||
1..."s" // expect runtime error: Right hand side of range must be a number.
|
||||
@@ -0,0 +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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
@@ -0,0 +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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
@@ -0,0 +1 @@
|
||||
1.."s" // expect runtime error: Right hand side of range must be a number.
|
||||
@@ -0,0 +1,5 @@
|
||||
IO.print((0..0).isInclusive) // expect: true
|
||||
IO.print((0...0).isInclusive) // expect: false
|
||||
|
||||
IO.print((-1..1).isInclusive) // expect: true
|
||||
IO.print((-1...1).isInclusive) // expect: false
|
||||
@@ -0,0 +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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// Empty inclusive range.
|
||||
range = 1..1
|
||||
IO.print(range.iterate(null)) // expect: 1
|
||||
IO.print(range.iterate(1)) // expect: false
|
||||
|
||||
// Empty exclusive range.
|
||||
range = 1...1
|
||||
IO.print(range.iterate(null)) // expect: false
|
||||
@@ -0,0 +1,18 @@
|
||||
// Starts at "from" and adds 1.0 each iteration.
|
||||
|
||||
for (n in 1.3..4.5) IO.print(n)
|
||||
// expect: 1.3
|
||||
// expect: 2.3
|
||||
// expect: 3.3
|
||||
// expect: 4.3
|
||||
|
||||
for (n in 1.3...4.5) IO.print(n)
|
||||
// expect: 1.3
|
||||
// expect: 2.3
|
||||
// expect: 3.3
|
||||
// expect: 4.3
|
||||
|
||||
for (n in 1.3...4.3) IO.print(n)
|
||||
// expect: 1.3
|
||||
// expect: 2.3
|
||||
// expect: 3.3
|
||||
@@ -0,0 +1 @@
|
||||
(1..3).iterate("") // expect runtime error: Iterator must be a number.
|
||||
@@ -0,0 +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
|
||||
|
||||
// Doesn't bother to bounds check.
|
||||
IO.print(range.iteratorValue(-2)) // expect: -2
|
||||
IO.print(range.iteratorValue(5)) // expect: 5
|
||||
|
||||
// Or type check.
|
||||
IO.print(range.iteratorValue("s")) // expect: s
|
||||
@@ -0,0 +1,4 @@
|
||||
var a = 1..3
|
||||
|
||||
IO.print(a.join) // expect: 123
|
||||
IO.print(a.join(", ")) // expect: 1, 2, 3
|
||||
@@ -0,0 +1 @@
|
||||
(1..3).join(2) // expect runtime error: Right operand must be a string.
|
||||
@@ -0,0 +1,3 @@
|
||||
var a = 1..3
|
||||
var b = a.map {|x| x + 1 }
|
||||
IO.print(b) // expect: [2, 3, 4]
|
||||
@@ -0,0 +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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
@@ -0,0 +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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
@@ -0,0 +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
|
||||
|
||||
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
|
||||
@@ -0,0 +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
|
||||
@@ -0,0 +1,6 @@
|
||||
var a = 1..3
|
||||
var b = a.where {|x| x > 1 }
|
||||
IO.print(b) // expect: [2, 3]
|
||||
|
||||
var c = a.where {|x| x > 10 }
|
||||
IO.print(c) // expect: []
|
||||
Reference in New Issue
Block a user