diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_6/Expressions/destructuring-array-done.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_6/Expressions/destructuring-array-done.js')
-rw-r--r-- | js/src/tests/ecma_6/Expressions/destructuring-array-done.js | 319 |
1 files changed, 319 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Expressions/destructuring-array-done.js b/js/src/tests/ecma_6/Expressions/destructuring-array-done.js new file mode 100644 index 000000000..f2c7e9410 --- /dev/null +++ b/js/src/tests/ecma_6/Expressions/destructuring-array-done.js @@ -0,0 +1,319 @@ +var BUGNUMBER = 1184922; +var summary = "iterator.next() should not be called when after iterator completes"; + +print(BUGNUMBER + ": " + summary); + +var log; +function reset() { + log = ""; +} +var obj = new Proxy({}, { + set(that, name, value) { + var v; + if (value instanceof Function || value instanceof RegExp) + v = value.toString(); + else + v = JSON.stringify(value); + log += "set:" + name + "=" + v + ","; + } +}); +function createIterable(n) { + return { + i: 0, + [Symbol.iterator]() { + return this; + }, + next() { + log += "next,"; + this.i++; + if (this.i <= n) + return {value: this.i, done: false}; + return {value: 0, done: true}; + } + }; +} + +// Simple pattern. + +reset(); +[obj.a, obj.b, obj.c] = createIterable(0); +assertEq(log, + "next," + + "set:a=undefined," + + "set:b=undefined," + + "set:c=undefined,"); + +reset(); +[obj.a, obj.b, obj.c] = createIterable(1); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:b=undefined," + + "set:c=undefined,"); + +reset(); +[obj.a, obj.b, obj.c] = createIterable(2); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:b=2," + + "next," + + "set:c=undefined,"); + +reset(); +[obj.a, obj.b, obj.c] = createIterable(3); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:b=2," + + "next," + + "set:c=3,"); + +// Elision. + +reset(); +[obj.a, , obj.b, , , obj.c, ,] = createIterable(0); +assertEq(log, + "next," + + "set:a=undefined," + + "set:b=undefined," + + "set:c=undefined,"); + +reset(); +[obj.a, , obj.b, , , obj.c, ,] = createIterable(1); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:b=undefined," + + "set:c=undefined,"); + +reset(); +[obj.a, , obj.b, , , obj.c, ,] = createIterable(2); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "next," + + "set:b=undefined," + + "set:c=undefined,"); + +reset(); +[obj.a, , obj.b, , , obj.c, ,] = createIterable(3); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "next," + + "set:b=3," + + "next," + + "set:c=undefined,"); + +reset(); +[obj.a, , obj.b, , , obj.c, ,] = createIterable(4); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "next," + + "set:b=3," + + "next," + + "next," + + "set:c=undefined,"); + +reset(); +[obj.a, , obj.b, , , obj.c, ,] = createIterable(5); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "next," + + "set:b=3," + + "next," + + "next," + + "next," + + "set:c=undefined,"); + +reset(); +[obj.a, , obj.b, , , obj.c, ,] = createIterable(6); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "next," + + "set:b=3," + + "next," + + "next," + + "next," + + "set:c=6," + + "next,"); + +reset(); +[obj.a, , obj.b, , , obj.c, ,] = createIterable(7); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "next," + + "set:b=3," + + "next," + + "next," + + "next," + + "set:c=6," + + "next,"); + +// Rest. + +reset(); +[...obj.r] = createIterable(0); +assertEq(log, + "next," + + "set:r=[],"); + +reset(); +[...obj.r] = createIterable(1); +assertEq(log, + "next," + + "next," + + "set:r=[1],"); + +reset(); +[obj.a, ...obj.r] = createIterable(0); +assertEq(log, + "next," + + "set:a=undefined," + + "set:r=[],"); + +reset(); +[obj.a, ...obj.r] = createIterable(1); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:r=[],"); + +reset(); +[obj.a, ...obj.r] = createIterable(2); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "next," + + "set:r=[2],"); + +reset(); +[obj.a, obj.b, ...obj.r] = createIterable(0); +assertEq(log, + "next," + + "set:a=undefined," + + "set:b=undefined," + + "set:r=[],"); + +reset(); +[obj.a, obj.b, ...obj.r] = createIterable(1); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:b=undefined," + + "set:r=[],"); + +reset(); +[obj.a, obj.b, ...obj.r] = createIterable(2); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:b=2," + + "next," + + "set:r=[],"); + +reset(); +[obj.a, obj.b, ...obj.r] = createIterable(3); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:b=2," + + "next," + + "next," + + "set:r=[3],"); + +// Rest and elision. + +reset(); +[, ...obj.r] = createIterable(0); +assertEq(log, + "next," + + "set:r=[],"); + +reset(); +[, ...obj.r] = createIterable(1); +assertEq(log, + "next," + + "next," + + "set:r=[],"); + +reset(); +[, ...obj.r] = createIterable(2); +assertEq(log, + "next," + + "next," + + "next," + + "set:r=[2],"); + +reset(); +[obj.a, obj.b, , ...obj.r] = createIterable(0); +assertEq(log, + "next," + + "set:a=undefined," + + "set:b=undefined," + + "set:r=[],"); + +reset(); +[obj.a, obj.b, , ...obj.r] = createIterable(1); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:b=undefined," + + "set:r=[],"); + +reset(); +[obj.a, obj.b, , ...obj.r] = createIterable(2); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:b=2," + + "next," + + "set:r=[],"); + +reset(); +[obj.a, obj.b, , ...obj.r] = createIterable(3); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:b=2," + + "next," + + "next," + + "set:r=[],"); + +reset(); +[obj.a, obj.b, , ...obj.r] = createIterable(4); +assertEq(log, + "next," + + "set:a=1," + + "next," + + "set:b=2," + + "next," + + "next," + + "next," + + "set:r=[4],"); + +if (typeof reportCompare === "function") + reportCompare(true, true); |