summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/assert.js10
-rw-r--r--tests/test262.patch48
-rw-r--r--tests/test_builtin.js2
-rw-r--r--tests/test_language.js2
-rw-r--r--tests/test_std.js18
5 files changed, 58 insertions, 22 deletions
diff --git a/tests/assert.js b/tests/assert.js
index c8240c8..42369ed 100644
--- a/tests/assert.js
+++ b/tests/assert.js
@@ -3,14 +3,8 @@ export function assert(actual, expected, message) {
expected = true;
if (typeof actual === typeof expected) {
- if (actual === expected) {
- if (actual !== 0 || (1 / actual) === (1 / expected))
- return;
- }
- if (typeof actual === 'number') {
- if (isNaN(actual) && isNaN(expected))
- return;
- }
+ if (Object.is(actual, expected))
+ return;
if (typeof actual === 'object') {
if (actual !== null && expected !== null
&& actual.constructor === expected.constructor
diff --git a/tests/test262.patch b/tests/test262.patch
index b6f4aa5..6956d15 100644
--- a/tests/test262.patch
+++ b/tests/test262.patch
@@ -71,10 +71,10 @@ index b397be0..c197ddc 100644
return result;
}
diff --git a/harness/sm/non262.js b/harness/sm/non262.js
-index c1829e3..3a3ee27 100644
+index 89df923..79ded15 100644
--- a/harness/sm/non262.js
+++ b/harness/sm/non262.js
-@@ -41,8 +41,6 @@ globalThis.createNewGlobal = function() {
+@@ -34,8 +34,6 @@ globalThis.createNewGlobal = function() {
return $262.createRealm().global
}
@@ -83,13 +83,43 @@ index c1829e3..3a3ee27 100644
function assertEq(...args) {
assert.sameValue(...args)
}
-@@ -71,4 +69,4 @@ if (globalThis.createExternalArrayBuffer === undefined) {
- if (globalThis.enableGeckoProfilingWithSlowAssertions === undefined) {
- globalThis.enableGeckoProfilingWithSlowAssertions = globalThis.enableGeckoProfiling =
- globalThis.disableGeckoProfiling = () => {}
--}
-\ No newline at end of file
-+}
+diff --git a/test/staging/sm/extensions/regress-469625-01.js b/test/staging/sm/extensions/regress-469625-01.js
+index 81f84fc..4652002 100644
+--- a/test/staging/sm/extensions/regress-469625-01.js
++++ b/test/staging/sm/extensions/regress-469625-01.js
+@@ -14,8 +14,7 @@ esid: pending
+ //-----------------------------------------------------------------------------
+ var BUGNUMBER = 469625;
+ var summary = 'TM: Array prototype and expression closures';
+-var actual = '';
+-var expect = '';
++var actual = null;
+
+
+ //-----------------------------------------------------------------------------
+@@ -24,9 +23,6 @@ test();
+
+ function test()
+ {
+- expect = 'TypeError: [].__proto__ is not a function';
+-
+-
+ Array.prototype.__proto__ = function () { return 3; };
+
+ try
+@@ -35,8 +31,10 @@ function test()
+ }
+ catch(ex)
+ {
+- print(actual = ex + '');
++ print(ex + '');
++ actual = ex;
+ }
+
+- assert.sameValue(expect, actual, summary);
++ assert.sameValue(actual instanceof TypeError, true);
++ assert.sameValue(actual.message.includes("not a function"), true);
+ }
diff --git a/test/staging/sm/misc/new-with-non-constructor.js b/test/staging/sm/misc/new-with-non-constructor.js
index 18c2f0c..f9aa209 100644
--- a/test/staging/sm/misc/new-with-non-constructor.js
diff --git a/tests/test_builtin.js b/tests/test_builtin.js
index ff376ec..a541c19 100644
--- a/tests/test_builtin.js
+++ b/tests/test_builtin.js
@@ -596,7 +596,7 @@ function test_json()
]
]`);
- assert_json_error('\n" @\\x"');
+ assert_json_error('\n" \\@x"');
assert_json_error('\n{ "a": @x }"');
}
diff --git a/tests/test_language.js b/tests/test_language.js
index cda782b..4fa16c8 100644
--- a/tests/test_language.js
+++ b/tests/test_language.js
@@ -2,7 +2,7 @@ function assert(actual, expected, message) {
if (arguments.length == 1)
expected = true;
- if (actual === expected)
+ if (Object.is(actual, expected))
return;
if (actual !== null && expected !== null
diff --git a/tests/test_std.js b/tests/test_std.js
index bb942d6..3debe40 100644
--- a/tests/test_std.js
+++ b/tests/test_std.js
@@ -6,7 +6,7 @@ function assert(actual, expected, message) {
if (arguments.length == 1)
expected = true;
- if (actual === expected)
+ if (Object.is(actual, expected))
return;
if (actual !== null && expected !== null
@@ -129,15 +129,27 @@ function test_popen()
function test_ext_json()
{
var expected, input, obj;
- expected = '{"x":false,"y":true,"z2":null,"a":[1,8,160],"s":"str"}';
+ expected = '{"x":false,"y":true,"z2":null,"a":[1,8,160],"b":"abc\\u000bd","s":"str"}';
input = `{ "x":false, /*comments are allowed */
"y":true, // also a comment
z2:null, // unquoted property names
"a":[+1,0o10,0xa0,], // plus prefix, octal, hexadecimal
- "s":"str",} // trailing comma in objects and arrays
+ "b": "ab\
+c\\vd", // multi-line strings, '\v' escape
+ "s":'str',} // trailing comma in objects and arrays, single quoted string
`;
obj = std.parseExtJSON(input);
assert(JSON.stringify(obj), expected);
+
+ obj = std.parseExtJSON('[Infinity, +Infinity, -Infinity, NaN, +NaN, -NaN, .1, -.2]');
+ assert(obj[0], Infinity);
+ assert(obj[1], Infinity);
+ assert(obj[2], -Infinity);
+ assert(obj[3], NaN);
+ assert(obj[4], NaN);
+ assert(obj[5], NaN);
+ assert(obj[6], 0.1);
+ assert(obj[7], -0.2);
}
function test_os()