diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2015-06-19 13:23:56 +0200 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2015-08-04 11:56:14 -0700 |
commit | 70d1f32f5605465a1a630a64f6f0d35f96c7709d (patch) | |
tree | 0a349040a686eafcb0a09943ebc733477dce2781 /deps/v8/test/webkit | |
parent | 4643b8b6671607a7aff60cbbd0b384dcf2f6959e (diff) | |
download | node-new-70d1f32f5605465a1a630a64f6f0d35f96c7709d.tar.gz |
deps: update v8 to 4.4.63.9
Upgrade the bundled V8 and update code in src/ and lib/ to the new API.
Notable backwards incompatible changes are the removal of the smalloc
module and dropped support for CESU-8 decoding. CESU-8 support can be
brought back if necessary by doing UTF-8 decoding ourselves.
This commit includes https://codereview.chromium.org/1192973004 to fix
a build error on python 2.6 systems. The original commit log follows:
Use optparse in js2c.py for python compatibility
Without this change, V8 won't build on RHEL/CentOS 6 because the
distro python is too old to know about the argparse module.
PR-URL: https://github.com/nodejs/io.js/pull/2022
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'deps/v8/test/webkit')
33 files changed, 1649 insertions, 294 deletions
diff --git a/deps/v8/test/webkit/class-constructor-return-expected.txt b/deps/v8/test/webkit/class-constructor-return-expected.txt new file mode 100644 index 0000000000..36062f040d --- /dev/null +++ b/deps/v8/test/webkit/class-constructor-return-expected.txt @@ -0,0 +1,94 @@ +Tests for ES6 class constructor return values + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Base class +PASS (new BaseNoReturn) instanceof BaseNoReturn is true +PASS (new BaseReturnImplicit) instanceof BaseReturnImplicit is true +PASS (new BaseReturnImplicit) !== undefined is true +PASS (new BaseReturnUndefined) instanceof BaseReturnUndefined is true +PASS (new BaseReturnUndefined) !== undefined is true +PASS (new BaseReturnThis) instanceof BaseReturnThis is true +PASS (new BaseReturnObject) instanceof BaseReturnObject is false +PASS typeof (new BaseReturnObject) === "object" is true +PASS (new BaseReturnObject2) instanceof BaseReturnObject is false +PASS (new BaseReturnObject2) === globalVariable is true +PASS (new BaseReturnString) instanceof BaseReturnString is true +PASS typeof (new BaseReturnString) !== "string" is true +PASS (new BaseReturnNumber) instanceof BaseReturnNumber is true +PASS typeof (new BaseReturnNumber) !== "number" is true +PASS (new BaseReturnNull) instanceof BaseReturnNull is true +PASS (new BaseReturnNull) !== null is true +PASS (new BaseReturnSymbol) instanceof BaseReturnSymbol is true +PASS (new BaseReturnSymbol) !== globalSymbol is true +PASS (new BaseThrow) threw exception Thrown Exception String. + +Function constructor (non-class) +PASS (new FunctionNoReturn) instanceof FunctionNoReturn is true +PASS (new FunctionReturnImplicit) instanceof FunctionReturnImplicit is true +PASS (new FunctionReturnImplicit) !== undefined is true +PASS (new FunctionReturnUndefined) instanceof FunctionReturnUndefined is true +PASS (new FunctionReturnUndefined) !== undefined is true +PASS (new FunctionReturnThis) instanceof FunctionReturnThis is true +PASS (new FunctionReturnObject) instanceof FunctionReturnObject is false +PASS typeof (new FunctionReturnObject) === "object" is true +PASS (new FunctionReturnObject2) instanceof FunctionReturnObject is false +PASS (new FunctionReturnObject2) === globalVariable is true +PASS (new FunctionReturnString) instanceof FunctionReturnString is true +PASS typeof (new FunctionReturnString) !== "string" is true +PASS (new FunctionReturnNumber) instanceof FunctionReturnNumber is true +PASS typeof (new FunctionReturnNumber) !== "number" is true +PASS (new FunctionReturnNull) instanceof FunctionReturnNull is true +PASS (new FunctionReturnNull) !== null is true +PASS (new FunctionReturnSymbol) instanceof FunctionReturnSymbol is true +PASS (new FunctionReturnSymbol) !== globalSymbol is true +PASS (new FunctionThrow) threw exception Thrown Exception String. + +Derived class calling super() +PASS (new DerivedNoReturn) instanceof DerivedNoReturn is true +PASS (new DerivedReturnImplicit) instanceof DerivedReturnImplicit is true +PASS (new DerivedReturnImplicit) !== undefined is true +PASS (new DerivedReturnUndefined) instanceof DerivedReturnUndefined is true +PASS (new DerivedReturnUndefined) !== undefined is true +PASS (new DerivedReturnThis) instanceof DerivedReturnThis is true +PASS (new DerivedReturnObject) instanceof DerivedReturnObject is false +PASS typeof (new DerivedReturnObject) === "object" is true +PASS (new DerivedReturnObject2) instanceof DerivedReturnObject2 is false +PASS (new DerivedReturnObject2) === globalVariable is true +PASS (new DerivedReturnString) threw exception TypeError: Derived constructors may only return object or undefined. +PASS (new DerivedReturnNumber) threw exception TypeError: Derived constructors may only return object or undefined. +PASS (new DerivedReturnNull) threw exception TypeError: Derived constructors may only return object or undefined. +PASS (new DerivedReturnSymbol) threw exception TypeError: Derived constructors may only return object or undefined. +PASS (new DerivedThrow) threw exception Thrown Exception String. + +Derived class not calling super() +PASS (new DerivedNoSuperNoReturn) threw exception ReferenceError: this is not defined. +PASS (new DerivedNoSuperReturnImplicit) threw exception ReferenceError: DerivedNoSuperReturnImplicit is not defined. +PASS (new DerivedNoSuperReturnUndefined) threw exception ReferenceError: this is not defined. +PASS (new DerivedNoSuperReturnThis) threw exception ReferenceError: this is not defined. +PASS (new DerivedNoSuperReturnObject) did not throw exception. +PASS (new DerivedNoSuperReturnObject2) did not throw exception. +PASS (new DerivedNoSuperReturnString) threw exception TypeError: Derived constructors may only return object or undefined. +PASS (new DerivedNoSuperReturnNumber) threw exception TypeError: Derived constructors may only return object or undefined. +PASS (new DerivedNoSuperReturnNull) threw exception TypeError: Derived constructors may only return object or undefined. +PASS (new DerivedNoSuperReturnSymbol) threw exception TypeError: Derived constructors may only return object or undefined. +PASS (new DerivedNoSuperThrow) threw exception Thrown Exception String. + +Derived class with default constructor and base class returning different values +PASS (new DerivedDefaultConstructorWithBaseNoReturn) instanceof DerivedDefaultConstructorWithBaseNoReturn is true +PASS (new DerivedDefaultConstructorWithBaseReturnImplicit) instanceof DerivedDefaultConstructorWithBaseReturnImplicit is true +PASS (new DerivedDefaultConstructorWithBaseReturnUndefined) instanceof DerivedDefaultConstructorWithBaseReturnUndefined is true +PASS (new DerivedDefaultConstructorWithBaseReturnObject) instanceof DerivedDefaultConstructorWithBaseReturnObject is false +PASS typeof (new DerivedDefaultConstructorWithBaseReturnObject) === "object" is true +PASS (new DerivedDefaultConstructorWithBaseReturnObject2) instanceof DerivedDefaultConstructorWithBaseReturnObject2 is false +PASS (new DerivedDefaultConstructorWithBaseReturnObject2) === globalVariable is true +PASS (new DerivedDefaultConstructorWithBaseReturnThis) instanceof DerivedDefaultConstructorWithBaseReturnThis is true +PASS (new DerivedDefaultConstructorWithBaseReturnString) instanceof DerivedDefaultConstructorWithBaseReturnString is true +PASS (new DerivedDefaultConstructorWithBaseReturnNumber) instanceof DerivedDefaultConstructorWithBaseReturnNumber is true +PASS (new DerivedDefaultConstructorWithBaseReturnNull) instanceof DerivedDefaultConstructorWithBaseReturnNull is true +PASS (new DerivedDefaultConstructorWithBaseReturnSymbol) instanceof DerivedDefaultConstructorWithBaseReturnSymbol is true +PASS (new DerivedDefaultConstructorWithBaseThrow) threw exception Thrown Exception String. +PASS successfullyParsed is true + +TEST COMPLETE diff --git a/deps/v8/test/webkit/class-constructor-return.js b/deps/v8/test/webkit/class-constructor-return.js new file mode 100644 index 0000000000..6eb72ad403 --- /dev/null +++ b/deps/v8/test/webkit/class-constructor-return.js @@ -0,0 +1,217 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-sloppy + +description('Tests for ES6 class constructor return values'); + +// ES6 +// - 9.2.2 [[Construct]] (ECMAScript Function Objects) +// - 12.3.5.1 Runtime Semantics: Evaluation (The super Keyword) +// - 14.5.14 Runtime Semantics: ClassDefinitionEvaluation (Default Constructor) + +var globalVariable = {name:"globalVariable"}; +var globalSymbol = Symbol(); + +debug('Base class'); +class BaseNoReturn { constructor() { } }; +class BaseReturnImplicit { constructor() { return; } }; +class BaseReturnUndefined { constructor() { return undefined; } }; +class BaseReturnThis { constructor() { return this; } }; +class BaseReturnObject { constructor() { return {a:1}; } }; +class BaseReturnObject2 { constructor() { return globalVariable; } }; +class BaseReturnString { constructor() { return "test"; } }; +class BaseReturnNumber { constructor() { return 1; } }; +class BaseReturnNull { constructor() { return null; } }; +class BaseReturnSymbol { constructor() { return Symbol(); } }; +class BaseThrow { constructor() { throw "Thrown Exception String"; } }; + +// Base - Implicit => return this. +shouldBeTrue('(new BaseNoReturn) instanceof BaseNoReturn'); + +// Base - Early return => return this. +shouldBeTrue('(new BaseReturnImplicit) instanceof BaseReturnImplicit'); +shouldBeTrue('(new BaseReturnImplicit) !== undefined'); +shouldBeTrue('(new BaseReturnUndefined) instanceof BaseReturnUndefined'); +shouldBeTrue('(new BaseReturnUndefined) !== undefined'); + +// Base - return this => return this. +shouldBeTrue('(new BaseReturnThis) instanceof BaseReturnThis'); + +// Base - return Object => return object, not instance. +shouldBeFalse('(new BaseReturnObject) instanceof BaseReturnObject'); +shouldBeTrue('typeof (new BaseReturnObject) === "object"'); +shouldBeFalse('(new BaseReturnObject2) instanceof BaseReturnObject'); +shouldBeTrue('(new BaseReturnObject2) === globalVariable'); + +// Base - return non-Object => return this. +shouldBeTrue('(new BaseReturnString) instanceof BaseReturnString'); +shouldBeTrue('typeof (new BaseReturnString) !== "string"'); +shouldBeTrue('(new BaseReturnNumber) instanceof BaseReturnNumber'); +shouldBeTrue('typeof (new BaseReturnNumber) !== "number"'); +shouldBeTrue('(new BaseReturnNull) instanceof BaseReturnNull'); +shouldBeTrue('(new BaseReturnNull) !== null'); +shouldBeTrue('(new BaseReturnSymbol) instanceof BaseReturnSymbol'); +shouldBeTrue('(new BaseReturnSymbol) !== globalSymbol'); + +// Base - throw => throw +shouldThrow('(new BaseThrow)'); + +// Same behavior for Functions. +debug(''); debug('Function constructor (non-class)'); +function FunctionNoReturn() { }; +function FunctionReturnImplicit() { return; }; +function FunctionReturnUndefined() { return undefined; }; +function FunctionReturnThis() { return this; }; +function FunctionReturnObject() { return {a:1}; }; +function FunctionReturnObject2() { return globalVariable; }; +function FunctionReturnString() { return "test"; }; +function FunctionReturnNumber() { return 1; }; +function FunctionReturnNull() { return null; }; +function FunctionReturnSymbol() { return Symbol(); }; +function FunctionThrow() { throw "Thrown Exception String"; }; + +shouldBeTrue('(new FunctionNoReturn) instanceof FunctionNoReturn'); +shouldBeTrue('(new FunctionReturnImplicit) instanceof FunctionReturnImplicit'); +shouldBeTrue('(new FunctionReturnImplicit) !== undefined'); +shouldBeTrue('(new FunctionReturnUndefined) instanceof FunctionReturnUndefined'); +shouldBeTrue('(new FunctionReturnUndefined) !== undefined'); +shouldBeTrue('(new FunctionReturnThis) instanceof FunctionReturnThis'); +shouldBeFalse('(new FunctionReturnObject) instanceof FunctionReturnObject'); +shouldBeTrue('typeof (new FunctionReturnObject) === "object"'); +shouldBeFalse('(new FunctionReturnObject2) instanceof FunctionReturnObject'); +shouldBeTrue('(new FunctionReturnObject2) === globalVariable'); +shouldBeTrue('(new FunctionReturnString) instanceof FunctionReturnString'); +shouldBeTrue('typeof (new FunctionReturnString) !== "string"'); +shouldBeTrue('(new FunctionReturnNumber) instanceof FunctionReturnNumber'); +shouldBeTrue('typeof (new FunctionReturnNumber) !== "number"'); +shouldBeTrue('(new FunctionReturnNull) instanceof FunctionReturnNull'); +shouldBeTrue('(new FunctionReturnNull) !== null'); +shouldBeTrue('(new FunctionReturnSymbol) instanceof FunctionReturnSymbol'); +shouldBeTrue('(new FunctionReturnSymbol) !== globalSymbol'); +shouldThrow('(new FunctionThrow)'); + + +debug(''); debug('Derived class calling super()'); +class DerivedNoReturn extends BaseNoReturn { constructor() { super(); } }; +class DerivedReturnImplicit extends BaseNoReturn { constructor() { super(); return; } }; +class DerivedReturnUndefined extends BaseNoReturn { constructor() { super(); return undefined; } }; +class DerivedReturnThis extends BaseNoReturn { constructor() { super(); return this; } }; +class DerivedReturnObject extends BaseNoReturn { constructor() { super(); return {a:1}; } }; +class DerivedReturnObject2 extends BaseNoReturn { constructor() { super(); return globalVariable; } }; +class DerivedReturnString extends BaseNoReturn { constructor() { super(); return "test"; } }; +class DerivedReturnNumber extends BaseNoReturn { constructor() { super(); return 1; } }; +class DerivedReturnNull extends BaseNoReturn { constructor() { super(); return null; } }; +class DerivedReturnSymbol extends BaseNoReturn { constructor() { super(); return globalSymbol; } }; +class DerivedThrow extends BaseNoReturn { constructor() { super(); throw "Thrown Exception String"; } }; + +// Derived - Implicit => return this. +shouldBeTrue('(new DerivedNoReturn) instanceof DerivedNoReturn'); + +// Derived - Early return => return this. +shouldBeTrue('(new DerivedReturnImplicit) instanceof DerivedReturnImplicit'); +shouldBeTrue('(new DerivedReturnImplicit) !== undefined'); +shouldBeTrue('(new DerivedReturnUndefined) instanceof DerivedReturnUndefined'); +shouldBeTrue('(new DerivedReturnUndefined) !== undefined'); + +// Derived - return this => return this. +shouldBeTrue('(new DerivedReturnThis) instanceof DerivedReturnThis'); + +// Derived - return Object => return object, not instance. +shouldBeFalse('(new DerivedReturnObject) instanceof DerivedReturnObject'); +shouldBeTrue('typeof (new DerivedReturnObject) === "object"'); +shouldBeFalse('(new DerivedReturnObject2) instanceof DerivedReturnObject2'); +shouldBeTrue('(new DerivedReturnObject2) === globalVariable'); + +// Derived - return non-Object => exception. +shouldThrow('(new DerivedReturnString)'); +shouldThrow('(new DerivedReturnNumber)'); +shouldThrow('(new DerivedReturnNull)'); +shouldThrow('(new DerivedReturnSymbol)'); +shouldThrow('(new DerivedThrow)'); + + +debug(''); debug('Derived class not calling super()'); +class DerivedNoSuperNoReturn extends BaseNoReturn { constructor() { } }; +class DerivedNoSuperReturn extends BaseNoReturn { constructor() { return; } }; +class DerivedNoSuperReturnUndefined extends BaseNoReturn { constructor() { return undefined; } }; +class DerivedNoSuperReturnObject extends BaseNoReturn { constructor() { return {a:1}; } }; +class DerivedNoSuperReturnObject2 extends BaseNoReturn { constructor() { return globalVariable; } }; +class DerivedNoSuperReturnThis extends BaseNoReturn { constructor() { return this; } }; +class DerivedNoSuperReturnString extends BaseNoReturn { constructor() { return "test"; } }; +class DerivedNoSuperReturnNumber extends BaseNoReturn { constructor() { return 1; } }; +class DerivedNoSuperReturnNull extends BaseNoReturn { constructor() { return null; } }; +class DerivedNoSuperReturnSymbol extends BaseNoReturn { constructor() { return globalSymbol; } }; +class DerivedNoSuperThrow extends BaseNoReturn { constructor() { throw "Thrown Exception String"; } }; + +// Derived without super() - Implicit => return this => TDZ. +shouldThrow('(new DerivedNoSuperNoReturn)'); + +// Derived without super() - Early return => return this => TDZ. +shouldThrow('(new DerivedNoSuperReturnImplicit)'); +shouldThrow('(new DerivedNoSuperReturnUndefined)'); + +// Derived without super() - return this => return this => TDZ +shouldThrow('(new DerivedNoSuperReturnThis)'); + +// Derived without super() - return Object => no this access => return object, not instance +shouldNotThrow('(new DerivedNoSuperReturnObject)'); +shouldNotThrow('(new DerivedNoSuperReturnObject2)'); + +// Derived without super() - return non-Object => exception +shouldThrow('(new DerivedNoSuperReturnString)'); // TypeError +shouldThrow('(new DerivedNoSuperReturnNumber)'); // TypeError +shouldThrow('(new DerivedNoSuperReturnNull)'); // TypeError +shouldThrow('(new DerivedNoSuperReturnSymbol)'); // TypeError +shouldThrow('(new DerivedNoSuperThrow)'); // Thrown exception + + +debug(''); debug('Derived class with default constructor and base class returning different values'); +class DerivedDefaultConstructorWithBaseNoReturn extends BaseNoReturn { }; +class DerivedDefaultConstructorWithBaseReturnImplicit extends BaseReturnImplicit { }; +class DerivedDefaultConstructorWithBaseReturnUndefined extends BaseReturnUndefined { }; +class DerivedDefaultConstructorWithBaseReturnThis extends BaseReturnThis { }; +class DerivedDefaultConstructorWithBaseReturnObject extends BaseReturnObject { }; +class DerivedDefaultConstructorWithBaseReturnObject2 extends BaseReturnObject2 { }; +class DerivedDefaultConstructorWithBaseReturnString extends BaseReturnString { }; +class DerivedDefaultConstructorWithBaseReturnNumber extends BaseReturnNumber { }; +class DerivedDefaultConstructorWithBaseReturnNull extends BaseReturnNull { }; +class DerivedDefaultConstructorWithBaseReturnSymbol extends BaseReturnSymbol { }; +class DerivedDefaultConstructorWithBaseThrow extends BaseThrow { }; + +// Derived default constructor - implicit "super(...arguments)" return the result of the base (Object or this). +shouldBeTrue('(new DerivedDefaultConstructorWithBaseNoReturn) instanceof DerivedDefaultConstructorWithBaseNoReturn'); +shouldBeTrue('(new DerivedDefaultConstructorWithBaseReturnImplicit) instanceof DerivedDefaultConstructorWithBaseReturnImplicit'); +shouldBeTrue('(new DerivedDefaultConstructorWithBaseReturnUndefined) instanceof DerivedDefaultConstructorWithBaseReturnUndefined'); +shouldBeFalse('(new DerivedDefaultConstructorWithBaseReturnObject) instanceof DerivedDefaultConstructorWithBaseReturnObject'); +shouldBeTrue('typeof (new DerivedDefaultConstructorWithBaseReturnObject) === "object"'); +shouldBeFalse('(new DerivedDefaultConstructorWithBaseReturnObject2) instanceof DerivedDefaultConstructorWithBaseReturnObject2'); +shouldBeTrue('(new DerivedDefaultConstructorWithBaseReturnObject2) === globalVariable'); +shouldBeTrue('(new DerivedDefaultConstructorWithBaseReturnThis) instanceof DerivedDefaultConstructorWithBaseReturnThis'); +shouldBeTrue('(new DerivedDefaultConstructorWithBaseReturnString) instanceof DerivedDefaultConstructorWithBaseReturnString'); +shouldBeTrue('(new DerivedDefaultConstructorWithBaseReturnNumber) instanceof DerivedDefaultConstructorWithBaseReturnNumber'); +shouldBeTrue('(new DerivedDefaultConstructorWithBaseReturnNull) instanceof DerivedDefaultConstructorWithBaseReturnNull'); +shouldBeTrue('(new DerivedDefaultConstructorWithBaseReturnSymbol) instanceof DerivedDefaultConstructorWithBaseReturnSymbol'); +shouldThrow('(new DerivedDefaultConstructorWithBaseThrow)'); + +var successfullyParsed = true; diff --git a/deps/v8/test/webkit/class-syntax-call-expected.txt b/deps/v8/test/webkit/class-syntax-call-expected.txt new file mode 100644 index 0000000000..79045ace95 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-call-expected.txt @@ -0,0 +1,16 @@ +Tests for calling the constructors of ES6 classes + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS new A did not throw exception. +PASS A() threw exception TypeError: Class constructors cannot be invoked without 'new'. +PASS new B did not throw exception. +PASS B() threw exception TypeError: Class constructors cannot be invoked without 'new'. +PASS new (class { constructor() {} })() did not throw exception. +PASS (class { constructor() {} })() threw exception TypeError: Class constructors cannot be invoked without 'new'. +PASS new (class extends null { constructor() { super() } })() threw exception TypeError: function () {} is not a constructor. +PASS (class extends null { constructor() { super() } })() threw exception TypeError: Class constructors cannot be invoked without 'new'. +PASS successfullyParsed is true + +TEST COMPLETE diff --git a/deps/v8/test/webkit/class-syntax-call.js b/deps/v8/test/webkit/class-syntax-call.js new file mode 100644 index 0000000000..3cf82a8899 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-call.js @@ -0,0 +1,40 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-sloppy + +description('Tests for calling the constructors of ES6 classes'); + +class A { constructor() {} }; +class B extends A { constructor() { super() } }; + +shouldNotThrow('new A'); +shouldThrow('A()', '"TypeError: Class constructors cannot be invoked without \'new\'"'); +shouldNotThrow('new B'); +shouldThrow('B()', '"TypeError: Class constructors cannot be invoked without \'new\'"'); +shouldNotThrow('new (class { constructor() {} })()'); +shouldThrow('(class { constructor() {} })()', '"TypeError: Class constructors cannot be invoked without \'new\'"'); +shouldThrow('new (class extends null { constructor() { super() } })()', '"TypeError: function () {} is not a constructor"'); +shouldThrow('(class extends null { constructor() { super() } })()', '"TypeError: Class constructors cannot be invoked without \'new\'"'); + +var successfullyParsed = true; diff --git a/deps/v8/test/webkit/class-syntax-declaration-expected.txt b/deps/v8/test/webkit/class-syntax-declaration-expected.txt new file mode 100644 index 0000000000..f1466c5114 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-declaration-expected.txt @@ -0,0 +1,43 @@ +Tests for ES6 class syntax declarations + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS constructorCallCount is 0 +PASS A.someStaticMethod() is staticMethodValue +PASS A.someStaticGetter is getterValue +PASS setterValue = undefined; A.someStaticSetter = 123; setterValue is 123 +PASS (new A).someInstanceMethod() is instanceMethodValue +PASS constructorCallCount is 1 +PASS (new A).someGetter is getterValue +PASS constructorCallCount is 2 +PASS (new A).someGetter is getterValue +PASS setterValue = undefined; (new A).someSetter = 789; setterValue is 789 +PASS (new A).__proto__ is A.prototype +PASS A.prototype.constructor is A +PASS class threw exception SyntaxError: Unexpected end of input. +PASS class [ threw exception SyntaxError: Unexpected token [. +PASS class { threw exception SyntaxError: Unexpected token {. +PASS class X { threw exception SyntaxError: Unexpected end of input. +PASS class X { ( } threw exception SyntaxError: Unexpected token (. +PASS class X {} did not throw exception. +PASS class X { constructor() {} constructor() {} } threw exception SyntaxError: A class may only have one constructor. +PASS class X { get constructor() {} } threw exception SyntaxError: Class constructor may not be an accessor. +PASS class X { set constructor() {} } threw exception SyntaxError: Class constructor may not be an accessor. +PASS class X { constructor() {} static constructor() { return staticMethodValue; } } did not throw exception. +PASS class X { constructor() {} static constructor() { return staticMethodValue; } }; X.constructor() is staticMethodValue +PASS class X { constructor() {} static prototype() {} } threw exception SyntaxError: Classes may not have static property named prototype. +PASS class X { constructor() {} static get prototype() {} } threw exception SyntaxError: Classes may not have static property named prototype. +PASS class X { constructor() {} static set prototype() {} } threw exception SyntaxError: Classes may not have static property named prototype. +PASS class X { constructor() {} prototype() { return instanceMethodValue; } } did not throw exception. +PASS class X { constructor() {} prototype() { return instanceMethodValue; } }; (new X).prototype() is instanceMethodValue +PASS class X { constructor() {} set foo(a) {} } did not throw exception. +FAIL class X { constructor() {} set foo({x, y}) {} } should not throw exception. Threw exception SyntaxError: Unexpected token {. +PASS class X { constructor() {} set foo() {} } threw exception SyntaxError: Setter must have exactly one formal parameter.. +PASS class X { constructor() {} set foo(a, b) {} } threw exception SyntaxError: Setter must have exactly one formal parameter.. +PASS class X { constructor() {} get foo() {} } did not throw exception. +PASS class X { constructor() {} get foo(x) {} } threw exception SyntaxError: Getter must not have any formal parameters.. +PASS class X { constructor() {} get foo({x, y}) {} } threw exception SyntaxError: Unexpected token {. +PASS successfullyParsed is true + +TEST COMPLETE diff --git a/deps/v8/test/webkit/class-syntax-declaration.js b/deps/v8/test/webkit/class-syntax-declaration.js new file mode 100644 index 0000000000..3c9aed7441 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-declaration.js @@ -0,0 +1,83 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-sloppy + +description('Tests for ES6 class syntax declarations'); + +var constructorCallCount = 0; +const staticMethodValue = [1]; +const instanceMethodValue = [2]; +const getterValue = [3]; +var setterValue = undefined; +class A { + constructor() { constructorCallCount++; } + static someStaticMethod() { return staticMethodValue; } + static get someStaticGetter() { return getterValue; } + static set someStaticSetter(value) { setterValue = value; } + someInstanceMethod() { return instanceMethodValue; } + get someGetter() { return getterValue; } + set someSetter(value) { setterValue = value; } +} + +shouldBe("constructorCallCount", "0"); +shouldBe("A.someStaticMethod()", "staticMethodValue"); +shouldBe("A.someStaticGetter", "getterValue"); +shouldBe("setterValue = undefined; A.someStaticSetter = 123; setterValue", "123"); +shouldBe("(new A).someInstanceMethod()", "instanceMethodValue"); +shouldBe("constructorCallCount", "1"); +shouldBe("(new A).someGetter", "getterValue"); +shouldBe("constructorCallCount", "2"); +shouldBe("(new A).someGetter", "getterValue"); +shouldBe("setterValue = undefined; (new A).someSetter = 789; setterValue", "789"); +shouldBe("(new A).__proto__", "A.prototype"); +shouldBe("A.prototype.constructor", "A"); + +shouldThrow("class", "'SyntaxError: Unexpected end of input'"); +shouldThrow("class [", "'SyntaxError: Unexpected token ['"); +shouldThrow("class {", "'SyntaxError: Unexpected token {'"); +shouldThrow("class X {", "'SyntaxError: Unexpected end of input'"); +shouldThrow("class X { ( }", "'SyntaxError: Unexpected token ('"); +shouldNotThrow("class X {}"); + +shouldThrow("class X { constructor() {} constructor() {} }", "'SyntaxError: A class may only have one constructor'"); +shouldThrow("class X { get constructor() {} }", "'SyntaxError: Class constructor may not be an accessor'"); +shouldThrow("class X { set constructor() {} }", "'SyntaxError: Class constructor may not be an accessor'"); +shouldNotThrow("class X { constructor() {} static constructor() { return staticMethodValue; } }"); +shouldBe("class X { constructor() {} static constructor() { return staticMethodValue; } }; X.constructor()", "staticMethodValue"); + +shouldThrow("class X { constructor() {} static prototype() {} }", "'SyntaxError: Classes may not have static property named prototype'"); +shouldThrow("class X { constructor() {} static get prototype() {} }", "'SyntaxError: Classes may not have static property named prototype'"); +shouldThrow("class X { constructor() {} static set prototype() {} }", "'SyntaxError: Classes may not have static property named prototype'"); +shouldNotThrow("class X { constructor() {} prototype() { return instanceMethodValue; } }"); +shouldBe("class X { constructor() {} prototype() { return instanceMethodValue; } }; (new X).prototype()", "instanceMethodValue"); + +shouldNotThrow("class X { constructor() {} set foo(a) {} }"); +shouldNotThrow("class X { constructor() {} set foo({x, y}) {} }"); +shouldThrow("class X { constructor() {} set foo() {} }"); +shouldThrow("class X { constructor() {} set foo(a, b) {} }"); +shouldNotThrow("class X { constructor() {} get foo() {} }"); +shouldThrow("class X { constructor() {} get foo(x) {} }"); +shouldThrow("class X { constructor() {} get foo({x, y}) {} }"); + +var successfullyParsed = true; diff --git a/deps/v8/test/webkit/class-syntax-default-constructor-expected.txt b/deps/v8/test/webkit/class-syntax-default-constructor-expected.txt new file mode 100644 index 0000000000..b08e7f0a1e --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-default-constructor-expected.txt @@ -0,0 +1,18 @@ +Tests for ES6 class syntax default constructor + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS new A instanceof A is true +PASS A() threw exception TypeError: Class constructors cannot be invoked without 'new'. +PASS A.prototype.constructor instanceof Function is true +PASS A.prototype.constructor.name is "A" +PASS new B instanceof A; new B instanceof A is true +PASS B() threw exception TypeError: Class constructors cannot be invoked without 'new'. +PASS B.prototype.constructor.name is "B" +PASS A !== B is true +PASS A.prototype.constructor !== B.prototype.constructor is true +PASS new (class extends (class { constructor(a, b) { return [a, b]; } }) {})(1, 2) is [1, 2] +PASS successfullyParsed is true + +TEST COMPLETE diff --git a/deps/v8/test/webkit/class-syntax-default-constructor.js b/deps/v8/test/webkit/class-syntax-default-constructor.js new file mode 100644 index 0000000000..841afddadc --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-default-constructor.js @@ -0,0 +1,42 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-sloppy + +description('Tests for ES6 class syntax default constructor'); + +class A { }; +class B extends A { }; + +shouldBeTrue('new A instanceof A'); +shouldThrow('A()', '"TypeError: Class constructors cannot be invoked without \'new\'"'); +shouldBeTrue('A.prototype.constructor instanceof Function'); +shouldBe('A.prototype.constructor.name', '"A"'); +shouldBeTrue('new B instanceof A; new B instanceof A'); +shouldThrow('B()', '"TypeError: Class constructors cannot be invoked without \'new\'"'); +shouldBe('B.prototype.constructor.name', '"B"'); +shouldBeTrue('A !== B'); +shouldBeTrue('A.prototype.constructor !== B.prototype.constructor'); +shouldBe('new (class extends (class { constructor(a, b) { return [a, b]; } }) {})(1, 2)', '[1, 2]'); + +var successfullyParsed = true; diff --git a/deps/v8/test/webkit/class-syntax-expression-expected.txt b/deps/v8/test/webkit/class-syntax-expression-expected.txt new file mode 100644 index 0000000000..aa1cfb76b0 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-expression-expected.txt @@ -0,0 +1,41 @@ +Tests for ES6 class syntax expressions + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS constructorCallCount is 0 +PASS A.someStaticMethod() is staticMethodValue +PASS A.someStaticGetter is getterValue +PASS setterValue = undefined; A.someStaticSetter = 123; setterValue is 123 +PASS (new A).someInstanceMethod() is instanceMethodValue +PASS constructorCallCount is 1 +PASS (new A).someGetter is getterValue +PASS constructorCallCount is 2 +PASS (new A).someGetter is getterValue +PASS setterValue = undefined; (new A).someSetter = 789; setterValue is 789 +PASS (new A).__proto__ is A.prototype +PASS A.prototype.constructor is A +PASS x = class threw exception SyntaxError: Unexpected end of input. +PASS x = class { threw exception SyntaxError: Unexpected end of input. +PASS x = class { ( } threw exception SyntaxError: Unexpected token (. +PASS x = class {} did not throw exception. +PASS x = class { constructor() {} constructor() {} } threw exception SyntaxError: A class may only have one constructor. +PASS x = class { get constructor() {} } threw exception SyntaxError: Class constructor may not be an accessor. +PASS x = class { set constructor() {} } threw exception SyntaxError: Class constructor may not be an accessor. +PASS x = class { constructor() {} static constructor() { return staticMethodValue; } } did not throw exception. +PASS x = class { constructor() {} static constructor() { return staticMethodValue; } }; x.constructor() is staticMethodValue +PASS x = class { constructor() {} static prototype() {} } threw exception SyntaxError: Classes may not have static property named prototype. +PASS x = class { constructor() {} static get prototype() {} } threw exception SyntaxError: Classes may not have static property named prototype. +PASS x = class { constructor() {} static set prototype() {} } threw exception SyntaxError: Classes may not have static property named prototype. +PASS x = class { constructor() {} prototype() { return instanceMethodValue; } } did not throw exception. +PASS x = class { constructor() {} prototype() { return instanceMethodValue; } }; (new x).prototype() is instanceMethodValue +PASS x = class { constructor() {} set foo(a) {} } did not throw exception. +FAIL x = class { constructor() {} set foo({x, y}) {} } should not throw exception. Threw exception SyntaxError: Unexpected token {. +PASS x = class { constructor() {} set foo() {} } threw exception SyntaxError: Setter must have exactly one formal parameter.. +PASS x = class { constructor() {} set foo(a, b) {} } threw exception SyntaxError: Setter must have exactly one formal parameter.. +PASS x = class { constructor() {} get foo() {} } did not throw exception. +PASS x = class { constructor() {} get foo(x) {} } threw exception SyntaxError: Getter must not have any formal parameters.. +PASS x = class { constructor() {} get foo({x, y}) {} } threw exception SyntaxError: Unexpected token {. +PASS successfullyParsed is true + +TEST COMPLETE diff --git a/deps/v8/test/webkit/class-syntax-expression.js b/deps/v8/test/webkit/class-syntax-expression.js new file mode 100644 index 0000000000..3272b81f7e --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-expression.js @@ -0,0 +1,81 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-sloppy + +description('Tests for ES6 class syntax expressions'); + +var constructorCallCount = 0; +const staticMethodValue = [1]; +const instanceMethodValue = [2]; +const getterValue = [3]; +var setterValue = undefined; +var A = class { + constructor() { constructorCallCount++; } + static someStaticMethod() { return staticMethodValue; } + static get someStaticGetter() { return getterValue; } + static set someStaticSetter(value) { setterValue = value; } + someInstanceMethod() { return instanceMethodValue; } + get someGetter() { return getterValue; } + set someSetter(value) { setterValue = value; } +}; + +shouldBe("constructorCallCount", "0"); +shouldBe("A.someStaticMethod()", "staticMethodValue"); +shouldBe("A.someStaticGetter", "getterValue"); +shouldBe("setterValue = undefined; A.someStaticSetter = 123; setterValue", "123"); +shouldBe("(new A).someInstanceMethod()", "instanceMethodValue"); +shouldBe("constructorCallCount", "1"); +shouldBe("(new A).someGetter", "getterValue"); +shouldBe("constructorCallCount", "2"); +shouldBe("(new A).someGetter", "getterValue"); +shouldBe("setterValue = undefined; (new A).someSetter = 789; setterValue", "789"); +shouldBe("(new A).__proto__", "A.prototype"); +shouldBe("A.prototype.constructor", "A"); + +shouldThrow("x = class", "'SyntaxError: Unexpected end of input'"); +shouldThrow("x = class {", "'SyntaxError: Unexpected end of input'"); +shouldThrow("x = class { ( }", "'SyntaxError: Unexpected token ('"); +shouldNotThrow("x = class {}"); + +shouldThrow("x = class { constructor() {} constructor() {} }", "'SyntaxError: A class may only have one constructor'"); +shouldThrow("x = class { get constructor() {} }", "'SyntaxError: Class constructor may not be an accessor'"); +shouldThrow("x = class { set constructor() {} }", "'SyntaxError: Class constructor may not be an accessor'"); +shouldNotThrow("x = class { constructor() {} static constructor() { return staticMethodValue; } }"); +shouldBe("x = class { constructor() {} static constructor() { return staticMethodValue; } }; x.constructor()", "staticMethodValue"); + +shouldThrow("x = class { constructor() {} static prototype() {} }", "'SyntaxError: Classes may not have static property named prototype'"); +shouldThrow("x = class { constructor() {} static get prototype() {} }", "'SyntaxError: Classes may not have static property named prototype'"); +shouldThrow("x = class { constructor() {} static set prototype() {} }", "'SyntaxError: Classes may not have static property named prototype'"); +shouldNotThrow("x = class { constructor() {} prototype() { return instanceMethodValue; } }"); +shouldBe("x = class { constructor() {} prototype() { return instanceMethodValue; } }; (new x).prototype()", "instanceMethodValue"); + +shouldNotThrow("x = class { constructor() {} set foo(a) {} }"); +shouldNotThrow("x = class { constructor() {} set foo({x, y}) {} }"); +shouldThrow("x = class { constructor() {} set foo() {} }"); +shouldThrow("x = class { constructor() {} set foo(a, b) {} }"); +shouldNotThrow("x = class { constructor() {} get foo() {} }"); +shouldThrow("x = class { constructor() {} get foo(x) {} }"); +shouldThrow("x = class { constructor() {} get foo({x, y}) {} }"); + +var successfullyParsed = true; diff --git a/deps/v8/test/webkit/class-syntax-extends-expected.txt b/deps/v8/test/webkit/class-syntax-extends-expected.txt new file mode 100644 index 0000000000..b3b4c8ee60 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-extends-expected.txt @@ -0,0 +1,72 @@ +Tests for ES6 class syntax "extends" + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS (new Base) instanceof Base is true +PASS Object.getPrototypeOf(new Base) is Base.prototype +PASS (new Derived) instanceof Derived is true +PASS Object.getPrototypeOf(new Derived) is Derived.prototype +PASS Object.getPrototypeOf(Derived.prototype) is Base.prototype +PASS (new Derived).baseMethod() is "base" +PASS (new Derived).overridenMethod() is "derived" +PASS Derived.staticBaseMethod() is "base" +PASS Derived.staticOverridenMethod() is "derived" +PASS x = class extends threw exception SyntaxError: Unexpected end of input. +PASS x = class extends threw exception SyntaxError: Unexpected end of input. +PASS x = class extends Base { threw exception SyntaxError: Unexpected end of input. +PASS x = class extends Base { } did not throw exception. +PASS x = class extends Base { constructor() { } } did not throw exception. +PASS x.__proto__ is Base +PASS Object.getPrototypeOf(x) is Base +PASS x.prototype.__proto__ is Base.prototype +PASS Object.getPrototypeOf(x.prototype) is Base.prototype +PASS x = class extends null { constructor() { } }; x.__proto__ is Function.prototype +PASS x.__proto__ is Function.prototype +PASS x = class extends 3 { constructor() { } }; x.__proto__ threw exception TypeError: Class extends value 3 is not a function or null. +PASS x = class extends "abc" { constructor() { } }; x.__proto__ threw exception TypeError: Class extends value abc is not a function or null. +PASS baseWithBadPrototype = function () {}; baseWithBadPrototype.prototype = 3; new baseWithBadPrototype did not throw exception. +PASS x = class extends baseWithBadPrototype { constructor() { } } threw exception TypeError: Class extends value does not have valid prototype property 3. +PASS baseWithBadPrototype.prototype = "abc" did not throw exception. +PASS x = class extends baseWithBadPrototype { constructor() { } } threw exception TypeError: Class extends value does not have valid prototype property abc. +PASS baseWithBadPrototype.prototype = null; x = class extends baseWithBadPrototype { constructor() { } } did not throw exception. +PASS x = 1; c = class extends ++x { constructor() { } }; threw exception SyntaxError: Unexpected token ++. +PASS x = 1; c = class extends x++ { constructor() { } }; threw exception SyntaxError: Unexpected token ++. +PASS x = 1; c = class extends (++x) { constructor() { } }; threw exception TypeError: Class extends value 2 is not a function or null. +PASS x = 1; c = class extends (x++) { constructor() { } }; threw exception TypeError: Class extends value 1 is not a function or null. +PASS x = 1; try { c = class extends (++x) { constructor() { } } } catch (e) { }; x is 2 +PASS x = 1; try { c = class extends (x++) { constructor() { } } } catch (e) { }; x is 2 +PASS namespace = {}; namespace.A = class { }; namespace.B = class extends namespace.A { } did not throw exception. +PASS namespace = {}; namespace.A = class A { }; namespace.B = class B extends namespace.A { } did not throw exception. +PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends namespace.A { constructor() { } } did not throw exception. +PASS namespace = {}; namespace.A = class A { constructor() { } }; namespace.B = class B extends namespace.A { constructor() { } } did not throw exception. +PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (namespace.A) { constructor() { } } did not throw exception. +PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends namespace["A"] { constructor() { } } did not throw exception. +PASS namespace = {}; namespace.A = class { constructor() { } }; function getClassA() { return namespace.A }; namespace.B = class extends getClassA() { constructor() { } } did not throw exception. +PASS namespace = {}; namespace.A = class { constructor() { } }; function getClass(prop) { return namespace[prop] }; namespace.B = class extends getClass("A") { constructor() { } } did not throw exception. +PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (false||null||namespace.A) { constructor() { } } did not throw exception. +PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends false||null||namespace.A { constructor() { } } threw exception SyntaxError: Unexpected token ||. +PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (x++, namespace.A) { constructor() { } }; did not throw exception. +PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (namespace.A, x++) { constructor() { } }; threw exception TypeError: Class extends value 1 is not a function or null. +PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends new namespace.A { constructor() { } } threw exception TypeError: Class extends value [object Object] is not a function or null. +PASS namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends new namespace.A() { constructor() { } } threw exception TypeError: Class extends value [object Object] is not a function or null. +PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; try { namespace.B = class extends (x++, namespace.A) { constructor() { } } } catch (e) { } x is 2 +PASS x = 1; namespace = {}; namespace.A = class { constructor() { } }; try { namespace.B = class extends (namespace.A, x++) { constructor() { } } } catch (e) { } x is 2 +PASS Object.getPrototypeOf((class { constructor () { } }).prototype) is Object.prototype +PASS Object.getPrototypeOf((class extends null { constructor () { super(); } }).prototype) is null +PASS new (class extends undefined { constructor () { this } }) threw exception TypeError: Class extends value undefined is not a function or null. +PASS new (class extends undefined { constructor () { super(); } }) threw exception TypeError: Class extends value undefined is not a function or null. +PASS x = {}; new (class extends undefined { constructor () { return x; } }) threw exception TypeError: Class extends value undefined is not a function or null. +PASS y = 12; new (class extends undefined { constructor () { return y; } }) threw exception TypeError: Class extends value undefined is not a function or null. +FAIL class x {}; new (class extends null { constructor () { return new x; } }) instanceof x should be true. Threw exception TypeError: x is not a function +PASS new (class extends null { constructor () { this; } }) threw exception ReferenceError: this is not defined. +PASS new (class extends null { constructor () { super(); } }) threw exception TypeError: function () {} is not a constructor. +PASS x = {}; new (class extends null { constructor () { return x } }) is x +PASS y = 12; new (class extends null { constructor () { return y; } }) threw exception TypeError: Derived constructors may only return object or undefined. +FAIL class x {}; new (class extends null { constructor () { return new x; } }) instanceof x should be true. Threw exception TypeError: x is not a function +PASS x = null; Object.getPrototypeOf((class extends x { }).prototype) is null +PASS Object.prototype.isPrototypeOf(class { }) is true +PASS Function.prototype.isPrototypeOf(class { }) is true +PASS successfullyParsed is true + +TEST COMPLETE diff --git a/deps/v8/test/webkit/class-syntax-extends.js b/deps/v8/test/webkit/class-syntax-extends.js new file mode 100644 index 0000000000..3c7ee19cef --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-extends.js @@ -0,0 +1,111 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-sloppy + +description('Tests for ES6 class syntax "extends"'); + +class Base { + constructor() { } + baseMethod() { return 'base'; } + overridenMethod() { return 'base'; } + static staticBaseMethod() { return 'base'; } + static staticOverridenMethod() { return 'base'; } +} + +class Derived extends Base { + constructor() { super(); } + overridenMethod() { return 'derived'; } + static staticOverridenMethod() { return 'derived'; } +} + +shouldBeTrue('(new Base) instanceof Base'); +shouldBe('Object.getPrototypeOf(new Base)', 'Base.prototype'); +shouldBeTrue('(new Derived) instanceof Derived'); +shouldBe('Object.getPrototypeOf(new Derived)', 'Derived.prototype'); +shouldBe('Object.getPrototypeOf(Derived.prototype)', 'Base.prototype'); +shouldBe('(new Derived).baseMethod()', '"base"'); +shouldBe('(new Derived).overridenMethod()', '"derived"'); +shouldBe('Derived.staticBaseMethod()', '"base"'); +shouldBe('Derived.staticOverridenMethod()', '"derived"'); + +shouldThrow('x = class extends', '"SyntaxError: Unexpected end of input"'); +shouldThrow('x = class extends', '"SyntaxError: Unexpected end of input"'); +shouldThrow('x = class extends Base {', '"SyntaxError: Unexpected end of input"'); +shouldNotThrow('x = class extends Base { }'); +shouldNotThrow('x = class extends Base { constructor() { } }'); +shouldBe('x.__proto__', 'Base'); +shouldBe('Object.getPrototypeOf(x)', 'Base'); +shouldBe('x.prototype.__proto__', 'Base.prototype'); +shouldBe('Object.getPrototypeOf(x.prototype)', 'Base.prototype'); +shouldBe('x = class extends null { constructor() { } }; x.__proto__', 'Function.prototype'); +shouldBe('x.__proto__', 'Function.prototype'); +shouldThrow('x = class extends 3 { constructor() { } }; x.__proto__', '"TypeError: Class extends value 3 is not a function or null"'); +shouldThrow('x = class extends "abc" { constructor() { } }; x.__proto__', '"TypeError: Class extends value abc is not a function or null"'); +shouldNotThrow('baseWithBadPrototype = function () {}; baseWithBadPrototype.prototype = 3; new baseWithBadPrototype'); +shouldThrow('x = class extends baseWithBadPrototype { constructor() { } }', '"TypeError: Class extends value does not have valid prototype property 3"'); +shouldNotThrow('baseWithBadPrototype.prototype = "abc"'); +shouldThrow('x = class extends baseWithBadPrototype { constructor() { } }', '"TypeError: Class extends value does not have valid prototype property abc"'); +shouldNotThrow('baseWithBadPrototype.prototype = null; x = class extends baseWithBadPrototype { constructor() { } }'); + +shouldThrow('x = 1; c = class extends ++x { constructor() { } };'); +shouldThrow('x = 1; c = class extends x++ { constructor() { } };'); +shouldThrow('x = 1; c = class extends (++x) { constructor() { } };'); +shouldThrow('x = 1; c = class extends (x++) { constructor() { } };'); +shouldBe('x = 1; try { c = class extends (++x) { constructor() { } } } catch (e) { }; x', '2'); +shouldBe('x = 1; try { c = class extends (x++) { constructor() { } } } catch (e) { }; x', '2'); + +shouldNotThrow('namespace = {}; namespace.A = class { }; namespace.B = class extends namespace.A { }'); +shouldNotThrow('namespace = {}; namespace.A = class A { }; namespace.B = class B extends namespace.A { }'); +shouldNotThrow('namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends namespace.A { constructor() { } }'); +shouldNotThrow('namespace = {}; namespace.A = class A { constructor() { } }; namespace.B = class B extends namespace.A { constructor() { } }'); +shouldNotThrow('namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (namespace.A) { constructor() { } }'); +shouldNotThrow('namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends namespace["A"] { constructor() { } }'); +shouldNotThrow('namespace = {}; namespace.A = class { constructor() { } }; function getClassA() { return namespace.A }; namespace.B = class extends getClassA() { constructor() { } }'); +shouldNotThrow('namespace = {}; namespace.A = class { constructor() { } }; function getClass(prop) { return namespace[prop] }; namespace.B = class extends getClass("A") { constructor() { } }'); +shouldNotThrow('namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (false||null||namespace.A) { constructor() { } }'); +shouldThrow('namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends false||null||namespace.A { constructor() { } }'); +shouldNotThrow('x = 1; namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (x++, namespace.A) { constructor() { } };'); +shouldThrow('x = 1; namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends (namespace.A, x++) { constructor() { } };'); +shouldThrow('namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends new namespace.A { constructor() { } }'); +shouldThrow('namespace = {}; namespace.A = class { constructor() { } }; namespace.B = class extends new namespace.A() { constructor() { } }'); +shouldBe('x = 1; namespace = {}; namespace.A = class { constructor() { } }; try { namespace.B = class extends (x++, namespace.A) { constructor() { } } } catch (e) { } x', '2'); +shouldBe('x = 1; namespace = {}; namespace.A = class { constructor() { } }; try { namespace.B = class extends (namespace.A, x++) { constructor() { } } } catch (e) { } x', '2'); + +shouldBe('Object.getPrototypeOf((class { constructor () { } }).prototype)', 'Object.prototype'); +shouldBe('Object.getPrototypeOf((class extends null { constructor () { super(); } }).prototype)', 'null'); +shouldThrow('new (class extends undefined { constructor () { this } })', '"TypeError: Class extends value undefined is not a function or null"'); +shouldThrow('new (class extends undefined { constructor () { super(); } })', '"TypeError: Class extends value undefined is not a function or null"'); +shouldThrow('x = {}; new (class extends undefined { constructor () { return x; } })', '"TypeError: Class extends value undefined is not a function or null"'); +shouldThrow('y = 12; new (class extends undefined { constructor () { return y; } })', '"TypeError: Class extends value undefined is not a function or null"'); +shouldBeTrue ('class x {}; new (class extends null { constructor () { return new x; } }) instanceof x'); +shouldThrow('new (class extends null { constructor () { this; } })', '"ReferenceError: this is not defined"'); +shouldThrow('new (class extends null { constructor () { super(); } })', '"TypeError: function () {} is not a constructor"'); +shouldBe('x = {}; new (class extends null { constructor () { return x } })', 'x'); +shouldThrow('y = 12; new (class extends null { constructor () { return y; } })', '"TypeError: Derived constructors may only return object or undefined"'); +shouldBeTrue ('class x {}; new (class extends null { constructor () { return new x; } }) instanceof x'); +shouldBe('x = null; Object.getPrototypeOf((class extends x { }).prototype)', 'null'); +shouldBeTrue('Object.prototype.isPrototypeOf(class { })'); +shouldBeTrue('Function.prototype.isPrototypeOf(class { })'); + +var successfullyParsed = true; diff --git a/deps/v8/test/webkit/class-syntax-name-expected.txt b/deps/v8/test/webkit/class-syntax-name-expected.txt new file mode 100644 index 0000000000..10f38ff2c2 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-name-expected.txt @@ -0,0 +1,125 @@ +Tests for ES6 class name semantics in class statements and expressions + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Class statement +PASS A threw exception ReferenceError: A is not defined. +PASS 'use strict'; A threw exception ReferenceError: A is not defined. +PASS class {} threw exception SyntaxError: Unexpected token {. +PASS 'use strict'; class {} threw exception SyntaxError: Unexpected token {. +PASS class { constructor() {} } threw exception SyntaxError: Unexpected token {. +PASS 'use strict'; class { constructor() {} } threw exception SyntaxError: Unexpected token {. +PASS class A { constructor() {} } did not throw exception. +PASS 'use strict'; class A { constructor() {} } did not throw exception. +PASS class A { constructor() {} }; A.toString() is 'class A { constructor() {} }' +PASS 'use strict'; class A { constructor() {} }; A.toString() is 'class A { constructor() {} }' +PASS class A { constructor() {} }; (new A) instanceof A is true +PASS 'use strict'; class A { constructor() {} }; (new A) instanceof A is true +PASS class A { constructor() { this.base = A; } }; (new A).base.toString() is 'class A { constructor() { this.base = A; } }' +PASS 'use strict'; class A { constructor() { this.base = A; } }; (new A).base.toString() is 'class A { constructor() { this.base = A; } }' +PASS class A { constructor() {} }; class B extends A {}; did not throw exception. +PASS 'use strict'; class A { constructor() {} }; class B extends A {}; did not throw exception. +PASS class A { constructor() {} }; class B extends A { constructor() {} }; B.toString() is 'class B extends A { constructor() {} }' +PASS 'use strict'; class A { constructor() {} }; class B extends A { constructor() {} }; B.toString() is 'class B extends A { constructor() {} }' +PASS class A { constructor() {} }; class B extends A {}; (new B) instanceof A is true +PASS 'use strict'; class A { constructor() {} }; class B extends A {}; (new B) instanceof A is true +PASS class A { constructor() {} }; class B extends A {}; (new B) instanceof B is true +PASS 'use strict'; class A { constructor() {} }; class B extends A {}; (new B) instanceof B is true +PASS class A { constructor() {} }; class B extends A { constructor() { super(); this.base = A; this.derived = B; } }; (new B).base.toString() is 'class A { constructor() {} }' +PASS 'use strict'; class A { constructor() {} }; class B extends A { constructor() { super(); this.base = A; this.derived = B; } }; (new B).base.toString() is 'class A { constructor() {} }' +PASS class A { constructor() {} }; class B extends A { constructor() { super(); this.base = A; this.derived = B; } }; (new B).derived.toString() is 'class B extends A { constructor() { super(); this.base = A; this.derived = B; } }' +PASS 'use strict'; class A { constructor() {} }; class B extends A { constructor() { super(); this.base = A; this.derived = B; } }; (new B).derived.toString() is 'class B extends A { constructor() { super(); this.base = A; this.derived = B; } }' + +Class expression +PASS A threw exception ReferenceError: A is not defined. +PASS 'use strict'; A threw exception ReferenceError: A is not defined. +PASS (class {}) did not throw exception. +PASS 'use strict'; (class {}) did not throw exception. +PASS (class { constructor(){} }) did not throw exception. +PASS 'use strict'; (class { constructor(){} }) did not throw exception. +PASS typeof (class {}) is "function" +PASS 'use strict'; typeof (class {}) is "function" +PASS (class A {}) did not throw exception. +PASS 'use strict'; (class A {}) did not throw exception. +PASS typeof (class A {}) is "function" +PASS 'use strict'; typeof (class A {}) is "function" +PASS (class A {}); A threw exception ReferenceError: A is not defined. +PASS 'use strict'; (class A {}); A threw exception ReferenceError: A is not defined. +PASS new (class A {}) did not throw exception. +PASS 'use strict'; new (class A {}) did not throw exception. +PASS typeof (new (class A {})) is "object" +PASS 'use strict'; typeof (new (class A {})) is "object" +PASS (new (class A { constructor() { this.base = A; } })).base did not throw exception. +PASS 'use strict'; (new (class A { constructor() { this.base = A; } })).base did not throw exception. +PASS (new (class A { constructor() { this.base = A; } })).base.toString() is "class A { constructor() { this.base = A; } }" +PASS 'use strict'; (new (class A { constructor() { this.base = A; } })).base.toString() is "class A { constructor() { this.base = A; } }" +PASS class A {}; (class B extends A {}) did not throw exception. +PASS 'use strict'; class A {}; (class B extends A {}) did not throw exception. +PASS class A {}; (class B extends A {}); B threw exception ReferenceError: B is not defined. +PASS 'use strict'; class A {}; (class B extends A {}); B threw exception ReferenceError: B is not defined. +PASS class A {}; new (class B extends A {}) did not throw exception. +PASS 'use strict'; class A {}; new (class B extends A {}) did not throw exception. +PASS class A {}; new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } }) did not throw exception. +PASS 'use strict'; class A {}; new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } }) did not throw exception. +PASS class A {}; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })) instanceof A is true +PASS 'use strict'; class A {}; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })) instanceof A is true +PASS class A { constructor() {} }; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })).base.toString() is 'class A { constructor() {} }' +PASS 'use strict'; class A { constructor() {} }; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })).base.toString() is 'class A { constructor() {} }' +PASS class A { constructor() {} }; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })).derived.toString() is 'class B extends A { constructor() { super(); this.base = A; this.derived = B; } }' +PASS 'use strict'; class A { constructor() {} }; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })).derived.toString() is 'class B extends A { constructor() { super(); this.base = A; this.derived = B; } }' + +Class expression assignment to variable +PASS A threw exception ReferenceError: A is not defined. +PASS 'use strict'; A threw exception ReferenceError: A is not defined. +PASS var VarA = class {} did not throw exception. +PASS 'use strict'; var VarA = class {} did not throw exception. +PASS var VarA = class { constructor() {} }; VarA.toString() is 'class { constructor() {} }' +PASS 'use strict'; var VarA = class { constructor() {} }; VarA.toString() is 'class { constructor() {} }' +PASS VarA threw exception ReferenceError: VarA is not defined. +PASS 'use strict'; VarA threw exception ReferenceError: VarA is not defined. +PASS var VarA = class A { constructor() {} } did not throw exception. +PASS 'use strict'; var VarA = class A { constructor() {} } did not throw exception. +PASS var VarA = class A { constructor() {} }; VarA.toString() is 'class A { constructor() {} }' +PASS 'use strict'; var VarA = class A { constructor() {} }; VarA.toString() is 'class A { constructor() {} }' +PASS var VarA = class A { constructor() {} }; A.toString() threw exception ReferenceError: A is not defined. +PASS 'use strict'; var VarA = class A { constructor() {} }; A.toString() threw exception ReferenceError: A is not defined. +PASS var VarA = class A { constructor() {} }; (new VarA) instanceof VarA is true +PASS 'use strict'; var VarA = class A { constructor() {} }; (new VarA) instanceof VarA is true +PASS var VarA = class A { constructor() { this.base = A; } }; (new VarA).base.toString() is 'class A { constructor() { this.base = A; } }' +PASS 'use strict'; var VarA = class A { constructor() { this.base = A; } }; (new VarA).base.toString() is 'class A { constructor() { this.base = A; } }' +PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; did not throw exception. +PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; did not throw exception. +PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; B threw exception ReferenceError: B is not defined. +PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; B threw exception ReferenceError: B is not defined. +PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; VarB.toString() is 'class B extends VarA { constructor() {} }' +PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; VarB.toString() is 'class B extends VarA { constructor() {} }' +PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { }; (new VarB) instanceof VarA is true +PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { }; (new VarB) instanceof VarA is true +PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { }; (new VarB) instanceof VarB is true +PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { }; (new VarB) instanceof VarB is true +PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).base === VarA is true +PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).base === VarA is true +PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).derived === VarB is true +PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).derived === VarB is true +PASS var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).derivedVar === VarB is true +PASS 'use strict'; var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).derivedVar === VarB is true + +Class statement binding in other circumstances +PASS var result = A; result threw exception ReferenceError: A is not defined. +PASS 'use strict'; var result = A; result threw exception ReferenceError: A is not defined. +FAIL var result = A; class A {}; result should throw an exception. Was undefined. +PASS 'use strict'; var result = A; class A {}; result threw exception ReferenceError: A is not defined. +PASS class A { constructor() { A = 1; } }; new A threw exception TypeError: Assignment to constant variable.. +PASS 'use strict'; class A { constructor() { A = 1; } }; new A threw exception TypeError: Assignment to constant variable.. +PASS class A { constructor() { } }; A = 1; A is 1 +PASS 'use strict'; class A { constructor() { } }; A = 1; A is 1 +PASS class A {}; var result = A; result did not throw exception. +PASS 'use strict'; class A {}; var result = A; result did not throw exception. +PASS eval('var Foo = 10'); Foo is 10 +PASS 'use strict'; eval('var Foo = 10'); Foo threw exception ReferenceError: Foo is not defined. +PASS eval('class Bar { constructor() {} }'); Bar.toString() is 'class Bar { constructor() {} }' +PASS 'use strict'; eval('class Bar { constructor() {} }'); Bar.toString() threw exception ReferenceError: Bar is not defined. +PASS successfullyParsed is true + +TEST COMPLETE diff --git a/deps/v8/test/webkit/class-syntax-name.js b/deps/v8/test/webkit/class-syntax-name.js new file mode 100644 index 0000000000..09faa3a54a --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-name.js @@ -0,0 +1,115 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-sloppy + +description('Tests for ES6 class name semantics in class statements and expressions'); + +function runTestShouldBe(statement, result) { + shouldBe(statement, result); + shouldBe("'use strict'; " + statement, result); +} + +function runTestShouldBeTrue(statement) { + shouldBeTrue(statement); + shouldBeTrue("'use strict'; " + statement); +} + +function runTestShouldThrow(statement) { + shouldThrow(statement); + shouldThrow("'use strict'; " + statement); +} + +function runTestShouldNotThrow(statement) { + shouldNotThrow(statement); + shouldNotThrow("'use strict'; " + statement); +} + +// Class statement. Class name added to global scope. Class name is available inside class scope and in global scope. +debug('Class statement'); +runTestShouldThrow("A"); +runTestShouldThrow("class {}"); +runTestShouldThrow("class { constructor() {} }"); +runTestShouldNotThrow("class A { constructor() {} }"); +runTestShouldBe("class A { constructor() {} }; A.toString()", "'class A { constructor() {} }'"); +runTestShouldBeTrue("class A { constructor() {} }; (new A) instanceof A"); +runTestShouldBe("class A { constructor() { this.base = A; } }; (new A).base.toString()", "'class A { constructor() { this.base = A; } }'"); +runTestShouldNotThrow("class A { constructor() {} }; class B extends A {};"); +runTestShouldBe("class A { constructor() {} }; class B extends A { constructor() {} }; B.toString()", "'class B extends A { constructor() {} }'"); +runTestShouldBeTrue("class A { constructor() {} }; class B extends A {}; (new B) instanceof A"); +runTestShouldBeTrue("class A { constructor() {} }; class B extends A {}; (new B) instanceof B"); +runTestShouldBe("class A { constructor() {} }; class B extends A { constructor() { super(); this.base = A; this.derived = B; } }; (new B).base.toString()", "'class A { constructor() {} }'"); +runTestShouldBe("class A { constructor() {} }; class B extends A { constructor() { super(); this.base = A; this.derived = B; } }; (new B).derived.toString()", "'class B extends A { constructor() { super(); this.base = A; this.derived = B; } }'"); + +// Class expression. Class name not added to scope. Class name is available inside class scope. +debug(''); debug('Class expression'); +runTestShouldThrow("A"); +runTestShouldNotThrow("(class {})"); +runTestShouldNotThrow("(class { constructor(){} })"); +runTestShouldBe("typeof (class {})", '"function"'); +runTestShouldNotThrow("(class A {})"); +runTestShouldBe("typeof (class A {})", '"function"'); +runTestShouldThrow("(class A {}); A"); +runTestShouldNotThrow("new (class A {})"); +runTestShouldBe("typeof (new (class A {}))", '"object"'); +runTestShouldNotThrow("(new (class A { constructor() { this.base = A; } })).base"); +runTestShouldBe("(new (class A { constructor() { this.base = A; } })).base.toString()", '"class A { constructor() { this.base = A; } }"'); +runTestShouldNotThrow("class A {}; (class B extends A {})"); +runTestShouldThrow("class A {}; (class B extends A {}); B"); +runTestShouldNotThrow("class A {}; new (class B extends A {})"); +runTestShouldNotThrow("class A {}; new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })"); +runTestShouldBeTrue("class A {}; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })) instanceof A"); +runTestShouldBe("class A { constructor() {} }; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })).base.toString()", "'class A { constructor() {} }'"); +runTestShouldBe("class A { constructor() {} }; (new (class B extends A { constructor() { super(); this.base = A; this.derived = B; } })).derived.toString()", "'class B extends A { constructor() { super(); this.base = A; this.derived = B; } }'"); + +// Assignment of a class expression to a variable. Variable name available in scope, class name is not. Class name is available inside class scope. +debug(''); debug('Class expression assignment to variable'); +runTestShouldThrow("A"); +runTestShouldNotThrow("var VarA = class {}"); +runTestShouldBe("var VarA = class { constructor() {} }; VarA.toString()", "'class { constructor() {} }'"); +runTestShouldThrow("VarA"); +runTestShouldNotThrow("var VarA = class A { constructor() {} }"); +runTestShouldBe("var VarA = class A { constructor() {} }; VarA.toString()", "'class A { constructor() {} }'"); +runTestShouldThrow("var VarA = class A { constructor() {} }; A.toString()"); +runTestShouldBeTrue("var VarA = class A { constructor() {} }; (new VarA) instanceof VarA"); +runTestShouldBe("var VarA = class A { constructor() { this.base = A; } }; (new VarA).base.toString()", "'class A { constructor() { this.base = A; } }'"); +runTestShouldNotThrow("var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} };"); +runTestShouldThrow("var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; B"); +runTestShouldBe("var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() {} }; VarB.toString()", "'class B extends VarA { constructor() {} }'"); +runTestShouldBeTrue("var VarA = class A { constructor() {} }; var VarB = class B extends VarA { }; (new VarB) instanceof VarA"); +runTestShouldBeTrue("var VarA = class A { constructor() {} }; var VarB = class B extends VarA { }; (new VarB) instanceof VarB"); +runTestShouldBeTrue("var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).base === VarA"); +runTestShouldBeTrue("var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).derived === VarB"); +runTestShouldBeTrue("var VarA = class A { constructor() {} }; var VarB = class B extends VarA { constructor() { super(); this.base = VarA; this.derived = B; this.derivedVar = VarB; } }; (new VarB).derivedVar === VarB"); + +// FIXME: Class statement binding should be like `let`, not `var`. +debug(''); debug('Class statement binding in other circumstances'); +runTestShouldThrow("var result = A; result"); +runTestShouldThrow("var result = A; class A {}; result"); +runTestShouldThrow("class A { constructor() { A = 1; } }; new A"); +runTestShouldBe("class A { constructor() { } }; A = 1; A", "1"); +runTestShouldNotThrow("class A {}; var result = A; result"); +shouldBe("eval('var Foo = 10'); Foo", "10"); +shouldThrow("'use strict'; eval('var Foo = 10'); Foo"); +shouldBe("eval('class Bar { constructor() {} }'); Bar.toString()", "'class Bar { constructor() {} }'"); +shouldThrow("'use strict'; eval('class Bar { constructor() {} }'); Bar.toString()"); diff --git a/deps/v8/test/webkit/class-syntax-prototype-expected.txt b/deps/v8/test/webkit/class-syntax-prototype-expected.txt new file mode 100644 index 0000000000..31a0a79144 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-prototype-expected.txt @@ -0,0 +1,50 @@ +Tests for the descriptors of the properties implicitly defined by ES6 class syntax + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS class A {}; descriptor(A, "prototype").writable is false +PASS class A {}; var x = A.prototype; A.prototype = 3; A.prototype is x +PASS class A {}; descriptor(A, "prototype").enumerable is false +PASS class A {}; A.foo = "foo"; enumeratedProperties(A).includes("foo") is true +PASS class A {}; enumeratedProperties(A).includes("prototype") is false +PASS class A {}; descriptor(A, "prototype").configurable is false +PASS class A {}; Object.defineProperty(A, "prototype", {value: "foo"}) threw exception TypeError: Cannot redefine property: prototype. +PASS class A { static foo() {} }; descriptor(A, "foo").writable is true +PASS class A { static foo() {} }; A.foo = 3; A.foo is 3 +PASS class A { static foo() {} }; descriptor(A, "foo").enumerable is false +PASS class A { static foo() {} }; enumeratedProperties(A).includes("foo") is false +PASS class A { static foo() {} }; descriptor(A, "foo").configurable is true +PASS class A { static foo() {} }; Object.defineProperty(A, "foo", {value: "bar"}); A.foo is "bar" +PASS class A { static get foo() {} }; descriptor(A, "foo").writable is undefined +PASS class A { static get foo() { return 5; } }; A.foo = 3; A.foo is 5 +PASS class A { static get foo() {} }; descriptor(A, "foo").enumerable is false +PASS class A { static get foo() {} }; enumeratedProperties(A).includes("foo") is false +PASS class A { static get foo() {} }; enumeratedProperties(new A).includes("foo") is false +PASS class A { static get foo() {} }; descriptor(A, "foo").configurable is true +PASS class A { static get foo() {} }; Object.defineProperty(A, "foo", {value: "bar"}); A.foo is "bar" +PASS class A { foo() {} }; descriptor(A.prototype, "foo").writable is true +PASS class A { foo() {} }; A.prototype.foo = 3; A.prototype.foo is 3 +PASS class A { foo() {} }; descriptor(A.prototype, "foo").enumerable is false +PASS class A { foo() {} }; enumeratedProperties(A.prototype).includes("foo") is false +PASS class A { foo() {} }; enumeratedProperties(new A).includes("foo") is false +PASS class A { foo() {} }; descriptor(A.prototype, "foo").configurable is true +PASS class A { foo() {} }; Object.defineProperty(A.prototype, "foo", {value: "bar"}); A.prototype.foo is "bar" +PASS class A { get foo() {} }; descriptor(A.prototype, "foo").writable is undefined +PASS class A { get foo() { return 5; } }; A.prototype.foo = 3; A.prototype.foo is 5 +PASS class A { get foo() {} }; descriptor(A.prototype, "foo").enumerable is false +PASS class A { get foo() {} }; enumeratedProperties(A.prototype).includes("foo") is false +PASS class A { get foo() {} }; enumeratedProperties(new A).includes("foo") is false +PASS class A { get foo() {} }; descriptor(A.prototype, "foo").configurable is true +PASS class A { get foo() {} }; Object.defineProperty(A.prototype, "foo", {value: "bar"}); A.prototype.foo is "bar" +PASS class A { }; descriptor(A.prototype, "constructor").writable is true +PASS class A { }; A.prototype.constructor = 3; A.prototype.constructor is 3 +PASS class A { }; x = {}; A.prototype.constructor = function () { return x; }; (new A) instanceof A is true +PASS class A { }; descriptor(A.prototype, "constructor").enumerable is false +PASS class A { }; enumeratedProperties(A.prototype).includes("constructor") is false +PASS class A { }; enumeratedProperties(new A).includes("constructor") is false +PASS class A { }; descriptor(A.prototype, "constructor").configurable is true +PASS class A { }; Object.defineProperty(A.prototype, "constructor", {value: "bar"}); A.prototype.constructor is "bar" +PASS successfullyParsed is true + +TEST COMPLETE diff --git a/deps/v8/test/webkit/class-syntax-prototype.js b/deps/v8/test/webkit/class-syntax-prototype.js new file mode 100644 index 0000000000..02ec578bb4 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-prototype.js @@ -0,0 +1,91 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-sloppy + +description('Tests for the descriptors of the properties implicitly defined by ES6 class syntax'); + +function descriptor(object, propertyName) { + return Object.getOwnPropertyDescriptor(object, propertyName); +} + +function enumeratedProperties(object) { + var properties = []; + for (var propertyName in object) + properties.push(propertyName); + return properties; +} + +Array.prototype.includes = function(element) { + return this.indexOf(element) !== -1; +}; + +shouldBeFalse('class A {}; descriptor(A, "prototype").writable'); +shouldBe('class A {}; var x = A.prototype; A.prototype = 3; A.prototype', 'x'); +shouldBeFalse('class A {}; descriptor(A, "prototype").enumerable'); +shouldBeTrue('class A {}; A.foo = "foo"; enumeratedProperties(A).includes("foo")'); +shouldBeFalse('class A {}; enumeratedProperties(A).includes("prototype")'); +shouldBeFalse('class A {}; descriptor(A, "prototype").configurable'); +shouldThrow('class A {}; Object.defineProperty(A, "prototype", {value: "foo"})', '"TypeError: Cannot redefine property: prototype"'); + +shouldBeTrue('class A { static foo() {} }; descriptor(A, "foo").writable'); +shouldBe('class A { static foo() {} }; A.foo = 3; A.foo', '3'); +shouldBeFalse('class A { static foo() {} }; descriptor(A, "foo").enumerable'); +shouldBeFalse('class A { static foo() {} }; enumeratedProperties(A).includes("foo")'); +shouldBeTrue('class A { static foo() {} }; descriptor(A, "foo").configurable'); +shouldBe('class A { static foo() {} }; Object.defineProperty(A, "foo", {value: "bar"}); A.foo', '"bar"'); + +shouldBe('class A { static get foo() {} }; descriptor(A, "foo").writable', 'undefined'); +shouldBe('class A { static get foo() { return 5; } }; A.foo = 3; A.foo', '5'); +shouldBeFalse('class A { static get foo() {} }; descriptor(A, "foo").enumerable'); +shouldBeFalse('class A { static get foo() {} }; enumeratedProperties(A).includes("foo")'); +shouldBeFalse('class A { static get foo() {} }; enumeratedProperties(new A).includes("foo")'); +shouldBeTrue('class A { static get foo() {} }; descriptor(A, "foo").configurable'); +shouldBe('class A { static get foo() {} }; Object.defineProperty(A, "foo", {value: "bar"}); A.foo', '"bar"'); + +shouldBeTrue('class A { foo() {} }; descriptor(A.prototype, "foo").writable'); +shouldBe('class A { foo() {} }; A.prototype.foo = 3; A.prototype.foo', '3'); +shouldBeFalse('class A { foo() {} }; descriptor(A.prototype, "foo").enumerable'); +shouldBeFalse('class A { foo() {} }; enumeratedProperties(A.prototype).includes("foo")'); +shouldBeFalse('class A { foo() {} }; enumeratedProperties(new A).includes("foo")'); +shouldBeTrue('class A { foo() {} }; descriptor(A.prototype, "foo").configurable'); +shouldBe('class A { foo() {} }; Object.defineProperty(A.prototype, "foo", {value: "bar"}); A.prototype.foo', '"bar"'); + +shouldBe('class A { get foo() {} }; descriptor(A.prototype, "foo").writable', 'undefined'); +shouldBe('class A { get foo() { return 5; } }; A.prototype.foo = 3; A.prototype.foo', '5'); +shouldBeFalse('class A { get foo() {} }; descriptor(A.prototype, "foo").enumerable'); +shouldBeFalse('class A { get foo() {} }; enumeratedProperties(A.prototype).includes("foo")'); +shouldBeFalse('class A { get foo() {} }; enumeratedProperties(new A).includes("foo")'); +shouldBeTrue('class A { get foo() {} }; descriptor(A.prototype, "foo").configurable'); +shouldBe('class A { get foo() {} }; Object.defineProperty(A.prototype, "foo", {value: "bar"}); A.prototype.foo', '"bar"'); + +shouldBeTrue('class A { }; descriptor(A.prototype, "constructor").writable'); +shouldBe('class A { }; A.prototype.constructor = 3; A.prototype.constructor', '3'); +shouldBeTrue('class A { }; x = {}; A.prototype.constructor = function () { return x; }; (new A) instanceof A'); +shouldBeFalse('class A { }; descriptor(A.prototype, "constructor").enumerable'); +shouldBeFalse('class A { }; enumeratedProperties(A.prototype).includes("constructor")'); +shouldBeFalse('class A { }; enumeratedProperties(new A).includes("constructor")'); +shouldBeTrue('class A { }; descriptor(A.prototype, "constructor").configurable'); +shouldBe('class A { }; Object.defineProperty(A.prototype, "constructor", {value: "bar"}); A.prototype.constructor', '"bar"'); + +var successfullyParsed = true; diff --git a/deps/v8/test/webkit/class-syntax-scoping-expected.txt b/deps/v8/test/webkit/class-syntax-scoping-expected.txt new file mode 100644 index 0000000000..1a8dd35f20 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-scoping-expected.txt @@ -0,0 +1,10 @@ +Tests for scoping of variables in ES6 class syntax + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS test() is "PASS" +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/deps/v8/test/webkit/class-syntax-scoping.js b/deps/v8/test/webkit/class-syntax-scoping.js new file mode 100644 index 0000000000..02f5a1ee04 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-scoping.js @@ -0,0 +1,39 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-sloppy + +description('Tests for scoping of variables in ES6 class syntax'); + +var local = "FAIL"; +function test() { + var local = "PASS"; + class A { + getLocal(x) { return local; } + }; + return new A().getLocal(); +} + +shouldBe('test()', '"PASS"'); + +var successfullyParsed = true; diff --git a/deps/v8/test/webkit/class-syntax-semicolon-expected.txt b/deps/v8/test/webkit/class-syntax-semicolon-expected.txt new file mode 100644 index 0000000000..488054a582 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-semicolon-expected.txt @@ -0,0 +1,65 @@ +Tests for ES6 class syntax containing semicolon in the class body + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS class A { foo;() { } } threw exception SyntaxError: Unexpected token ;. +PASS class A { foo() ; { } } threw exception SyntaxError: Unexpected token ;. +PASS class A { get ; foo() { } } threw exception SyntaxError: Unexpected token ;. +PASS class A { get foo;() { } } threw exception SyntaxError: Unexpected token ;. +PASS class A { get foo() ; { } } threw exception SyntaxError: Unexpected token ;. +PASS class A { set ; foo(x) { } } threw exception SyntaxError: Unexpected token ;. +PASS class A { set foo;(x) { } } threw exception SyntaxError: Unexpected token ;. +PASS class A { set foo(x) ; { } } threw exception SyntaxError: Unexpected token ;. +PASS class A { ; } did not throw exception. +PASS class A { foo() { } ; } did not throw exception. +PASS class A { get foo() { } ; } did not throw exception. +PASS class A { set foo(x) { } ; } did not throw exception. +PASS class A { static foo() { } ; } did not throw exception. +PASS class A { static get foo() { } ; } did not throw exception. +PASS class A { static set foo(x) { } ; } did not throw exception. +PASS class A { ; foo() { } } did not throw exception. +PASS class A { ; get foo() { } } did not throw exception. +PASS class A { ; set foo(x) { } } did not throw exception. +PASS class A { ; static foo() { } } did not throw exception. +PASS class A { ; static get foo() { } } did not throw exception. +PASS class A { ; static set foo(x) { } } did not throw exception. +PASS class A { foo() { } ; foo() {} } did not throw exception. +PASS class A { foo() { } ; get foo() {} } did not throw exception. +PASS class A { foo() { } ; set foo(x) {} } did not throw exception. +PASS class A { foo() { } ; static foo() {} } did not throw exception. +PASS class A { foo() { } ; static get foo() {} } did not throw exception. +PASS class A { foo() { } ; static set foo(x) {} } did not throw exception. +PASS class A { get foo() { } ; foo() {} } did not throw exception. +PASS class A { get foo() { } ; get foo() {} } did not throw exception. +PASS class A { get foo() { } ; set foo(x) {} } did not throw exception. +PASS class A { get foo() { } ; static foo() {} } did not throw exception. +PASS class A { get foo() { } ; static get foo() {} } did not throw exception. +PASS class A { get foo() { } ; static set foo(x) {} } did not throw exception. +PASS class A { set foo(x) { } ; foo() {} } did not throw exception. +PASS class A { set foo(x) { } ; get foo() {} } did not throw exception. +PASS class A { set foo(x) { } ; set foo(x) {} } did not throw exception. +PASS class A { set foo(x) { } ; static foo() {} } did not throw exception. +PASS class A { set foo(x) { } ; static get foo() {} } did not throw exception. +PASS class A { set foo(x) { } ; static set foo(x) {} } did not throw exception. +PASS class A { static foo() { } ; foo() {} } did not throw exception. +PASS class A { static foo() { } ; get foo() {} } did not throw exception. +PASS class A { static foo() { } ; set foo(x) {} } did not throw exception. +PASS class A { static foo() { } ; static foo() {} } did not throw exception. +PASS class A { static foo() { } ; static get foo() {} } did not throw exception. +PASS class A { static foo() { } ; static set foo(x) {} } did not throw exception. +PASS class A { static get foo() { } ; foo() {} } did not throw exception. +PASS class A { static get foo() { } ; get foo() {} } did not throw exception. +PASS class A { static get foo() { } ; set foo(x) {} } did not throw exception. +PASS class A { static get foo() { } ; static foo() {} } did not throw exception. +PASS class A { static get foo() { } ; static get foo() {} } did not throw exception. +PASS class A { static get foo() { } ; static set foo(x) {} } did not throw exception. +PASS class A { static set foo(x) { } ; foo() {} } did not throw exception. +PASS class A { static set foo(x) { } ; get foo() {} } did not throw exception. +PASS class A { static set foo(x) { } ; set foo(x) {} } did not throw exception. +PASS class A { static set foo(x) { } ; static foo() {} } did not throw exception. +PASS class A { static set foo(x) { } ; static get foo() {} } did not throw exception. +PASS class A { static set foo(x) { } ; static set foo(x) {} } did not throw exception. +PASS successfullyParsed is true + +TEST COMPLETE diff --git a/deps/v8/test/webkit/class-syntax-semicolon.js b/deps/v8/test/webkit/class-syntax-semicolon.js new file mode 100644 index 0000000000..33504f95d4 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-semicolon.js @@ -0,0 +1,94 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-sloppy + +description('Tests for ES6 class syntax containing semicolon in the class body'); + +shouldThrow("class A { foo;() { } }", "'SyntaxError: Unexpected token ;'"); +shouldThrow("class A { foo() ; { } }", "'SyntaxError: Unexpected token ;'"); +shouldThrow("class A { get ; foo() { } }", "'SyntaxError: Unexpected token ;'"); +shouldThrow("class A { get foo;() { } }", "'SyntaxError: Unexpected token ;'"); +shouldThrow("class A { get foo() ; { } }", "'SyntaxError: Unexpected token ;'"); +shouldThrow("class A { set ; foo(x) { } }", "'SyntaxError: Unexpected token ;'"); +shouldThrow("class A { set foo;(x) { } }", "'SyntaxError: Unexpected token ;'"); +shouldThrow("class A { set foo(x) ; { } }", "'SyntaxError: Unexpected token ;'"); + +shouldNotThrow("class A { ; }"); +shouldNotThrow("class A { foo() { } ; }"); +shouldNotThrow("class A { get foo() { } ; }"); +shouldNotThrow("class A { set foo(x) { } ; }"); +shouldNotThrow("class A { static foo() { } ; }"); +shouldNotThrow("class A { static get foo() { } ; }"); +shouldNotThrow("class A { static set foo(x) { } ; }"); + +shouldNotThrow("class A { ; foo() { } }"); +shouldNotThrow("class A { ; get foo() { } }"); +shouldNotThrow("class A { ; set foo(x) { } }"); +shouldNotThrow("class A { ; static foo() { } }"); +shouldNotThrow("class A { ; static get foo() { } }"); +shouldNotThrow("class A { ; static set foo(x) { } }"); + +shouldNotThrow("class A { foo() { } ; foo() {} }"); +shouldNotThrow("class A { foo() { } ; get foo() {} }"); +shouldNotThrow("class A { foo() { } ; set foo(x) {} }"); +shouldNotThrow("class A { foo() { } ; static foo() {} }"); +shouldNotThrow("class A { foo() { } ; static get foo() {} }"); +shouldNotThrow("class A { foo() { } ; static set foo(x) {} }"); + +shouldNotThrow("class A { get foo() { } ; foo() {} }"); +shouldNotThrow("class A { get foo() { } ; get foo() {} }"); +shouldNotThrow("class A { get foo() { } ; set foo(x) {} }"); +shouldNotThrow("class A { get foo() { } ; static foo() {} }"); +shouldNotThrow("class A { get foo() { } ; static get foo() {} }"); +shouldNotThrow("class A { get foo() { } ; static set foo(x) {} }"); + +shouldNotThrow("class A { set foo(x) { } ; foo() {} }"); +shouldNotThrow("class A { set foo(x) { } ; get foo() {} }"); +shouldNotThrow("class A { set foo(x) { } ; set foo(x) {} }"); +shouldNotThrow("class A { set foo(x) { } ; static foo() {} }"); +shouldNotThrow("class A { set foo(x) { } ; static get foo() {} }"); +shouldNotThrow("class A { set foo(x) { } ; static set foo(x) {} }"); + +shouldNotThrow("class A { static foo() { } ; foo() {} }"); +shouldNotThrow("class A { static foo() { } ; get foo() {} }"); +shouldNotThrow("class A { static foo() { } ; set foo(x) {} }"); +shouldNotThrow("class A { static foo() { } ; static foo() {} }"); +shouldNotThrow("class A { static foo() { } ; static get foo() {} }"); +shouldNotThrow("class A { static foo() { } ; static set foo(x) {} }"); + +shouldNotThrow("class A { static get foo() { } ; foo() {} }"); +shouldNotThrow("class A { static get foo() { } ; get foo() {} }"); +shouldNotThrow("class A { static get foo() { } ; set foo(x) {} }"); +shouldNotThrow("class A { static get foo() { } ; static foo() {} }"); +shouldNotThrow("class A { static get foo() { } ; static get foo() {} }"); +shouldNotThrow("class A { static get foo() { } ; static set foo(x) {} }"); + +shouldNotThrow("class A { static set foo(x) { } ; foo() {} }"); +shouldNotThrow("class A { static set foo(x) { } ; get foo() {} }"); +shouldNotThrow("class A { static set foo(x) { } ; set foo(x) {} }"); +shouldNotThrow("class A { static set foo(x) { } ; static foo() {} }"); +shouldNotThrow("class A { static set foo(x) { } ; static get foo() {} }"); +shouldNotThrow("class A { static set foo(x) { } ; static set foo(x) {} }"); + +var successfullyParsed = true; diff --git a/deps/v8/test/webkit/class-syntax-super-expected.txt b/deps/v8/test/webkit/class-syntax-super-expected.txt new file mode 100644 index 0000000000..2f38f5ae38 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-super-expected.txt @@ -0,0 +1,46 @@ +Tests for ES6 class syntax "super" + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +PASS (new Base) instanceof Base is true +PASS (new Derived) instanceof Derived is true +PASS (new Derived).callBaseMethod() is baseMethodValue +PASS x = (new Derived).callBaseMethod; x() is baseMethodValue +PASS (new Derived).callBaseMethodInGetter is baseMethodValue +PASS (new Derived).callBaseMethodInSetter = 1; valueInSetter is baseMethodValue +PASS (new Derived).baseMethodInGetterSetter is (new Base).baseMethod +PASS (new Derived).baseMethodInGetterSetter = 1; valueInSetter is (new Base).baseMethod +PASS Derived.staticMethod() is "base3" +PASS (new SecondDerived).chainMethod() is ["base", "derived", "secondDerived"] +PASS x = class extends Base { constructor() { super(); } super() {} } did not throw exception. +PASS x = class extends Base { constructor() { super(); } method() { super() } } threw exception SyntaxError: 'super' keyword unexpected here. +PASS x = class extends Base { constructor() { super(); } method() { super } } threw exception SyntaxError: 'super' keyword unexpected here. +PASS x = class extends Base { constructor() { super(); } method() { return new super } } threw exception SyntaxError: 'super' keyword unexpected here. +PASS x = class extends Base { constructor() { super(); } method1() { delete (super.foo) } method2() { delete super["foo"] } } did not throw exception. +PASS (new x).method1() threw exception ReferenceError: Unsupported reference to 'super'. +PASS (new x).method2() threw exception ReferenceError: Unsupported reference to 'super'. +PASS new (class { constructor() { return undefined; } }) instanceof Object is true +PASS new (class { constructor() { return 1; } }) instanceof Object is true +PASS new (class extends Base { constructor() { return undefined } }) threw exception ReferenceError: this is not defined. +PASS new (class extends Base { constructor() { super(); return undefined } }) instanceof Object is true +PASS x = { }; new (class extends Base { constructor() { return x } }); is x +PASS x instanceof Base is false +PASS new (class extends Base { constructor() { } }) threw exception ReferenceError: this is not defined. +PASS new (class extends Base { constructor() { return 1; } }) threw exception TypeError: Derived constructors may only return object or undefined. +PASS new (class extends null { constructor() { return undefined } }) threw exception ReferenceError: this is not defined. +PASS new (class extends null { constructor() { super(); return undefined } }) threw exception TypeError: function () {} is not a constructor. +PASS x = { }; new (class extends null { constructor() { return x } }); is x +PASS x instanceof Object is true +PASS new (class extends null { constructor() { } }) threw exception ReferenceError: this is not defined. +PASS new (class extends null { constructor() { return 1; } }) threw exception TypeError: Derived constructors may only return object or undefined. +PASS new (class extends null { constructor() { super() } }) threw exception TypeError: function () {} is not a constructor. +PASS new (class { constructor() { super() } }) threw exception SyntaxError: 'super' keyword unexpected here. +PASS function x() { super(); } threw exception SyntaxError: 'super' keyword unexpected here. +PASS new (class extends Object { constructor() { function x() { super() } } }) threw exception SyntaxError: 'super' keyword unexpected here. +PASS new (class extends Object { constructor() { function x() { super.method } } }) threw exception SyntaxError: 'super' keyword unexpected here. +PASS function x() { super.method(); } threw exception SyntaxError: 'super' keyword unexpected here. +PASS function x() { super(); } threw exception SyntaxError: 'super' keyword unexpected here. +PASS successfullyParsed is true + +TEST COMPLETE diff --git a/deps/v8/test/webkit/class-syntax-super.js b/deps/v8/test/webkit/class-syntax-super.js new file mode 100644 index 0000000000..8625831de5 --- /dev/null +++ b/deps/v8/test/webkit/class-syntax-super.js @@ -0,0 +1,96 @@ +// Copyright 2015 the V8 project authors. All rights reserved. +// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY +// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY +// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +// Flags: --harmony-sloppy + +description('Tests for ES6 class syntax "super"'); + +var baseMethodValue = {}; +var valueInSetter = null; + +class Base { + constructor() { } + baseMethod() { return baseMethodValue; } + chainMethod() { return 'base'; } + static staticMethod() { return 'base3'; } +} + +class Derived extends Base { + constructor() { super(); } + chainMethod() { return [super.chainMethod(), 'derived']; } + callBaseMethod() { return super.baseMethod(); } + get callBaseMethodInGetter() { return super['baseMethod'](); } + set callBaseMethodInSetter(x) { valueInSetter = super.baseMethod(); } + get baseMethodInGetterSetter() { return super.baseMethod; } + set baseMethodInGetterSetter(x) { valueInSetter = super['baseMethod']; } + static staticMethod() { return super.staticMethod(); } +} + +class SecondDerived extends Derived { + constructor() { super(); } + chainMethod() { return super.chainMethod().concat(['secondDerived']); } +} + +shouldBeTrue('(new Base) instanceof Base'); +shouldBeTrue('(new Derived) instanceof Derived'); +shouldBe('(new Derived).callBaseMethod()', 'baseMethodValue'); +shouldBe('x = (new Derived).callBaseMethod; x()', 'baseMethodValue'); +shouldBe('(new Derived).callBaseMethodInGetter', 'baseMethodValue'); +shouldBe('(new Derived).callBaseMethodInSetter = 1; valueInSetter', 'baseMethodValue'); +shouldBe('(new Derived).baseMethodInGetterSetter', '(new Base).baseMethod'); +shouldBe('(new Derived).baseMethodInGetterSetter = 1; valueInSetter', '(new Base).baseMethod'); +shouldBe('Derived.staticMethod()', '"base3"'); +shouldBe('(new SecondDerived).chainMethod()', '["base", "derived", "secondDerived"]'); +shouldNotThrow('x = class extends Base { constructor() { super(); } super() {} }'); +shouldThrow('x = class extends Base { constructor() { super(); } method() { super() } }', + '"SyntaxError: \'super\' keyword unexpected here"'); +shouldThrow('x = class extends Base { constructor() { super(); } method() { super } }', '"SyntaxError: \'super\' keyword unexpected here"'); +shouldThrow('x = class extends Base { constructor() { super(); } method() { return new super } }', '"SyntaxError: \'super\' keyword unexpected here"'); +// shouldBeTrue('(new x).method() instanceof Base'); +// shouldBeFalse('(new x).method() instanceof x'); +shouldNotThrow('x = class extends Base { constructor() { super(); } method1() { delete (super.foo) } method2() { delete super["foo"] } }'); +shouldThrow('(new x).method1()', '"ReferenceError: Unsupported reference to \'super\'"'); +shouldThrow('(new x).method2()', '"ReferenceError: Unsupported reference to \'super\'"'); +shouldBeTrue('new (class { constructor() { return undefined; } }) instanceof Object'); +shouldBeTrue('new (class { constructor() { return 1; } }) instanceof Object'); +shouldThrow('new (class extends Base { constructor() { return undefined } })'); +shouldBeTrue('new (class extends Base { constructor() { super(); return undefined } }) instanceof Object'); +shouldBe('x = { }; new (class extends Base { constructor() { return x } });', 'x'); +shouldBeFalse('x instanceof Base'); +shouldThrow('new (class extends Base { constructor() { } })', '"ReferenceError: this is not defined"'); +shouldThrow('new (class extends Base { constructor() { return 1; } })', '"TypeError: Derived constructors may only return object or undefined"'); +shouldThrow('new (class extends null { constructor() { return undefined } })'); +shouldThrow('new (class extends null { constructor() { super(); return undefined } })', '"TypeError: function () {} is not a constructor"'); +shouldBe('x = { }; new (class extends null { constructor() { return x } });', 'x'); +shouldBeTrue('x instanceof Object'); +shouldThrow('new (class extends null { constructor() { } })', '"ReferenceError: this is not defined"'); +shouldThrow('new (class extends null { constructor() { return 1; } })', '"TypeError: Derived constructors may only return object or undefined"'); +shouldThrow('new (class extends null { constructor() { super() } })', '"TypeError: function () {} is not a constructor"'); +shouldThrow('new (class { constructor() { super() } })', '"SyntaxError: \'super\' keyword unexpected here"'); +shouldThrow('function x() { super(); }', '"SyntaxError: \'super\' keyword unexpected here"'); +shouldThrow('new (class extends Object { constructor() { function x() { super() } } })', '"SyntaxError: \'super\' keyword unexpected here"'); +shouldThrow('new (class extends Object { constructor() { function x() { super.method } } })', '"SyntaxError: \'super\' keyword unexpected here"'); +shouldThrow('function x() { super.method(); }', '"SyntaxError: \'super\' keyword unexpected here"'); +shouldThrow('function x() { super(); }', '"SyntaxError: \'super\' keyword unexpected here"'); + +var successfullyParsed = true; diff --git a/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt b/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt index 0e00f23cad..1948700fca 100644 --- a/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt +++ b/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt @@ -38,12 +38,12 @@ PASS getSortedOwnPropertyNames(parseInt) is ['arguments', 'caller', 'length', 'n PASS getSortedOwnPropertyNames(parseFloat) is ['arguments', 'caller', 'length', 'name'] PASS getSortedOwnPropertyNames(isNaN) is ['arguments', 'caller', 'length', 'name'] PASS getSortedOwnPropertyNames(isFinite) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(escape) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(unescape) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(decodeURI) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(decodeURIComponent) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(encodeURI) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(encodeURIComponent) is ['arguments', 'caller', 'length', 'name'] +PASS getSortedOwnPropertyNames(escape) is ['length', 'name'] +PASS getSortedOwnPropertyNames(unescape) is ['length', 'name'] +PASS getSortedOwnPropertyNames(decodeURI) is ['length', 'name'] +PASS getSortedOwnPropertyNames(decodeURIComponent) is ['length', 'name'] +PASS getSortedOwnPropertyNames(encodeURI) is ['length', 'name'] +PASS getSortedOwnPropertyNames(encodeURIComponent) is ['length', 'name'] PASS getSortedOwnPropertyNames(Object) is ['arguments', 'caller', 'create', 'defineProperties', 'defineProperty', 'deliverChangeRecords', 'freeze', 'getNotifier', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'getOwnPropertySymbols', 'getPrototypeOf', 'is', 'isExtensible', 'isFrozen', 'isSealed', 'keys', 'length', 'name', 'observe', 'preventExtensions', 'prototype', 'seal', 'setPrototypeOf', 'unobserve'] PASS getSortedOwnPropertyNames(Object.prototype) is ['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', '__proto__', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf'] PASS getSortedOwnPropertyNames(Function) is ['arguments', 'caller', 'length', 'name', 'prototype'] diff --git a/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames.js b/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames.js index 72bd21b426..20e509ba96 100644 --- a/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames.js +++ b/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames.js @@ -64,12 +64,12 @@ var expectedPropertyNamesSet = { "parseFloat": "['arguments', 'caller', 'length', 'name']", "isNaN": "['arguments', 'caller', 'length', 'name']", "isFinite": "['arguments', 'caller', 'length', 'name']", - "escape": "['arguments', 'caller', 'length', 'name']", - "unescape": "['arguments', 'caller', 'length', 'name']", - "decodeURI": "['arguments', 'caller', 'length', 'name']", - "decodeURIComponent": "['arguments', 'caller', 'length', 'name']", - "encodeURI": "['arguments', 'caller', 'length', 'name']", - "encodeURIComponent": "['arguments', 'caller', 'length', 'name']", + "escape": "['length', 'name']", + "unescape": "['length', 'name']", + "decodeURI": "['length', 'name']", + "decodeURIComponent": "['length', 'name']", + "encodeURI": "['length', 'name']", + "encodeURIComponent": "['length', 'name']", // Built-in ECMA objects "Object": "['arguments', 'caller', 'create', 'defineProperties', 'defineProperty', 'deliverChangeRecords', 'freeze', 'getNotifier', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'getOwnPropertySymbols', 'getPrototypeOf', 'is', 'isExtensible', 'isFrozen', 'isSealed', 'keys', 'length', 'name', 'observe', 'preventExtensions', 'prototype', 'seal', 'setPrototypeOf', 'unobserve']", "Object.prototype": "['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', '__proto__', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']", diff --git a/deps/v8/test/webkit/fast/js/basic-strict-mode-expected.txt b/deps/v8/test/webkit/fast/js/basic-strict-mode-expected.txt index 0e6228e161..1fcf0c1acb 100644 --- a/deps/v8/test/webkit/fast/js/basic-strict-mode-expected.txt +++ b/deps/v8/test/webkit/fast/js/basic-strict-mode-expected.txt @@ -81,20 +81,22 @@ PASS (function (){'use strict'; with(1){};}) threw exception SyntaxError: Strict PASS (function(){(function (){'use strict'; with(1){};})}) threw exception SyntaxError: Strict mode code may not include a with statement. PASS (function (){'use strict'; arguments.callee; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. PASS (function (){'use strict'; arguments.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(){'use strict'; f.arguments; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(){'use strict'; f.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(){'use strict'; f.caller=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. +PASS (function f(){'use strict'; f.arguments; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(){'use strict'; f.caller; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(){'use strict'; f.caller=5; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. PASS (function (arg){'use strict'; arguments.callee; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. PASS (function (arg){'use strict'; arguments.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(arg){'use strict'; f.arguments; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(arg){'use strict'; f.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(arg){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(arg){'use strict'; f.caller=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. +PASS (function f(arg){'use strict'; f.arguments; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(arg){'use strict'; f.caller; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(arg){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(arg){'use strict'; f.caller=5; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. PASS "caller" in function(){"use strict"} is true -PASS (function(){"use strict";}).hasOwnProperty("caller") is true +PASS (function(){"use strict";}).hasOwnProperty("caller") is false +PASS (function(){"use strict";}).__proto__.hasOwnProperty("caller") is true PASS "arguments" in function(){"use strict"} is true -PASS (function(){"use strict";}).hasOwnProperty("arguments") is true +PASS (function(){"use strict";}).hasOwnProperty("arguments") is false +PASS (function(){"use strict";}).__proto__.hasOwnProperty("arguments") is true PASS 'use strict'; (function (){with(1){};}) threw exception SyntaxError: Strict mode code may not include a with statement. PASS (function(){'use strict'; (function (){with(1){};})}) threw exception SyntaxError: Strict mode code may not include a with statement. PASS 'use strict'; (function (){var a; delete a;}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode.. @@ -195,14 +197,14 @@ PASS (function (a){'use strict'; var local; (function (){local;})(); arguments[0 PASS (function (){'use strict'; var local; (function (){local;})(); arguments[0]=true; return arguments; })()[0] is true PASS 'use strict'; (function (){var a = true; eval('var a = false'); return a; })() is true PASS (function (){var a = true; eval('"use strict"; var a = false'); return a; })() is true -PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f, 'arguments').value; })() is undefined. -PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f, 'caller').value; })() is undefined. +PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'arguments').value; })() is undefined. +PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'caller').value; })() is undefined. PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'callee').value; })() is undefined. PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'caller').value; })() is undefined. PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'caller'); return descriptor.get === descriptor.set; })() is true PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'callee'); return descriptor.get === descriptor.set; })() is true -PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f, 'caller'); return descriptor.get === descriptor.set; })() is true -PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f, 'arguments'); return descriptor.get === descriptor.set; })() is true +PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'caller'); return descriptor.get === descriptor.set; })() is true +PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'arguments'); return descriptor.get === descriptor.set; })() is true PASS 'use strict'; (function f() { for(var i in this); })(); true; is true PASS 'use strict'̻ threw exception SyntaxError: Unexpected token ILLEGAL. PASS (function(){'use strict'̻}) threw exception SyntaxError: Unexpected token ILLEGAL. @@ -228,7 +230,7 @@ PASS (function () {'use strict'; try { throw 1; } catch (e) { aGlobal = true; } PASS try { throw 1; } catch (e) { aGlobal = true; } is true PASS (function () { try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal; is true PASS (function () {try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal; is true -FAIL String(Object.getOwnPropertyDescriptor(function() { "use strict"; }, "caller").get) should be function () { +FAIL String(Object.getOwnPropertyDescriptor((function() { "use strict"; }).__proto__, "caller").get) should be function () { [native code] }. Was function ThrowTypeError() { [native code] }. PASS successfullyParsed is true diff --git a/deps/v8/test/webkit/fast/js/basic-strict-mode.js b/deps/v8/test/webkit/fast/js/basic-strict-mode.js index f34b14e7ae..1687b2e5e7 100644 --- a/deps/v8/test/webkit/fast/js/basic-strict-mode.js +++ b/deps/v8/test/webkit/fast/js/basic-strict-mode.js @@ -109,11 +109,13 @@ shouldThrow("(function f(arg){'use strict'; f.caller; })()"); shouldThrow("(function f(arg){'use strict'; f.arguments=5; })()"); shouldThrow("(function f(arg){'use strict'; f.caller=5; })()"); -// arguments/caller poisoning should be visible but not throw with 'in' & 'hasOwnProperty'. +// arguments/caller poisoning should be visible on the intrinsic %FunctionPrototype%, but not throw with 'in' & 'hasOwnProperty'. shouldBeTrue('"caller" in function(){"use strict"}'); -shouldBeTrue('(function(){"use strict";}).hasOwnProperty("caller")'); +shouldBeFalse('(function(){"use strict";}).hasOwnProperty("caller")'); +shouldBeTrue('(function(){"use strict";}).__proto__.hasOwnProperty("caller")'); shouldBeTrue('"arguments" in function(){"use strict"}'); -shouldBeTrue('(function(){"use strict";}).hasOwnProperty("arguments")'); +shouldBeFalse('(function(){"use strict";}).hasOwnProperty("arguments")'); +shouldBeTrue('(function(){"use strict";}).__proto__.hasOwnProperty("arguments")'); shouldBeSyntaxError("'use strict'; (function (){with(1){};})"); shouldBeSyntaxError("'use strict'; (function (){var a; delete a;})"); @@ -194,14 +196,14 @@ shouldBeTrue("(function (){'use strict'; var local; (function (){local;})(); ar shouldBeTrue("'use strict'; (function (){var a = true; eval('var a = false'); return a; })()"); shouldBeTrue("(function (){var a = true; eval('\"use strict\"; var a = false'); return a; })()"); -shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f, 'arguments').value; })()"); -shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f, 'caller').value; })()"); +shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'arguments').value; })()"); +shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'caller').value; })()"); shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'callee').value; })()"); shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'caller').value; })()"); shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'caller'); return descriptor.get === descriptor.set; })()"); shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'callee'); return descriptor.get === descriptor.set; })()"); -shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f, 'caller'); return descriptor.get === descriptor.set; })()"); -shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f, 'arguments'); return descriptor.get === descriptor.set; })()"); +shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'caller'); return descriptor.get === descriptor.set; })()"); +shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'arguments'); return descriptor.get === descriptor.set; })()"); shouldBeTrue("'use strict'; (function f() { for(var i in this); })(); true;") shouldBeSyntaxError("'use strict'\u033b"); @@ -228,4 +230,4 @@ aGlobal = false; shouldBeTrue("(function () {try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal;"); // Make sure this doesn't crash! -shouldBe('String(Object.getOwnPropertyDescriptor(function() { "use strict"; }, "caller").get)', "'function () {\\n [native code]\\n}'"); +shouldBe('String(Object.getOwnPropertyDescriptor((function() { "use strict"; }).__proto__, "caller").get)', "'function () {\\n [native code]\\n}'"); diff --git a/deps/v8/test/webkit/fast/js/caller-property-expected.txt b/deps/v8/test/webkit/fast/js/caller-property-expected.txt deleted file mode 100644 index a5d4dd2c14..0000000000 --- a/deps/v8/test/webkit/fast/js/caller-property-expected.txt +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2013 the V8 project authors. All rights reserved. -# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This tests for caller property in functions. Only functions that are called from inside of other functions and have a parent should have this property set. Tests return true when caller is found and false when the caller is null. - -On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". - - -PASS childHasCallerWhenExecutingGlobalCode is false -PASS childHasCallerWhenCalledWithoutParent is false -PASS childHasCallerWhenCalledFromWithinParent is true -PASS nonStrictCaller(nonStrictCallee) is nonStrictCaller -FAIL nonStrictCaller(strictCallee) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -FAIL strictCaller(nonStrictCallee) should throw TypeError: Function.caller used to retrieve strict caller. Was null. -FAIL strictCaller(strictCallee) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS nonStrictCaller(boundNonStrictCallee) is nonStrictCaller -FAIL nonStrictCaller(boundStrictCallee) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -FAIL strictCaller(boundNonStrictCallee) should throw TypeError: Function.caller used to retrieve strict caller. Was null. -FAIL strictCaller(boundStrictCallee) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS nonStrictGetter(nonStrictAccessor) is nonStrictGetter -PASS nonStrictSetter(nonStrictAccessor) is true -FAIL nonStrictGetter(strictAccessor) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -FAIL nonStrictSetter(strictAccessor) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -FAIL strictGetter(nonStrictAccessor) should throw TypeError: Function.caller used to retrieve strict caller. Was null. -FAIL strictSetter(nonStrictAccessor) should throw TypeError: Function.caller used to retrieve strict caller. Was undefined. -FAIL strictGetter(strictAccessor) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -FAIL strictSetter(strictAccessor) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS successfullyParsed is true - -TEST COMPLETE - diff --git a/deps/v8/test/webkit/fast/js/caller-property.js b/deps/v8/test/webkit/fast/js/caller-property.js deleted file mode 100644 index d28ccf8c50..0000000000 --- a/deps/v8/test/webkit/fast/js/caller-property.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -description( -'This tests for caller property in functions. Only functions that are called from inside of other functions and have a parent should have this property set. Tests return true when caller is found and false when the caller is null.' -) -function child() -{ - return (child.caller !== null); -} - -function parent() -{ - return child(); -} - -var childHasCallerWhenExecutingGlobalCode = (child.caller !== null); -var childHasCallerWhenCalledWithoutParent = child(); -var childHasCallerWhenCalledFromWithinParent = parent(); - -shouldBe('childHasCallerWhenExecutingGlobalCode', 'false'); -shouldBe('childHasCallerWhenCalledWithoutParent', 'false'); -shouldBe('childHasCallerWhenCalledFromWithinParent', 'true') - -// The caller property should throw in strict mode, and a non-strict function cannot use caller to reach a strict caller (see ES5.1 15.3.5.4). -function nonStrictCallee() { return nonStrictCallee.caller; } -function strictCallee() { "use strict"; return strictCallee.caller; } -function nonStrictCaller(x) { return x(); } -function strictCaller(x) { "use strict"; return x(); } -shouldBe("nonStrictCaller(nonStrictCallee)", "nonStrictCaller"); -shouldThrow("nonStrictCaller(strictCallee)", '"TypeError: Type error"'); -shouldThrow("strictCaller(nonStrictCallee)", '"TypeError: Function.caller used to retrieve strict caller"'); -shouldThrow("strictCaller(strictCallee)", '"TypeError: Type error"'); - -// .caller within a bound function reaches the caller, ignoring the binding. -var boundNonStrictCallee = nonStrictCallee.bind(); -var boundStrictCallee = strictCallee.bind(); -shouldBe("nonStrictCaller(boundNonStrictCallee)", "nonStrictCaller"); -shouldThrow("nonStrictCaller(boundStrictCallee)", '"TypeError: Type error"'); -shouldThrow("strictCaller(boundNonStrictCallee)", '"TypeError: Function.caller used to retrieve strict caller"'); -shouldThrow("strictCaller(boundStrictCallee)", '"TypeError: Type error"'); - -// Check that .caller works (or throws) as expected, over an accessor call. -function getFooGetter(x) { return Object.getOwnPropertyDescriptor(x, 'foo').get; } -function getFooSetter(x) { return Object.getOwnPropertyDescriptor(x, 'foo').set; } -var nonStrictAccessor = { - get foo() { return getFooGetter(nonStrictAccessor).caller; }, - set foo(x) { if (getFooSetter(nonStrictAccessor).caller !==x) throw false; } -}; -var strictAccessor = { - get foo() { "use strict"; return getFooGetter(strictAccessor).caller; }, - set foo(x) { "use strict"; if (getFooSetter(strictAccessor).caller !==x) throw false; } -}; -function nonStrictGetter(x) { return x.foo; } -function nonStrictSetter(x) { x.foo = nonStrictSetter; return true; } -function strictGetter(x) { "use strict"; return x.foo; } -function strictSetter(x) { "use strict"; x.foo = nonStrictSetter; return true; } -shouldBe("nonStrictGetter(nonStrictAccessor)", "nonStrictGetter"); -shouldBeTrue("nonStrictSetter(nonStrictAccessor)"); -shouldThrow("nonStrictGetter(strictAccessor)", '"TypeError: Type error"'); -shouldThrow("nonStrictSetter(strictAccessor)", '"TypeError: Type error"'); -shouldThrow("strictGetter(nonStrictAccessor)", '"TypeError: Function.caller used to retrieve strict caller"'); -shouldThrow("strictSetter(nonStrictAccessor)", '"TypeError: Function.caller used to retrieve strict caller"'); -shouldThrow("strictGetter(strictAccessor)", '"TypeError: Type error"'); -shouldThrow("strictSetter(strictAccessor)", '"TypeError: Type error"'); diff --git a/deps/v8/test/webkit/prototypes-expected.txt b/deps/v8/test/webkit/prototypes-expected.txt index c2c35b177c..935cd6222b 100644 --- a/deps/v8/test/webkit/prototypes-expected.txt +++ b/deps/v8/test/webkit/prototypes-expected.txt @@ -43,8 +43,8 @@ PASS Array.__proto__ is Object.__proto__ PASS Date.__proto__ is Object.__proto__ PASS Number.__proto__ is Object.__proto__ PASS String.__proto__ is Object.__proto__ -PASS Object.getPrototypeOf('') threw exception TypeError: Object.getPrototypeOf called on non-object. -PASS Object.getPrototypeOf(0) threw exception TypeError: Object.getPrototypeOf called on non-object. +PASS Object.getPrototypeOf('') is String.prototype +PASS Object.getPrototypeOf(0) is Number.prototype PASS Object.getPrototypeOf([]) is Array.prototype PASS Object.getPrototypeOf({}) is Object.prototype PASS Object.getPrototypeOf(new Date) is Date.prototype diff --git a/deps/v8/test/webkit/prototypes.js b/deps/v8/test/webkit/prototypes.js index 26ae286df6..9e62c3a52e 100644 --- a/deps/v8/test/webkit/prototypes.js +++ b/deps/v8/test/webkit/prototypes.js @@ -43,8 +43,8 @@ shouldBe("Date.__proto__", "Object.__proto__"); shouldBe("Number.__proto__", "Object.__proto__"); shouldBe("String.__proto__", "Object.__proto__"); -shouldThrow("Object.getPrototypeOf('')"); -shouldThrow("Object.getPrototypeOf(0)"); +shouldBe("Object.getPrototypeOf('')", "String.prototype"); +shouldBe("Object.getPrototypeOf(0)", "Number.prototype"); shouldBe("Object.getPrototypeOf([])", "Array.prototype"); shouldBe("Object.getPrototypeOf({})", "Object.prototype"); shouldBe("Object.getPrototypeOf(new Date)", "Date.prototype"); diff --git a/deps/v8/test/webkit/resources/standalone-pre.js b/deps/v8/test/webkit/resources/standalone-pre.js index 5f164dbcb5..3c94dd64c1 100644 --- a/deps/v8/test/webkit/resources/standalone-pre.js +++ b/deps/v8/test/webkit/resources/standalone-pre.js @@ -89,9 +89,12 @@ function isResultCorrect(_actual, _expected) function stringify(v) { + if (v) + return v.toString(); if (v === 0 && 1/v < 0) return "-0"; - else return "" + v; + else + return "" + v; } function shouldBe(_a, _b) @@ -114,7 +117,7 @@ function shouldBe(_a, _b) else if (typeof(_av) == typeof(_bv)) testFailed(_a + " should be " + _bv + ". Was " + stringify(_av) + "."); else - testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + _av + " (of type " + typeof _av + ")."); + testFailed(_a + " should be " + _bv + " (of type " + typeof _bv + "). Was " + stringify(_av) + " (of type " + typeof _av + ")."); } function shouldBeTrue(_a) { shouldBe(_a, "true"); } @@ -171,7 +174,18 @@ function shouldThrow(_a, _e) } else if (typeof _av == "undefined") testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was undefined."); else - testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + _av + "."); + testFailed(_a + " should throw " + (typeof _e == "undefined" ? "an exception" : _ev) + ". Was " + stringify(_av) + "."); +} + + +function shouldNotThrow(_a) +{ + try { + eval(_a); + testPassed(_a + " did not throw exception."); + } catch (e) { + testFailed(_a + " should not throw exception. Threw exception " + e + "."); + } } function isSuccessfullyParsed() diff --git a/deps/v8/test/webkit/strict-throw-type-error-expected.txt b/deps/v8/test/webkit/strict-throw-type-error-expected.txt deleted file mode 100644 index 607498e4eb..0000000000 --- a/deps/v8/test/webkit/strict-throw-type-error-expected.txt +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright 2013 the V8 project authors. All rights reserved. -# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -ThrowTypeError is a singleton object - -On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". - - -PASS functionCaller1 === functionCaller2 is true -PASS functionCaller1 === functionArguments1 is true -PASS functionCaller1 === argumentsCaller1 is true -PASS functionCaller1 === argumentsCallee1 is true -PASS functionCaller1 === boundCaller1 is true -PASS functionCaller1 === boundArguments1 is true -PASS functionCaller2 === functionArguments2 is true -PASS functionCaller2 === argumentsCaller2 is true -PASS functionCaller2 === argumentsCallee2 is true -PASS functionCaller2 === boundCaller2 is true -PASS functionCaller2 === boundArguments2 is true -PASS successfullyParsed is true - -TEST COMPLETE - diff --git a/deps/v8/test/webkit/strict-throw-type-error.js b/deps/v8/test/webkit/strict-throw-type-error.js deleted file mode 100644 index c9e34a3878..0000000000 --- a/deps/v8/test/webkit/strict-throw-type-error.js +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -description("ThrowTypeError is a singleton object"); - -function getter(object, name) -{ - Object.getOwnPropertyDescriptor(object, name).get; -} - -function strictArgumentsFunction1() -{ - "use strict"; - return arguments; -} -var strictArguments1 = strictArgumentsFunction1(); -var boundFunction1 = strictArgumentsFunction1.bind(); -var functionCaller1 = getter(strictArgumentsFunction1, "caller"); -var functionArguments1 = getter(strictArgumentsFunction1, "arguments"); -var argumentsCaller1 = getter(strictArguments1, "caller"); -var argumentsCallee1 = getter(strictArguments1, "callee"); -var boundCaller1 = getter(boundFunction1, "caller"); -var boundArguments1 = getter(boundFunction1, "arguments"); - -function strictArgumentsFunction2() -{ - "use strict"; - return arguments; -} -var strictArguments2 = strictArgumentsFunction2(); -var boundFunction2 = strictArgumentsFunction2.bind(); -var functionCaller2 = getter(strictArgumentsFunction2, "caller"); -var functionArguments2 = getter(strictArgumentsFunction2, "arguments"); -var argumentsCaller2 = getter(strictArguments2, "caller"); -var argumentsCallee2 = getter(strictArguments2, "callee"); -var boundCaller2 = getter(boundFunction2, "caller"); -var boundArguments2 = getter(boundFunction2, "arguments"); - -shouldBeTrue('functionCaller1 === functionCaller2'); - -shouldBeTrue('functionCaller1 === functionArguments1'); -shouldBeTrue('functionCaller1 === argumentsCaller1'); -shouldBeTrue('functionCaller1 === argumentsCallee1'); -shouldBeTrue('functionCaller1 === boundCaller1'); -shouldBeTrue('functionCaller1 === boundArguments1'); - -shouldBeTrue('functionCaller2 === functionArguments2'); -shouldBeTrue('functionCaller2 === argumentsCaller2'); -shouldBeTrue('functionCaller2 === argumentsCallee2'); -shouldBeTrue('functionCaller2 === boundCaller2'); -shouldBeTrue('functionCaller2 === boundArguments2'); - -successfullyParsed = true; |