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/Class/superPropHomeObject.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/Class/superPropHomeObject.js')
-rw-r--r-- | js/src/tests/ecma_6/Class/superPropHomeObject.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Class/superPropHomeObject.js b/js/src/tests/ecma_6/Class/superPropHomeObject.js new file mode 100644 index 000000000..7694ae852 --- /dev/null +++ b/js/src/tests/ecma_6/Class/superPropHomeObject.js @@ -0,0 +1,62 @@ +// This is super weird. A super property reference in the spec contains two +// things. The first is the object to do the lookup on, the super base. This +// should be unchanged, no matter what's going on: I can move the method to +// another object. I can pull it out as its own function. I can put it on my +// head and run around the front yard. No changes. The other half, the |this| +// for invoked calls, is the this at the time of referencing the property, which +// means it's gonna vary wildly as stuff gets moved around. + +class base { + constructor() { } + test(expectedThis) { assertEq(this, expectedThis); } +} + +class derived extends base { + constructor() { super(); } + test(expected) { super.test(expected); } + testArrow() { return (() => super.test(this)); } + ["testCPN"](expected) { super.test(expected); } +} + +let derivedInstance = new derived(); +derivedInstance.test(derivedInstance); +derivedInstance.testCPN(derivedInstance); + +let obj = { test: derivedInstance.test }; +obj.test(obj); + +let testSolo = derivedInstance.test; +// Hah! The engine is not prepared for non-object receivers, since this couldn't +// happen before. Hope Waldo fixes this soon as he claims he will :) +assertThrowsInstanceOf(() =>testSolo(undefined), TypeError); + +let anotherObject = { }; +derivedInstance.test.call(anotherObject, anotherObject); + +let strThis = "this is not an object!"; +derivedInstance.test.call(strThis, strThis); + +// You can take the arrow function out of the super, ... or something like that +let arrowTest = derivedInstance.testArrow(); +arrowTest(); + +// There's no magic "super script index" per code location. +class base1 { + constructor() { } + test() { return "llama"; } +} +class base2 { + constructor() { } + test() { return "alpaca"; } +} + +let animals = []; +for (let exprBase of [base1, base2]) + new class extends exprBase { + constructor() { super(); } + test() { animals.push(super["test"]()); } + }().test(); +assertDeepEq(animals, ["llama", "alpaca"]); + +if (typeof reportCompare === 'function') + reportCompare(0,0,"OK"); |