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:
@@ -1,4 +0,0 @@
|
||||
IO.print("a" + "b") // expect: ab
|
||||
|
||||
// 8-bit clean.
|
||||
IO.print(("a\0b" + "\0c") == "a\0b\0c") // expect: true
|
||||
@@ -1 +0,0 @@
|
||||
IO.print("a" + 123) // expect runtime error: Right operand must be a string.
|
||||
@@ -1,16 +0,0 @@
|
||||
IO.print("".contains("")) // expect: true
|
||||
IO.print("anything".contains("")) // expect: true
|
||||
IO.print("something".contains("meth")) // expect: true
|
||||
IO.print("something".contains("some")) // expect: true
|
||||
IO.print("something".contains("ing")) // expect: true
|
||||
IO.print("something".contains("math")) // expect: false
|
||||
|
||||
// Non-ASCII.
|
||||
IO.print("søméthîng".contains("méth")) // expect: true
|
||||
IO.print("søméthîng".contains("meth")) // expect: false
|
||||
|
||||
// 8-bit clean.
|
||||
IO.print("a\0b\0c".contains("\0")) // expect: true
|
||||
IO.print("a\0b\0c".contains("b")) // expect: true
|
||||
IO.print("a\0b\0c".contains("b\0c")) // expect: true
|
||||
IO.print("a\0b\0c".contains("bc")) // expect: false
|
||||
@@ -1 +0,0 @@
|
||||
"foo".contains(1) // expect runtime error: Argument must be a string.
|
||||
@@ -1,8 +0,0 @@
|
||||
IO.print("".count) // expect: 0
|
||||
IO.print("a string".count) // expect: 8
|
||||
|
||||
// 8-bit clean.
|
||||
IO.print("\0".count) // expect: 1
|
||||
IO.print("a\0b".count) // expect: 3
|
||||
IO.print("\0c".count) // expect: 2
|
||||
IO.print(("a\0b" + "\0c").count) // expect: 5
|
||||
@@ -1,15 +0,0 @@
|
||||
IO.print("abcd".endsWith("cd")) // expect: true
|
||||
IO.print("abcd".endsWith("abcde")) // expect: false
|
||||
IO.print("abcd".endsWith("abcd")) // expect: true
|
||||
IO.print("abcd".endsWith("f")) // expect: false
|
||||
IO.print("abcd".endsWith("")) // expect: true
|
||||
|
||||
// Non-ASCII.
|
||||
IO.print("søméthîng".endsWith("thîng")) // expect: true
|
||||
IO.print("søméthîng".endsWith("thing")) // expect: false
|
||||
|
||||
// 8-bit clean.
|
||||
IO.print("a\0b\0c".endsWith("\0")) // expect: false
|
||||
IO.print("a\0b\0c".endsWith("c")) // expect: true
|
||||
IO.print("a\0b\0c".endsWith("\0c")) // expect: true
|
||||
IO.print("a\0b\0c".endsWith("\0b")) // expect: false
|
||||
@@ -1 +0,0 @@
|
||||
IO.print("abcd".endsWith(null)) // expect runtime error: Argument must be a string.
|
||||
@@ -1,28 +0,0 @@
|
||||
IO.print("" == "") // expect: true
|
||||
IO.print("abcd" == "abcd") // expect: true
|
||||
IO.print("abcd" == "d") // expect: false
|
||||
IO.print("e" == "abcd") // expect: false
|
||||
IO.print("" == "abcd") // expect: false
|
||||
|
||||
// Not equal to other types.
|
||||
IO.print("1" == 1) // expect: false
|
||||
IO.print("true" == true) // expect: false
|
||||
|
||||
IO.print("" != "") // expect: false
|
||||
IO.print("abcd" != "abcd") // expect: false
|
||||
IO.print("abcd" != "d") // expect: true
|
||||
IO.print("e" != "abcd") // expect: true
|
||||
IO.print("" != "abcd") // expect: true
|
||||
|
||||
// Not equal to other types.
|
||||
IO.print("1" != 1) // expect: true
|
||||
IO.print("true" != true) // expect: true
|
||||
|
||||
// Non-ASCII.
|
||||
IO.print("vålue" == "value") // expect: false
|
||||
IO.print("vålue" == "vålue") // expect: true
|
||||
|
||||
// 8-bit clean.
|
||||
IO.print("a\0b\0c" == "a") // expect: false
|
||||
IO.print("a\0b\0c" == "abc") // expect: false
|
||||
IO.print("a\0b\0c" == "a\0b\0c") // expect: true
|
||||
@@ -1,7 +0,0 @@
|
||||
// Escape characters.
|
||||
IO.print("\"") // expect: "
|
||||
IO.print("\\") // expect: \
|
||||
IO.print("(\n)") // expect: (
|
||||
// expect: )
|
||||
|
||||
// TODO: Non-printing escapes like \t.
|
||||
@@ -1,2 +0,0 @@
|
||||
// expect error line 2
|
||||
"\u00"
|
||||
@@ -1,2 +0,0 @@
|
||||
// expect error line 2
|
||||
"\u004
|
||||
@@ -1,24 +0,0 @@
|
||||
IO.print("abcd".indexOf("")) // expect: 0
|
||||
IO.print("abcd".indexOf("cd")) // expect: 2
|
||||
IO.print("abcd".indexOf("a")) // expect: 0
|
||||
IO.print("abcd".indexOf("abcd")) // expect: 0
|
||||
IO.print("abcd".indexOf("abcde")) // expect: -1
|
||||
IO.print("abab".indexOf("ab")) // expect: 0
|
||||
|
||||
// More complex cases.
|
||||
IO.print("abcdefabcdefg".indexOf("defg")) // expect: 9
|
||||
IO.print("abcdabcdabcd".indexOf("dab")) // expect: 3
|
||||
IO.print("abcdabcdabcdabcd".indexOf("dabcdabc")) // expect: 3
|
||||
IO.print("abcdefg".indexOf("abcdef!")) // expect: -1
|
||||
|
||||
// Non-ASCII. Note that it returns byte indices, not code points.
|
||||
IO.print("søméஃthîng".indexOf("e")) // expect: -1
|
||||
IO.print("søméஃthîng".indexOf("m")) // expect: 3
|
||||
IO.print("søméஃthîng".indexOf("thî")) // expect: 9
|
||||
|
||||
// 8-bit clean.
|
||||
IO.print("a\0b\0c".indexOf("\0")) // expect: 1
|
||||
IO.print("a\0b\0c".indexOf("a")) // expect: 0
|
||||
IO.print("a\0b\0c".indexOf("b\0c")) // expect: 2
|
||||
IO.print("a\0b\0c".indexOf("a\0b\0c\0d")) // expect: -1
|
||||
IO.print("a\0b\0a\0b".indexOf("a\0b")) // expect: 0
|
||||
@@ -1 +0,0 @@
|
||||
IO.print("abcd".indexOf(null)) // expect runtime error: Argument must be a string.
|
||||
@@ -1,2 +0,0 @@
|
||||
// expect error line 2
|
||||
"not a \m real escape"
|
||||
@@ -1,2 +0,0 @@
|
||||
// expect error line 2
|
||||
"\u00no"
|
||||
@@ -1,24 +0,0 @@
|
||||
var s = "abçd"
|
||||
IO.print(s.iterate(null)) // expect: 0
|
||||
IO.print(s.iterate(0)) // expect: 1
|
||||
IO.print(s.iterate(1)) // expect: 2
|
||||
// Skip 3 because that's the middle of the ç sequence.
|
||||
IO.print(s.iterate(2)) // expect: 4
|
||||
// Iterating from the middle of a UTF-8 sequence goes to the next one.
|
||||
IO.print(s.iterate(3)) // expect: 4
|
||||
IO.print(s.iterate(4)) // expect: false
|
||||
|
||||
// Out of bounds.
|
||||
IO.print(s.iterate(123)) // expect: false
|
||||
IO.print(s.iterate(-1)) // expect: false
|
||||
|
||||
// Nothing to iterate in an empty string.
|
||||
IO.print("".iterate(null)) // expect: false
|
||||
|
||||
// 8-bit clean.
|
||||
IO.print("a\0b\0c".iterate(null)) // expect: 0
|
||||
IO.print("a\0b\0c".iterate(0)) // expect: 1
|
||||
IO.print("a\0b\0c".iterate(1)) // expect: 2
|
||||
IO.print("a\0b\0c".iterate(2)) // expect: 3
|
||||
IO.print("a\0b\0c".iterate(3)) // expect: 4
|
||||
IO.print("a\0b\0c".iterate(4)) // expect: false
|
||||
@@ -1 +0,0 @@
|
||||
"s".iterate(1.5) // expect runtime error: Iterator must be an integer.
|
||||
@@ -1 +0,0 @@
|
||||
"s".iterate("2") // expect runtime error: Iterator must be a number.
|
||||
@@ -1,15 +0,0 @@
|
||||
var s = "abçd"
|
||||
IO.print(s.iteratorValue(0)) // expect: a
|
||||
IO.print(s.iteratorValue(1)) // expect: b
|
||||
IO.print(s.iteratorValue(2)) // expect: ç
|
||||
// Iterator value in middle of UTF sequence is an empty string.
|
||||
IO.print(s.iteratorValue(3) == "") // expect: true
|
||||
IO.print(s.iteratorValue(4)) // expect: d
|
||||
|
||||
// 8-bit clean.
|
||||
var t = "a\0b\0c"
|
||||
IO.print(t.iteratorValue(0) == "a") // expect: true
|
||||
IO.print(t.iteratorValue(1) == "\0") // expect: true
|
||||
IO.print(t.iteratorValue(2) == "b") // expect: true
|
||||
IO.print(t.iteratorValue(3) == "\0") // expect: true
|
||||
IO.print(t.iteratorValue(4) == "c") // expect: true
|
||||
@@ -1 +0,0 @@
|
||||
"s".iteratorValue(1.5) // expect runtime error: Iterator must be an integer.
|
||||
@@ -1 +0,0 @@
|
||||
"s".iteratorValue("2") // expect runtime error: Iterator must be a number.
|
||||
@@ -1 +0,0 @@
|
||||
"123".iteratorValue(4) // expect runtime error: Iterator out of bounds.
|
||||
@@ -1 +0,0 @@
|
||||
"123".iteratorValue(-5) // expect runtime error: Iterator out of bounds.
|
||||
@@ -1,10 +0,0 @@
|
||||
var str = "string"
|
||||
|
||||
IO.print(str.join("") == str) // expect: true
|
||||
|
||||
IO.print(str.join(", ")) // expect: s, t, r, i, n, g
|
||||
|
||||
// 8-bit clean.
|
||||
var ing = "a\0b\0c"
|
||||
IO.print(ing.join("") == ing) // expect: true
|
||||
IO.print(ing.join(", ") == "a, \0, b, \0, c") // expect: true
|
||||
@@ -1 +0,0 @@
|
||||
"string".join(2) // // expect runtime error: Right operand must be a string.
|
||||
@@ -1,5 +0,0 @@
|
||||
IO.print("".count) // expect: 0
|
||||
IO.print("a string") // expect: a string
|
||||
|
||||
// Non-ASCII.
|
||||
IO.print("A~¶Þॐஃ") // expect: A~¶Þॐஃ
|
||||
@@ -1,2 +0,0 @@
|
||||
IO.print(!"s") // expect: false
|
||||
IO.print(!"") // expect: false
|
||||
@@ -1,14 +0,0 @@
|
||||
IO.print("abcd".startsWith("cd")) // expect: false
|
||||
IO.print("abcd".startsWith("a")) // expect: true
|
||||
IO.print("abcd".startsWith("abcd")) // expect: true
|
||||
IO.print("abcd".startsWith("abcde")) // expect: false
|
||||
IO.print("abcd".startsWith("")) // expect: true
|
||||
|
||||
// Non-ASCII.
|
||||
IO.print("søméthîng".startsWith("sømé")) // expect: true
|
||||
IO.print("søméthîng".startsWith("some")) // expect: false
|
||||
|
||||
// 8-bit clean.
|
||||
IO.print("a\0b\0c".startsWith("a")) // expect: true
|
||||
IO.print("a\0b\0c".startsWith("a\0")) // expect: true
|
||||
IO.print("a\0b\0c".startsWith("b\0")) // expect: false
|
||||
@@ -1 +0,0 @@
|
||||
IO.print("abcd".startsWith(null)) // expect runtime error: Argument must be a string.
|
||||
@@ -1,42 +0,0 @@
|
||||
// Returns characters (as strings).
|
||||
IO.print("abcd"[0]) // expect: a
|
||||
IO.print("abcd"[1]) // expect: b
|
||||
IO.print("abcd"[2]) // expect: c
|
||||
IO.print("abcd"[3]) // expect: d
|
||||
|
||||
// Allows indexing backwards from the end.
|
||||
IO.print("abcd"[-4]) // expect: a
|
||||
IO.print("abcd"[-3]) // expect: b
|
||||
IO.print("abcd"[-2]) // expect: c
|
||||
IO.print("abcd"[-1]) // expect: d
|
||||
|
||||
// Regression: Make sure the string's internal buffer size is correct.
|
||||
IO.print("abcd"[1] == "b") // expect: true
|
||||
|
||||
// Indexes by byte, not code point.
|
||||
//
|
||||
// Bytes: 11111
|
||||
// 012345678901234
|
||||
// Chars: sø mé ஃ thî ng
|
||||
IO.print("søméஃthîng"[0]) // expect: s
|
||||
IO.print("søméஃthîng"[1]) // expect: ø
|
||||
IO.print("søméஃthîng"[3]) // expect: m
|
||||
IO.print("søméஃthîng"[6]) // expect: ஃ
|
||||
IO.print("søméஃthîng"[10]) // expect: h
|
||||
IO.print("søméஃthîng"[-1]) // expect: g
|
||||
IO.print("søméஃthîng"[-2]) // expect: n
|
||||
IO.print("søméஃthîng"[-4]) // expect: î
|
||||
|
||||
// If the subscript is in the middle of a UTF-8 sequence, yield an empty string.
|
||||
IO.print("søméஃthîng"[2] == "") // expect: true
|
||||
IO.print("søméஃthîng"[7] == "") // expect: true
|
||||
IO.print("søméஃthîng"[8] == "") // expect: true
|
||||
IO.print("søméஃ"[-1] == "") // expect: true
|
||||
IO.print("søméஃ"[-2] == "") // expect: true
|
||||
|
||||
// 8-bit clean.
|
||||
IO.print("a\0b\0c"[0] == "a") // expect: true
|
||||
IO.print("a\0b\0c"[1] == "\0") // expect: true
|
||||
IO.print("a\0b\0c"[2] == "b") // expect: true
|
||||
IO.print("a\0b\0c"[3] == "\0") // expect: true
|
||||
IO.print("a\0b\0c"[4] == "c") // expect: true
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "123"
|
||||
a[1.5] // expect runtime error: Subscript must be an integer.
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "123"
|
||||
a["2"] // expect runtime error: Subscript must be a number or a range.
|
||||
@@ -1,34 +0,0 @@
|
||||
var string = "abcde"
|
||||
IO.print(string[0..0]) // expect: a
|
||||
IO.print(string[1...1] == "") // expect: true
|
||||
IO.print(string[1..2]) // expect: bc
|
||||
IO.print(string[1...2]) // expect: b
|
||||
IO.print(string[2..4]) // expect: cde
|
||||
IO.print(string[2...5]) // expect: cde
|
||||
|
||||
// A backwards range reverses.
|
||||
IO.print(string[3..1]) // expect: dcb
|
||||
IO.print(string[3...1]) // expect: dc
|
||||
IO.print(string[3...3] == "") // expect: true
|
||||
|
||||
// Negative ranges index from the end.
|
||||
IO.print(string[-5..-2]) // expect: abcd
|
||||
IO.print(string[-5...-2]) // expect: abc
|
||||
IO.print(string[-3..-5]) // expect: cba
|
||||
IO.print(string[-3...-6]) // expect: cba
|
||||
|
||||
// Half-negative ranges are treated like the negative value is fixed before
|
||||
// walking the range.
|
||||
IO.print(string[-5..3]) // expect: abcd
|
||||
IO.print(string[-3...5]) // expect: cde
|
||||
IO.print(string[-2..1]) // expect: dcb
|
||||
IO.print(string[-2...0]) // expect: dcb
|
||||
|
||||
IO.print(string[1..-2]) // expect: bcd
|
||||
IO.print(string[2...-1]) // expect: cd
|
||||
IO.print(string[4..-5]) // expect: edcba
|
||||
IO.print(string[3...-6]) // expect: dcba
|
||||
|
||||
// An empty range at zero is allowed on an empty string.
|
||||
IO.print(""[0...0] == "") // expect: true
|
||||
IO.print(""[0..-1] == "") // expect: true
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "string"
|
||||
a[1.5..2] // expect runtime error: Range start must be an integer.
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "123"
|
||||
a[3..2] // expect runtime error: Range start out of bounds.
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "123"
|
||||
a[-4..2] // expect runtime error: Range start out of bounds.
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "123"
|
||||
a[1...4] // expect runtime error: Range end out of bounds.
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "123"
|
||||
a[0...-5] // expect runtime error: Range end out of bounds.
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "string"
|
||||
a[1..2.5] // expect runtime error: Range end must be an integer.
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "123"
|
||||
a[1..3] // expect runtime error: Range end out of bounds.
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "123"
|
||||
a[0..-4] // expect runtime error: Range end out of bounds.
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "123"
|
||||
a[4] // expect runtime error: Subscript out of bounds.
|
||||
@@ -1,2 +0,0 @@
|
||||
var a = "123"
|
||||
a[-5] // expect runtime error: Subscript out of bounds.
|
||||
@@ -1,7 +0,0 @@
|
||||
IO.print("".toString == "") // expect: true
|
||||
IO.print("blah".toString == "blah") // expect: true
|
||||
|
||||
// 8-bit clean.
|
||||
IO.print("a\0b\0c".toString == "a\0b\0c") // expect: true
|
||||
IO.print("a\0b\0c".toString == "a") // expect: false
|
||||
IO.print("a\0b\0c".toString) // expect: a
|
||||
@@ -1,4 +0,0 @@
|
||||
IO.print("s" is String) // expect: true
|
||||
IO.print("s" is Object) // expect: true
|
||||
IO.print("s" is Num) // expect: false
|
||||
IO.print("s".type == String) // expect: true
|
||||
@@ -1,17 +0,0 @@
|
||||
// One byte UTF-8 Sequences.
|
||||
IO.print("\u0041") // expect: A
|
||||
IO.print("\u007e") // expect: ~
|
||||
|
||||
// Two byte sequences.
|
||||
IO.print("\u00b6") // expect: ¶
|
||||
IO.print("\u00de") // expect: Þ
|
||||
|
||||
// Three byte sequences.
|
||||
IO.print("\u0950") // expect: ॐ
|
||||
IO.print("\u0b83") // expect: ஃ
|
||||
|
||||
// Capitalized hex.
|
||||
IO.print("\u00B6") // expect: ¶
|
||||
IO.print("\u00DE") // expect: Þ
|
||||
|
||||
// TODO: Syntax for Unicode escapes > 0xffff?
|
||||
@@ -1,2 +0,0 @@
|
||||
// expect error line 2
|
||||
"this string has no close quote
|
||||
Reference in New Issue
Block a user