From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- js/src/tests/non262/extensions/decompile-for-of.js | 27 ++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 js/src/tests/non262/extensions/decompile-for-of.js (limited to 'js/src/tests/non262/extensions/decompile-for-of.js') diff --git a/js/src/tests/non262/extensions/decompile-for-of.js b/js/src/tests/non262/extensions/decompile-for-of.js new file mode 100644 index 0000000000..b99e20a40b --- /dev/null +++ b/js/src/tests/non262/extensions/decompile-for-of.js @@ -0,0 +1,27 @@ +// The decompiler can handle the implicit call to @@iterator in a for-of loop. + +var x; +function check(code, msg) { + var s = "no exception thrown"; + try { + eval(code); + } catch (exc) { + s = exc.message; + } + + assertEq(s, msg); +} + +x = {}; +check("for (var v of x) throw fit;", "x is not iterable"); +check("[...x]", "x is not iterable"); +check("Math.hypot(...x)", "x is not iterable"); + +x[Symbol.iterator] = "potato"; +check("for (var v of x) throw fit;", "x is not iterable"); + +x[Symbol.iterator] = {}; +check("for (var v of x) throw fit;", "x[Symbol.iterator] is not a function"); + +if (typeof reportCompare === "function") + reportCompare(0, 0, "ok"); -- cgit v1.2.3