diff options
Diffstat (limited to 'js/src/tests/non262')
-rw-r--r-- | js/src/tests/non262/Date/dashed-date.js | 6 | ||||
-rw-r--r-- | js/src/tests/non262/Date/parse-keywords.js | 7 | ||||
-rw-r--r-- | js/src/tests/non262/Intl/ListFormat/unit-type.js | 5 | ||||
-rw-r--r-- | js/src/tests/non262/String/make-normalize-generateddata-input.py | 2 | ||||
-rw-r--r-- | js/src/tests/non262/argumentsLengthOpt.js | 87 | ||||
-rw-r--r-- | js/src/tests/non262/extensions/typedarray-set-detach.js (renamed from js/src/tests/non262/extensions/typedarray-set-neutering.js) | 0 | ||||
-rw-r--r-- | js/src/tests/non262/reflect-parse/argumentsReflect.js | 14 |
7 files changed, 114 insertions, 7 deletions
diff --git a/js/src/tests/non262/Date/dashed-date.js b/js/src/tests/non262/Date/dashed-date.js index e479904098..d7b4692e7f 100644 --- a/js/src/tests/non262/Date/dashed-date.js +++ b/js/src/tests/non262/Date/dashed-date.js @@ -46,12 +46,10 @@ const tests = [ // ==== Date followed by hour and TZ ==== ["24-Apr-2023 12:34:56", "2023-04-24T12:34:56"], - ["24-Apr-2023 Mon 12:34:56", "2023-04-24T12:34:56"], ["24-Apr-2023 (Mon) 12:34:56", "2023-04-24T12:34:56"], ["24-Apr-2023(Mon)12:34:56", "2023-04-24T12:34:56"], ["24-Apr-2023,12:34:56", "2023-04-24T12:34:56"], - ["24-Apr-2023,Mon 12:34:56", "2023-04-24T12:34:56"], ["24-Apr-2023 12:34:56 GMT", "2023-04-24T12:34:56Z"], ["24-Apr-2023 12:34:56 +04", "2023-04-24T12:34:56+04:00"], @@ -145,6 +143,10 @@ const invalidTests = [ "24-Apr-2312+10:13:14", "24-Apr-2312=10:13:14", "24-Apr-2312?10:13:14", + + // Late weekday + "24-Apr-2023 Mon 12:34:56", + "24-Apr-2023,Mon 12:34:56", ]; for (const testString of invalidTests) { diff --git a/js/src/tests/non262/Date/parse-keywords.js b/js/src/tests/non262/Date/parse-keywords.js index c834bbfe0b..ba3b50b71b 100644 --- a/js/src/tests/non262/Date/parse-keywords.js +++ b/js/src/tests/non262/Date/parse-keywords.js @@ -12,7 +12,6 @@ const accepted = { "Sep 26 1995 10:00 am": "1995-09-26T10:00:00", "Sep 26 1995 10:00 AM": "1995-09-26T10:00:00", "Sep 26 1995 10:00 pm": "1995-09-26T22:00:00", - "Sep 26 Thurs 1995 Mon 10:thursday:00": "1995-09-26T10:00:00", }; const rejected = [ "Sep 26 1995 G", @@ -22,6 +21,12 @@ const rejected = [ "Sep 26 1995 10:00 a", "Sep 26 1995 10:00 p", "0/zx", + + // Late weekday + "Sep 26 Thurs 1995 10:00", + "Sep 26 1995 Thurs 10:00", + "Sep 26 1995 10:Thurs:00", + "Sep 26 1995 10:00 Thurs", ]; for (const [test, expected] of Object.entries(accepted)) { diff --git a/js/src/tests/non262/Intl/ListFormat/unit-type.js b/js/src/tests/non262/Intl/ListFormat/unit-type.js index 8c76677865..4f1c7321cf 100644 --- a/js/src/tests/non262/Intl/ListFormat/unit-type.js +++ b/js/src/tests/non262/Intl/ListFormat/unit-type.js @@ -1,4 +1,4 @@ -// |reftest| skip -- "unit" type currently not supported +// |reftest| skip-if(!this.hasOwnProperty('Intl')) const {Element, Literal} = ListFormatParts; const styles = ["long", "short", "narrow"]; @@ -38,7 +38,6 @@ const styles = ["long", "short", "narrow"]; const testData = { "ar": { long: [Element("A"), Literal(" و"), Element("B")], - narrow: [Element("A"), Literal("، "), Element("B")], }, "de": { long: [Element("A"), Literal(", "), Element("B")], @@ -90,7 +89,7 @@ const styles = ["long", "short", "narrow"]; // non-ASCII case "ar": { long: [Element("A"), Literal("، و"), Element("B"), Literal("، و"), Element("C"), Literal("، و"), Element("D")], - narrow: [Element("A"), Literal("، "), Element("B"), Literal("، "), Element("C"), Literal("، "), Element("D")], + narrow: [Element("A"), Literal(" و"), Element("B"), Literal(" و"), Element("C"), Literal(" و"), Element("D")], }, // all values are equal diff --git a/js/src/tests/non262/String/make-normalize-generateddata-input.py b/js/src/tests/non262/String/make-normalize-generateddata-input.py index 5c3d2d3e44..086275e67d 100644 --- a/js/src/tests/non262/String/make-normalize-generateddata-input.py +++ b/js/src/tests/non262/String/make-normalize-generateddata-input.py @@ -18,7 +18,7 @@ def to_code_list(codes): def convert(dir): - ver_pat = re.compile("NormalizationTest-([0-9\.]+)\.txt") + ver_pat = re.compile(r"NormalizationTest-([0-9\.]+)\.txt") part_pat = re.compile("^@(Part([0-9]+) .+)$") test_pat = re.compile( "^([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);([0-9A-Fa-f ]+);$" diff --git a/js/src/tests/non262/argumentsLengthOpt.js b/js/src/tests/non262/argumentsLengthOpt.js new file mode 100644 index 0000000000..16385fa5a4 --- /dev/null +++ b/js/src/tests/non262/argumentsLengthOpt.js @@ -0,0 +1,87 @@ +// Test cases for arguments.length optimization. + +function f1() { + return arguments.length; +} + +function f2(a, b, c) { + return arguments.length; +} + +// arrow functions don't have their own arguments, and so capture the enclosing +// scope. +function f3(a, b, c, d) { + return (() => arguments.length)(); +} + +// Test a function which mutates arguments.length +function f4(a, b, c, d) { + arguments.length = 42; + return arguments.length; +} + +// Manually read out arguments; should disable the length opt +function f5() { + for (var i = 0; i < arguments.length; i++) { + if (arguments[i] == 10) { return true } + } + return false; +} + +function f6() { + function inner() { + return arguments.length; + } + return inner(1, 2, 3); +} + +// edge cases of the arguments bindings: +function f7() { + var arguments = 42; + return arguments; +} + +function f8() { + var arguments = [1, 2]; + return arguments.length; +} + +function f9() { + eval("arguments.length = 42"); + return arguments.length; +} + +function test() { + assertEq(f1(), 0); + assertEq(f1(1), 1); + assertEq(f1(1, 2), 2); + assertEq(f1(1, 2, 3), 3); + + assertEq(f2(), 0); + assertEq(f2(1, 2, 3), 3); + + assertEq(f3(), 0); + assertEq(f3(1, 2, 3), 3); + + assertEq(f4(), 42); + assertEq(f4(1, 2, 3), 42); + + assertEq(f5(), false); + assertEq(f5(1, 2, 3, 10), true); + assertEq(f5(1, 2, 3, 10, 20), true); + assertEq(f5(1, 2, 3, 9, 20, 30), false); + + assertEq(f6(), 3) + assertEq(f6(1, 2, 3, 4), 3) + + assertEq(f7(), 42); + + assertEq(f8(), 2); + + assertEq(f9(), 42); +} + +test(); + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); diff --git a/js/src/tests/non262/extensions/typedarray-set-neutering.js b/js/src/tests/non262/extensions/typedarray-set-detach.js index 23df8158c5..23df8158c5 100644 --- a/js/src/tests/non262/extensions/typedarray-set-neutering.js +++ b/js/src/tests/non262/extensions/typedarray-set-detach.js diff --git a/js/src/tests/non262/reflect-parse/argumentsReflect.js b/js/src/tests/non262/reflect-parse/argumentsReflect.js new file mode 100644 index 0000000000..69a8624acc --- /dev/null +++ b/js/src/tests/non262/reflect-parse/argumentsReflect.js @@ -0,0 +1,14 @@ +// |reftest| skip-if(!xulRuntime.shell) + +// Test reflect.parse on a function with arguments.length +let ast = Reflect.parse(`function f10() { + return arguments.length; +}`); + +assertEq(ast.body[0].body.body[0].argument.object.type, "Identifier"); +assertEq(ast.body[0].body.body[0].argument.object.name, "arguments"); +assertEq(ast.body[0].body.body[0].argument.property.type, "Identifier"); +assertEq(ast.body[0].body.body[0].argument.property.name, "length"); + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); |