summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/assert.js10
-rw-r--r--tests/test262.patch37
-rw-r--r--tests/test_language.js2
-rw-r--r--tests/test_std.js16
4 files changed, 54 insertions, 11 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..4ed0afb 100644
--- a/tests/test262.patch
+++ b/tests/test262.patch
@@ -90,6 +90,43 @@ index c1829e3..3a3ee27 100644
-}
\ 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 5b62aeb..da07aae 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;
+
+
+ //-----------------------------------------------------------------------------
+@@ -27,9 +26,6 @@ function test()
+ printBugNumber(BUGNUMBER);
+ printStatus (summary);
+
+- expect = 'TypeError: [].__proto__ is not a function';
+-
+-
+ Array.prototype.__proto__ = function () { return 3; };
+
+ try
+@@ -38,8 +34,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_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 df02f92..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
+ "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()