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,6 +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
|
||||
System.print(123.abs) // expect: 123
|
||||
System.print((-123).abs) // expect: 123
|
||||
System.print(0.abs) // expect: 0
|
||||
System.print((-0).abs) // expect: 0
|
||||
System.print((-0.12).abs) // expect: 0.12
|
||||
System.print(12.34.abs) // expect: 12.34
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
IO.print(0.acos) // expect: 1.5707963267949
|
||||
IO.print(1.acos) // expect: 0
|
||||
IO.print((-1).acos) // expect: 3.1415926535898
|
||||
System.print(0.acos) // expect: 1.5707963267949
|
||||
System.print(1.acos) // expect: 0
|
||||
System.print((-1).acos) // expect: 3.1415926535898
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
IO.print(0.asin) // expect: 0
|
||||
IO.print(1.asin) // expect: 1.5707963267949
|
||||
IO.print((-1).asin) // expect: -1.5707963267949
|
||||
System.print(0.asin) // expect: 0
|
||||
System.print(1.asin) // expect: 1.5707963267949
|
||||
System.print((-1).asin) // expect: -1.5707963267949
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
IO.print(0.atan) // expect: 0
|
||||
IO.print(1.atan) // expect: 0.78539816339745
|
||||
System.print(0.atan) // expect: 0
|
||||
System.print(1.atan) // expect: 0.78539816339745
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
IO.print(0.atan(0)) // expect: 0
|
||||
IO.print(0.atan(1)) // expect: 0
|
||||
System.print(0.atan(0)) // expect: 0
|
||||
System.print(0.atan(1)) // expect: 0
|
||||
|
||||
IO.print(1.atan(0)) // expect: 1.5707963267949
|
||||
System.print(1.atan(0)) // expect: 1.5707963267949
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
IO.print(0 & 0) // expect: 0
|
||||
IO.print(2863311530 & 1431655765) // expect: 0
|
||||
IO.print(4042322160 & 1010580540) // expect: 808464432
|
||||
System.print(0 & 0) // expect: 0
|
||||
System.print(2863311530 & 1431655765) // expect: 0
|
||||
System.print(4042322160 & 1010580540) // expect: 808464432
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 & 4294967295) // expect: 4294967295
|
||||
System.print(4294967295 & 4294967295) // expect: 4294967295
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 & 4294967296) // expect: 0
|
||||
System.print(4294967296 & 4294967296) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
|
||||
@@ -1,15 +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
|
||||
System.print(0 << 0) // expect: 0
|
||||
System.print(1 << 0) // expect: 1
|
||||
System.print(0 << 1) // expect: 0
|
||||
System.print(1 << 1) // expect: 2
|
||||
System.print(2863311530 << 1) // expect: 1431655764
|
||||
System.print(4042322160 << 1) // expect: 3789677024
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 << 1) // expect: 4294967294
|
||||
System.print(4294967295 << 1) // expect: 4294967294
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 << 1) // expect: 0
|
||||
System.print(4294967296 << 1) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
IO.print(~0) // expect: 4294967295
|
||||
IO.print(~1) // expect: 4294967294
|
||||
IO.print(~23) // expect: 4294967272
|
||||
System.print(~0) // expect: 4294967295
|
||||
System.print(~1) // expect: 4294967294
|
||||
System.print(~23) // expect: 4294967272
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(~4294967295) // expect: 0
|
||||
System.print(~4294967295) // expect: 0
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(~4294967296) // expect: 4294967295
|
||||
System.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
|
||||
System.print(~-1) // expect: 0
|
||||
System.print(~-123) // expect: 122
|
||||
System.print(~-4294967294) // expect: 4294967293
|
||||
System.print(~-4294967295) // expect: 4294967294
|
||||
System.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
|
||||
System.print(~1.23) // expect: 4294967294
|
||||
System.print(~0.00123) // expect: 4294967295
|
||||
System.print(~345.67) // expect: 4294966950
|
||||
System.print(~-12.34) // expect: 11
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
IO.print(0 | 0) // expect: 0
|
||||
IO.print(2863311530 | 1431655765) // expect: 4294967295
|
||||
IO.print(3435973836 | 1717986918) // expect: 4008636142
|
||||
System.print(0 | 0) // expect: 0
|
||||
System.print(2863311530 | 1431655765) // expect: 4294967295
|
||||
System.print(3435973836 | 1717986918) // expect: 4008636142
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 | 4294967295) // expect: 4294967295
|
||||
System.print(4294967295 | 4294967295) // expect: 4294967295
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 | 4294967296) // expect: 0
|
||||
System.print(4294967296 | 4294967296) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
|
||||
@@ -1,15 +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
|
||||
System.print(0 >> 0) // expect: 0
|
||||
System.print(1 >> 0) // expect: 1
|
||||
System.print(0 >> 1) // expect: 0
|
||||
System.print(1 >> 1) // expect: 0
|
||||
System.print(2863311530 >> 1) // expect: 1431655765
|
||||
System.print(4042322160 >> 1) // expect: 2021161080
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 >> 1) // expect: 2147483647
|
||||
System.print(4294967295 >> 1) // expect: 2147483647
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 >> 1) // expect: 0
|
||||
System.print(4294967296 >> 1) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
|
||||
@@ -1,15 +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
|
||||
System.print(0 ^ 0) // expect: 0
|
||||
System.print(1 ^ 1) // expect: 0
|
||||
System.print(0 ^ 1) // expect: 1
|
||||
System.print(1 ^ 0) // expect: 1
|
||||
System.print(2863311530 ^ 1431655765) // expect: 4294967295
|
||||
System.print(4042322160 ^ 1010580540) // expect: 3435973836
|
||||
|
||||
// Max u32 value.
|
||||
IO.print(4294967295 ^ 4294967295) // expect: 0
|
||||
System.print(4294967295 ^ 4294967295) // expect: 0
|
||||
|
||||
// Past max u32 value.
|
||||
IO.print(4294967296 ^ 4294967296) // expect: 0
|
||||
System.print(4294967296 ^ 4294967296) // expect: 0
|
||||
|
||||
// TODO: Negative numbers.
|
||||
// TODO: Floating-point numbers.
|
||||
|
||||
@@ -1,8 +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
|
||||
System.print(123.ceil) // expect: 123
|
||||
System.print((-123).ceil) // expect: -123
|
||||
System.print(0.ceil) // expect: 0
|
||||
System.print((-0).ceil) // expect: -0
|
||||
System.print(0.123.ceil) // expect: 1
|
||||
System.print(12.3.ceil) // expect: 13
|
||||
System.print((-0.123).ceil) // expect: -0
|
||||
System.print((-12.3).ceil) // expect: -12
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
IO.print(1 < 2) // expect: true
|
||||
IO.print(2 < 2) // expect: false
|
||||
IO.print(2 < 1) // expect: false
|
||||
System.print(1 < 2) // expect: true
|
||||
System.print(2 < 2) // expect: false
|
||||
System.print(2 < 1) // expect: false
|
||||
|
||||
IO.print(1 <= 2) // expect: true
|
||||
IO.print(2 <= 2) // expect: true
|
||||
IO.print(2 <= 1) // expect: false
|
||||
System.print(1 <= 2) // expect: true
|
||||
System.print(2 <= 2) // expect: true
|
||||
System.print(2 <= 1) // expect: false
|
||||
|
||||
IO.print(1 > 2) // expect: false
|
||||
IO.print(2 > 2) // expect: false
|
||||
IO.print(2 > 1) // expect: true
|
||||
System.print(1 > 2) // expect: false
|
||||
System.print(2 > 2) // expect: false
|
||||
System.print(2 > 1) // expect: true
|
||||
|
||||
IO.print(1 >= 2) // expect: false
|
||||
IO.print(2 >= 2) // expect: true
|
||||
IO.print(2 >= 1) // expect: true
|
||||
System.print(1 >= 2) // expect: false
|
||||
System.print(2 >= 2) // expect: true
|
||||
System.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
|
||||
System.print(0 < -0) // expect: false
|
||||
System.print(-0 < 0) // expect: false
|
||||
System.print(0 > -0) // expect: false
|
||||
System.print(-0 > 0) // expect: false
|
||||
System.print(0 <= -0) // expect: true
|
||||
System.print(-0 <= 0) // expect: true
|
||||
System.print(0 >= -0) // expect: true
|
||||
System.print(-0 >= 0) // expect: true
|
||||
|
||||
// TODO: Wrong type for RHS.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
IO.print(0.cos) // expect: 1
|
||||
IO.print(Num.pi.cos) // expect: -1
|
||||
IO.print((2 * Num.pi).cos) // expect: 1
|
||||
System.print(0.cos) // expect: 1
|
||||
System.print(Num.pi.cos) // expect: -1
|
||||
System.print((2 * Num.pi).cos) // expect: 1
|
||||
|
||||
// this should of course be 0, but it's not that precise
|
||||
IO.print((Num.pi / 2).cos) // expect: 6.1232339957368e-17
|
||||
System.print((Num.pi / 2).cos) // expect: 6.1232339957368e-17
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
IO.print(8 / 2) // expect: 4
|
||||
IO.print(12.34 / -0.4) // expect: -30.85
|
||||
System.print(8 / 2) // expect: 4
|
||||
System.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
|
||||
System.print(3 / 0) // expect: infinity
|
||||
System.print(-3 / 0) // expect: -infinity
|
||||
System.print(0 / 0) // expect: nan
|
||||
System.print(-0 / 0) // expect: nan
|
||||
System.print(3 / -0) // expect: -infinity
|
||||
System.print(-3 / -0) // expect: infinity
|
||||
System.print(0 / -0) // expect: nan
|
||||
System.print(-0 / -0) // expect: nan
|
||||
|
||||
@@ -1,19 +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
|
||||
System.print(123 == 123) // expect: true
|
||||
System.print(123 == 124) // expect: false
|
||||
System.print(-3 == 3) // expect: false
|
||||
System.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
|
||||
System.print(123 == "123") // expect: false
|
||||
System.print(1 == true) // expect: false
|
||||
System.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
|
||||
System.print(123 != 123) // expect: false
|
||||
System.print(123 != 124) // expect: true
|
||||
System.print(-3 != 3) // expect: true
|
||||
System.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
|
||||
System.print(123 != "123") // expect: true
|
||||
System.print(1 != true) // expect: true
|
||||
System.print(0 != false) // expect: true
|
||||
|
||||
@@ -1,8 +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
|
||||
System.print(123.floor) // expect: 123
|
||||
System.print((-123).floor) // expect: -123
|
||||
System.print(0.floor) // expect: 0
|
||||
System.print((-0).floor) // expect: -0
|
||||
System.print(0.123.floor) // expect: 0
|
||||
System.print(12.3.floor) // expect: 12
|
||||
System.print((-0.123).floor) // expect: -1
|
||||
System.print((-12.3).floor) // expect: -13
|
||||
|
||||
@@ -1,19 +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
|
||||
System.print(123.fraction) // expect: 0
|
||||
System.print((-123).fraction) // expect: -0
|
||||
System.print(0.fraction) // expect: 0
|
||||
System.print((-0).fraction) // expect: -0
|
||||
System.print(0.123.fraction) // expect: 0.123
|
||||
System.print(12.3.fraction) // expect: 0.3
|
||||
System.print((-0.123).fraction) // expect: -0.123
|
||||
System.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
|
||||
System.print((1.23456789012345).fraction) // expect: 0.23456789012345
|
||||
System.print((-1.23456789012345).fraction) // expect: -0.23456789012345
|
||||
|
||||
IO.print((0.000000000000000000000000000000000000000001).fraction) // expect: 1e-42
|
||||
IO.print((-0.000000000000000000000000000000000000000001).fraction) // expect: -1e-42
|
||||
System.print((0.000000000000000000000000000000000000000001).fraction) // expect: 1e-42
|
||||
System.print((-0.000000000000000000000000000000000000000001).fraction) // expect: -1e-42
|
||||
|
||||
IO.print((1.000000000000000000000000000000000000000001).fraction) // expect: 0
|
||||
IO.print((-1.000000000000000000000000000000000000000001).fraction) // expect: -0
|
||||
System.print((1.000000000000000000000000000000000000000001).fraction) // expect: 0
|
||||
System.print((-1.000000000000000000000000000000000000000001).fraction) // expect: -0
|
||||
|
||||
@@ -1,14 +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
|
||||
System.print(Num.fromString("123") == 123) // expect: true
|
||||
System.print(Num.fromString("-123") == -123) // expect: true
|
||||
System.print(Num.fromString("-0") == -0) // expect: true
|
||||
System.print(Num.fromString("12.34") == 12.34) // expect: true
|
||||
System.print(Num.fromString("-0.0001") == -0.0001) // expect: true
|
||||
System.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
|
||||
System.print(Num.fromString("test1") == null) // expect: true
|
||||
System.print(Num.fromString("") == null) // expect: true
|
||||
System.print(Num.fromString("prefix1.2") == null) // expect: true
|
||||
System.print(Num.fromString("1.2suffix") == null) // expect: true
|
||||
|
||||
// TODO: Parse hex and scientific numbers.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
IO.print(1.isNan) // expect: false
|
||||
IO.print((0/0).isNan) // expect: true
|
||||
System.print(1.isNan) // expect: false
|
||||
System.print((0/0).isNan) // expect: true
|
||||
|
||||
// Infinity is not NaN.
|
||||
IO.print((1/0).isNan) // expect: false
|
||||
System.print((1/0).isNan) // expect: false
|
||||
|
||||
@@ -1,8 +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
|
||||
System.print(5 - 3) // expect: 2
|
||||
System.print(3.1 - 0.24) // expect: 2.86
|
||||
System.print(3 - 2 - 1) // expect: 0
|
||||
|
||||
// Unary negation.
|
||||
var a = 3
|
||||
IO.print(-a) // expect: -3
|
||||
System.print(-a) // expect: -3
|
||||
|
||||
+10
-10
@@ -1,17 +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
|
||||
System.print(5 % 3) // expect: 2
|
||||
System.print(10 % 5) // expect: 0
|
||||
System.print(-4 % 3) // expect: -1
|
||||
System.print(4 % -3) // expect: 1
|
||||
System.print(-4 % -3) // expect: -1
|
||||
System.print(-4.2 % 3.1) // expect: -1.1
|
||||
System.print(4.2 % -3.1) // expect: 1.1
|
||||
System.print(-4.2 % -3.1) // expect: -1.1
|
||||
|
||||
// Left associative.
|
||||
IO.print(13 % 7 % 4) // expect: 2
|
||||
System.print(13 % 7 % 4) // expect: 2
|
||||
|
||||
// Precedence.
|
||||
IO.print(13 + 1 % 7) // expect: 14
|
||||
System.print(13 + 1 % 7) // expect: 14
|
||||
|
||||
// TODO: Unsupported RHS types.
|
||||
// TODO: Error on mod by zero.
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
IO.print(5 * 3) // expect: 15
|
||||
IO.print(12.34 * 0.3) // expect: 3.702
|
||||
System.print(5 * 3) // expect: 15
|
||||
System.print(12.34 * 0.3) // expect: 3.702
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
IO.print(!123) // expect: false
|
||||
IO.print(!0) // expect: false
|
||||
System.print(!123) // expect: false
|
||||
System.print(!0) // expect: false
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
IO.print(1 + 2) // expect: 3
|
||||
IO.print(12.34 + 0.13) // expect: 12.47
|
||||
IO.print(3 + 5 + 2) // expect: 10
|
||||
System.print(1 + 2) // expect: 3
|
||||
System.print(12.34 + 0.13) // expect: 12.47
|
||||
System.print(3 + 5 + 2) // expect: 10
|
||||
|
||||
@@ -1,6 +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
|
||||
System.print(123.sign) // expect: 1
|
||||
System.print((-123).sign) // expect: -1
|
||||
System.print(0.sign) // expect: 0
|
||||
System.print((-0).sign) // expect: 0
|
||||
System.print(0.123.sign) // expect: 1
|
||||
System.print((-0.123).sign) // expect: -1
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
IO.print(0.sin) // expect: 0
|
||||
IO.print((Num.pi / 2).sin) // expect: 1
|
||||
System.print(0.sin) // expect: 0
|
||||
System.print((Num.pi / 2).sin) // expect: 1
|
||||
|
||||
// these should of course be 0, but it's not that precise
|
||||
IO.print(Num.pi.sin) // expect: 1.2246467991474e-16
|
||||
IO.print((2 * Num.pi).sin) // expect: -2.4492935982947e-16
|
||||
System.print(Num.pi.sin) // expect: 1.2246467991474e-16
|
||||
System.print((2 * Num.pi).sin) // expect: -2.4492935982947e-16
|
||||
|
||||
@@ -1,10 +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
|
||||
System.print(4.sqrt) // expect: 2
|
||||
System.print(1000000.sqrt) // expect: 1000
|
||||
System.print(1.sqrt) // expect: 1
|
||||
System.print((-0).sqrt) // expect: -0
|
||||
System.print(0.sqrt) // expect: 0
|
||||
System.print(2.sqrt) // expect: 1.4142135623731
|
||||
|
||||
IO.print((-4).sqrt.isNan) // expect: true
|
||||
System.print((-4).sqrt.isNan) // expect: true
|
||||
|
||||
// TODO: Tests for sin and cos.
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
IO.print(0.tan) // expect: 0
|
||||
IO.print((Num.pi / 4).tan) // expect: 1
|
||||
IO.print((-Num.pi / 4).tan) // expect: -1
|
||||
System.print(0.tan) // expect: 0
|
||||
System.print((Num.pi / 4).tan) // expect: 1
|
||||
System.print((-Num.pi / 4).tan) // expect: -1
|
||||
|
||||
@@ -1,5 +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
|
||||
System.print(123.toString == "123") // expect: true
|
||||
System.print((-123).toString == "-123") // expect: true
|
||||
System.print((-0).toString == "-0") // expect: true
|
||||
System.print(12.34.toString == "12.34") // expect: true
|
||||
System.print((-0.0001).toString == "-0.0001") // expect: true
|
||||
|
||||
@@ -1,13 +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
|
||||
System.print(123.truncate) // expect: 123
|
||||
System.print((-123).truncate) // expect: -123
|
||||
System.print(0.truncate) // expect: 0
|
||||
System.print((-0).truncate) // expect: -0
|
||||
System.print(0.123.truncate) // expect: 0
|
||||
System.print(12.3.truncate) // expect: 12
|
||||
System.print((-0.123).truncate) // expect: -0
|
||||
System.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
|
||||
System.print((12345678901234.5).truncate) // expect: 12345678901234
|
||||
System.print((-12345678901234.5).truncate) // expect: -12345678901234
|
||||
|
||||
@@ -1,4 +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
|
||||
System.print(123 is Num) // expect: true
|
||||
System.print(123 is Object) // expect: true
|
||||
System.print(123 is String) // expect: false
|
||||
System.print(123.type == Num) // expect: true
|
||||
|
||||
Reference in New Issue
Block a user