|
| 1 | +open RescriptCore |
| 2 | + |
| 3 | +let eq = (a, b) => a == b |
| 4 | + |
| 5 | +let bign = BigInt.fromFloat(Float.Constants.maxValue) |
| 6 | +let bign = BigInt.add(bign, bign) |
| 7 | + |
| 8 | +Test.run(__POS_OF__("print null"), Test.print(null), eq, "null") |
| 9 | +Test.run(__POS_OF__("print undefined"), Test.print(undefined), eq, "undefined") |
| 10 | +Test.run(__POS_OF__("print NaN"), Test.print(nan), eq, "NaN") |
| 11 | +Test.run(__POS_OF__("print infinity"), Test.print(infinity), eq, "Infinity") |
| 12 | +Test.run(__POS_OF__("print 0"), Test.print(0), eq, "0") |
| 13 | +Test.run(__POS_OF__("print int"), Test.print(42), eq, "42") |
| 14 | +Test.run(__POS_OF__("print float"), Test.print(4.2), eq, "4.2") |
| 15 | +Test.run(__POS_OF__("print string"), Test.print("foo"), eq, `"foo"`) |
| 16 | +Test.run(__POS_OF__("print bool"), Test.print(true), eq, "true") |
| 17 | +Test.run(__POS_OF__("print object"), Test.print({"x": 42}), eq, `{ x: 42 }`) |
| 18 | +Test.run(__POS_OF__("print array"), Test.print([1, 2, 3]), eq, "[ 1, 2, 3 ]") |
| 19 | +Test.run(__POS_OF__("print symbol"), Test.print(Symbol.make("foo")), eq, "Symbol(foo)") |
| 20 | +Test.run( |
| 21 | + __POS_OF__("print function"), |
| 22 | + Test.print(() => 42), |
| 23 | + eq, |
| 24 | + "function (param) {\n return 42;\n }", |
| 25 | +) |
| 26 | +Test.run(__POS_OF__("print es6 function"), Test.print(%raw("() => 42")), eq, "() => 42") |
| 27 | +Test.run( |
| 28 | + __POS_OF__("print bigint"), |
| 29 | + Test.print(bign), |
| 30 | + eq, |
| 31 | + "359538626972463141629054847463408713596141135051689993197834953606314521560057077521179117265533756343080917907028764928468642653778928365536935093407075033972099821153102564152490980180778657888151737016910267884609166473806445896331617118664246696549595652408289446337476354361838599762500808052368249716736n", |
| 32 | +) |
| 33 | +Test.run(__POS_OF__("print set"), Test.print(Set.fromArray([1, 2, 2, 3])), eq, "Set(3) { 1, 2, 3 }") |
0 commit comments