From 7533fd8b025937b2a9ab834a6bbee2be7309de8b Mon Sep 17 00:00:00 2001 From: Jack Karamanian Date: Mon, 8 Jun 2020 13:31:21 -0500 Subject: LibJS: Initial class implementation; allow super expressions in object literal methods; add EnvrionmentRecord fields and methods to LexicalEnvironment Adding EnvrionmentRecord's fields and methods lets us throw an exception when |this| is not initialized, which occurs when the super constructor in a derived class has not yet been called, or when |this| has already been initialized (the super constructor was already called). --- Libraries/LibJS/Tests/object-basic.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Libraries/LibJS/Tests/object-basic.js') diff --git a/Libraries/LibJS/Tests/object-basic.js b/Libraries/LibJS/Tests/object-basic.js index 04580afa0c..5e61525e40 100644 --- a/Libraries/LibJS/Tests/object-basic.js +++ b/Libraries/LibJS/Tests/object-basic.js @@ -70,6 +70,22 @@ try { assert(a[2] === 3); assert(o4.test === undefined); + var base = { + getNumber() { + return 10; + } + }; + + var derived = { + getNumber() { + return 20 + super.getNumber(); + } + }; + + Object.setPrototypeOf(derived, base) + assert(derived.getNumber() === 30); + + assertIsSyntaxError("({ foo: function() { super.bar; } })") assertIsSyntaxError("({ get ...foo })"); assertIsSyntaxError("({ get... foo })"); assertIsSyntaxError("({ get foo })"); -- cgit v1.2.3