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,6 @@
|
||||
IO.print(123.abs) // expect: 123
|
||||
IO.print((-123).abs) // expect: 123
|
||||
IO.print(0.abs) // expect: 0
|
||||
IO.print((-0).abs) // expect: 0
|
||||
IO.print((-0.12).abs) // expect: 0.12
|
||||
IO.print(12.34.abs) // expect: 12.34
|
||||
@@ -0,0 +1,12 @@
|
||||
IO.print(0 & 0) // expect: 0
|
||||
IO.print(2863311530 & 1431655765) // expect: 0
|
||||
IO.print(4042322160 & 1010580540) // expect: 808464432
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 & 4294967295) // expect: 4294967295
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 & 4294967296) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
@@ -0,0 +1 @@
|
||||
1 & false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,15 @@
|
||||
IO.print(0 << 0) // expect: 0
|
||||
IO.print(1 << 0) // expect: 1
|
||||
IO.print(0 << 1) // expect: 0
|
||||
IO.print(1 << 1) // expect: 2
|
||||
IO.print(2863311530 << 1) // expect: 1431655764
|
||||
IO.print(4042322160 << 1) // expect: 3789677024
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 << 1) // expect: 4294967294
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 << 1) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
@@ -0,0 +1 @@
|
||||
1 << false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,22 @@
|
||||
IO.print(~0) // expect: 4294967295
|
||||
IO.print(~1) // expect: 4294967294
|
||||
IO.print(~23) // expect: 4294967272
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(~4294967295) // expect: 0
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(~4294967296) // expect: 4294967295
|
||||
|
||||
// Negative numbers.
|
||||
IO.print(~-1) // expect: 0
|
||||
IO.print(~-123) // expect: 122
|
||||
IO.print(~-4294967294) // expect: 4294967293
|
||||
IO.print(~-4294967295) // expect: 4294967294
|
||||
IO.print(~-4294967296) // expect: 4294967295
|
||||
|
||||
// Floating point values.
|
||||
IO.print(~1.23) // expect: 4294967294
|
||||
IO.print(~0.00123) // expect: 4294967295
|
||||
IO.print(~345.67) // expect: 4294966950
|
||||
IO.print(~-12.34) // expect: 11
|
||||
@@ -0,0 +1,12 @@
|
||||
IO.print(0 | 0) // expect: 0
|
||||
IO.print(2863311530 | 1431655765) // expect: 4294967295
|
||||
IO.print(3435973836 | 1717986918) // expect: 4008636142
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 | 4294967295) // expect: 4294967295
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 | 4294967296) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
@@ -0,0 +1 @@
|
||||
1 | false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,15 @@
|
||||
IO.print(0 >> 0) // expect: 0
|
||||
IO.print(1 >> 0) // expect: 1
|
||||
IO.print(0 >> 1) // expect: 0
|
||||
IO.print(1 >> 1) // expect: 0
|
||||
IO.print(2863311530 >> 1) // expect: 1431655765
|
||||
IO.print(4042322160 >> 1) // expect: 2021161080
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 >> 1) // expect: 2147483647
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 >> 1) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
@@ -0,0 +1 @@
|
||||
1 >> false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,15 @@
|
||||
IO.print(0 ^ 0) // expect: 0
|
||||
IO.print(1 ^ 1) // expect: 0
|
||||
IO.print(0 ^ 1) // expect: 1
|
||||
IO.print(1 ^ 0) // expect: 1
|
||||
IO.print(2863311530 ^ 1431655765) // expect: 4294967295
|
||||
IO.print(4042322160 ^ 1010580540) // expect: 3435973836
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 ^ 4294967295) // expect: 0
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 ^ 4294967296) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
@@ -0,0 +1 @@
|
||||
1 ^ false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,8 @@
|
||||
IO.print(123.ceil) // expect: 123
|
||||
IO.print((-123).ceil) // expect: -123
|
||||
IO.print(0.ceil) // expect: 0
|
||||
IO.print((-0).ceil) // expect: -0
|
||||
IO.print(0.123.ceil) // expect: 1
|
||||
IO.print(12.3.ceil) // expect: 13
|
||||
IO.print((-0.123).ceil) // expect: -0
|
||||
IO.print((-12.3).ceil) // expect: -12
|
||||
@@ -0,0 +1,27 @@
|
||||
IO.print(1 < 2) // expect: true
|
||||
IO.print(2 < 2) // expect: false
|
||||
IO.print(2 < 1) // expect: false
|
||||
|
||||
IO.print(1 <= 2) // expect: true
|
||||
IO.print(2 <= 2) // expect: true
|
||||
IO.print(2 <= 1) // expect: false
|
||||
|
||||
IO.print(1 > 2) // expect: false
|
||||
IO.print(2 > 2) // expect: false
|
||||
IO.print(2 > 1) // expect: true
|
||||
|
||||
IO.print(1 >= 2) // expect: false
|
||||
IO.print(2 >= 2) // expect: true
|
||||
IO.print(2 >= 1) // expect: true
|
||||
|
||||
// Zero and negative zero compare the same.
|
||||
IO.print(0 < -0) // expect: false
|
||||
IO.print(-0 < 0) // expect: false
|
||||
IO.print(0 > -0) // expect: false
|
||||
IO.print(-0 > 0) // expect: false
|
||||
IO.print(0 <= -0) // expect: true
|
||||
IO.print(-0 <= 0) // expect: true
|
||||
IO.print(0 >= -0) // expect: true
|
||||
IO.print(-0 >= 0) // expect: true
|
||||
|
||||
// TODO: Wrong type for RHS.
|
||||
@@ -0,0 +1,2 @@
|
||||
// expect error line 2
|
||||
123.
|
||||
@@ -0,0 +1,12 @@
|
||||
IO.print(8 / 2) // expect: 4
|
||||
IO.print(12.34 / -0.4) // expect: -30.85
|
||||
|
||||
// Divide by zero.
|
||||
IO.print(3 / 0) // expect: infinity
|
||||
IO.print(-3 / 0) // expect: -infinity
|
||||
IO.print(0 / 0) // expect: nan
|
||||
IO.print(-0 / 0) // expect: nan
|
||||
IO.print(3 / -0) // expect: -infinity
|
||||
IO.print(-3 / -0) // expect: infinity
|
||||
IO.print(0 / -0) // expect: nan
|
||||
IO.print(-0 / -0) // expect: nan
|
||||
@@ -0,0 +1 @@
|
||||
1 / false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,19 @@
|
||||
IO.print(123 == 123) // expect: true
|
||||
IO.print(123 == 124) // expect: false
|
||||
IO.print(-3 == 3) // expect: false
|
||||
IO.print(0 == -0) // expect: true
|
||||
|
||||
// Not equal to other types.
|
||||
IO.print(123 == "123") // expect: false
|
||||
IO.print(1 == true) // expect: false
|
||||
IO.print(0 == false) // expect: false
|
||||
|
||||
IO.print(123 != 123) // expect: false
|
||||
IO.print(123 != 124) // expect: true
|
||||
IO.print(-3 != 3) // expect: true
|
||||
IO.print(0 != -0) // expect: false
|
||||
|
||||
// Not equal to other types.
|
||||
IO.print(123 != "123") // expect: true
|
||||
IO.print(1 != true) // expect: true
|
||||
IO.print(0 != false) // expect: true
|
||||
@@ -0,0 +1,8 @@
|
||||
IO.print(123.floor) // expect: 123
|
||||
IO.print((-123).floor) // expect: -123
|
||||
IO.print(0.floor) // expect: 0
|
||||
IO.print((-0).floor) // expect: -0
|
||||
IO.print(0.123.floor) // expect: 0
|
||||
IO.print(12.3.floor) // expect: 12
|
||||
IO.print((-0.123).floor) // expect: -1
|
||||
IO.print((-12.3).floor) // expect: -13
|
||||
@@ -0,0 +1,19 @@
|
||||
IO.print(123.fraction) // expect: 0
|
||||
IO.print((-123).fraction) // expect: -0
|
||||
IO.print(0.fraction) // expect: 0
|
||||
IO.print((-0).fraction) // expect: -0
|
||||
IO.print(0.123.fraction) // expect: 0.123
|
||||
IO.print(12.3.fraction) // expect: 0.3
|
||||
IO.print((-0.123).fraction) // expect: -0.123
|
||||
IO.print((-12.3).fraction) // expect: -0.3
|
||||
|
||||
// Using 32-bit representation, a longer mantissa will lead to
|
||||
// approximation.
|
||||
IO.print((1.23456789012345).fraction) // expect: 0.23456789012345
|
||||
IO.print((-1.23456789012345).fraction) // expect: -0.23456789012345
|
||||
|
||||
IO.print((0.000000000000000000000000000000000000000001).fraction) // expect: 1e-42
|
||||
IO.print((-0.000000000000000000000000000000000000000001).fraction) // expect: -1e-42
|
||||
|
||||
IO.print((1.000000000000000000000000000000000000000001).fraction) // expect: 0
|
||||
IO.print((-1.000000000000000000000000000000000000000001).fraction) // expect: -0
|
||||
@@ -0,0 +1,14 @@
|
||||
IO.print(Num.fromString("123") == 123) // expect: true
|
||||
IO.print(Num.fromString("-123") == -123) // expect: true
|
||||
IO.print(Num.fromString("-0") == -0) // expect: true
|
||||
IO.print(Num.fromString("12.34") == 12.34) // expect: true
|
||||
IO.print(Num.fromString("-0.0001") == -0.0001) // expect: true
|
||||
IO.print(Num.fromString(" 12 ") == 12) // expect: true
|
||||
|
||||
// Test some non-number literals and ensure they return null.
|
||||
IO.print(Num.fromString("test1") == null) // expect: true
|
||||
IO.print(Num.fromString("") == null) // expect: true
|
||||
IO.print(Num.fromString("prefix1.2") == null) // expect: true
|
||||
IO.print(Num.fromString("1.2suffix") == null) // expect: true
|
||||
|
||||
// TODO: Parse hex and scientific numbers.
|
||||
@@ -0,0 +1 @@
|
||||
Num.fromString(1) // expect runtime error: Argument must be a string.
|
||||
@@ -0,0 +1,2 @@
|
||||
var x = "999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
|
||||
var y = Num.fromString(x) // expect runtime error: Number literal is too large.
|
||||
@@ -0,0 +1 @@
|
||||
1 >= false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1 @@
|
||||
1 > false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1 @@
|
||||
var x = 2xFF // expect error: Error at 'xFF': Expect end of file.
|
||||
@@ -0,0 +1,5 @@
|
||||
IO.print(1.isNan) // expect: false
|
||||
IO.print((0/0).isNan) // expect: true
|
||||
|
||||
// Infinity is not NaN.
|
||||
IO.print((1/0).isNan) // expect: false
|
||||
@@ -0,0 +1 @@
|
||||
1 <= false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1 @@
|
||||
1 < false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,8 @@
|
||||
// Infix.
|
||||
IO.print(5 - 3) // expect: 2
|
||||
IO.print(3.1 - 0.24) // expect: 2.86
|
||||
IO.print(3 - 2 - 1) // expect: 0
|
||||
|
||||
// Unary negation.
|
||||
var a = 3
|
||||
IO.print(-a) // expect: -3
|
||||
@@ -0,0 +1 @@
|
||||
1 - false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,17 @@
|
||||
IO.print(5 % 3) // expect: 2
|
||||
IO.print(10 % 5) // expect: 0
|
||||
IO.print(-4 % 3) // expect: -1
|
||||
IO.print(4 % -3) // expect: 1
|
||||
IO.print(-4 % -3) // expect: -1
|
||||
IO.print(-4.2 % 3.1) // expect: -1.1
|
||||
IO.print(4.2 % -3.1) // expect: 1.1
|
||||
IO.print(-4.2 % -3.1) // expect: -1.1
|
||||
|
||||
// Left associative.
|
||||
IO.print(13 % 7 % 4) // expect: 2
|
||||
|
||||
// Precedence.
|
||||
IO.print(13 + 1 % 7) // expect: 14
|
||||
|
||||
// TODO: Unsupported RHS types.
|
||||
// TODO: Error on mod by zero.
|
||||
@@ -0,0 +1 @@
|
||||
1 % false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,2 @@
|
||||
IO.print(5 * 3) // expect: 15
|
||||
IO.print(12.34 * 0.3) // expect: 3.702
|
||||
@@ -0,0 +1 @@
|
||||
1 * false // expect runtime error: Right operand must be a number.
|
||||
@@ -0,0 +1,2 @@
|
||||
IO.print(!123) // expect: false
|
||||
IO.print(!0) // expect: false
|
||||
@@ -0,0 +1,3 @@
|
||||
IO.print(1 + 2) // expect: 3
|
||||
IO.print(12.34 + 0.13) // expect: 12.47
|
||||
IO.print(3 + 5 + 2) // expect: 10
|
||||
@@ -0,0 +1,3 @@
|
||||
1 + false // expect runtime error: Right operand must be a number.
|
||||
|
||||
// TODO: What about a string on the RHS?
|
||||
@@ -0,0 +1,6 @@
|
||||
IO.print(123.sign) // expect: 1
|
||||
IO.print((-123).sign) // expect: -1
|
||||
IO.print(0.sign) // expect: 0
|
||||
IO.print((-0).sign) // expect: 0
|
||||
IO.print(0.123.sign) // expect: 1
|
||||
IO.print((-0.123).sign) // expect: -1
|
||||
@@ -0,0 +1,10 @@
|
||||
IO.print(4.sqrt) // expect: 2
|
||||
IO.print(1000000.sqrt) // expect: 1000
|
||||
IO.print(1.sqrt) // expect: 1
|
||||
IO.print((-0).sqrt) // expect: -0
|
||||
IO.print(0.sqrt) // expect: 0
|
||||
IO.print(2.sqrt) // expect: 1.4142135623731
|
||||
|
||||
IO.print((-4).sqrt.isNan) // expect: true
|
||||
|
||||
// TODO: Tests for sin and cos.
|
||||
@@ -0,0 +1,5 @@
|
||||
IO.print(123.toString == "123") // expect: true
|
||||
IO.print((-123).toString == "-123") // expect: true
|
||||
IO.print((-0).toString == "-0") // expect: true
|
||||
IO.print(12.34.toString == "12.34") // expect: true
|
||||
IO.print((-0.0001).toString == "-0.0001") // expect: true
|
||||
@@ -0,0 +1,13 @@
|
||||
IO.print(123.truncate) // expect: 123
|
||||
IO.print((-123).truncate) // expect: -123
|
||||
IO.print(0.truncate) // expect: 0
|
||||
IO.print((-0).truncate) // expect: -0
|
||||
IO.print(0.123.truncate) // expect: 0
|
||||
IO.print(12.3.truncate) // expect: 12
|
||||
IO.print((-0.123).truncate) // expect: -0
|
||||
IO.print((-12.3).truncate) // expect: -12
|
||||
|
||||
// Using 32-bit representation, values "beyond" those two will lead to
|
||||
// approximation.
|
||||
IO.print((12345678901234.5).truncate) // expect: 12345678901234
|
||||
IO.print((-12345678901234.5).truncate) // expect: -12345678901234
|
||||
@@ -0,0 +1,4 @@
|
||||
IO.print(123 is Num) // expect: true
|
||||
IO.print(123 is Object) // expect: true
|
||||
IO.print(123 is String) // expect: false
|
||||
IO.print(123.type == Num) // expect: true
|
||||
Reference in New Issue
Block a user