haikuwebkit/LayoutTests/js/class-syntax-call-expected.txt

18 lines
732 B
Plaintext
Raw Permalink Normal View History

Enable ES6 classes by default https://bugs.webkit.org/show_bug.cgi?id=142774 Reviewed by Gavin Barraclough. .: * Source/cmake/WebKitFeatures.cmake: Source/JavaScriptCore: Enabled the feature and unskipped tests. * Configurations/FeatureDefines.xcconfig: * tests/stress/class-syntax-no-loop-tdz.js: * tests/stress/class-syntax-no-tdz-in-catch.js: * tests/stress/class-syntax-no-tdz-in-conditional.js: * tests/stress/class-syntax-no-tdz-in-loop-no-inline-super.js: * tests/stress/class-syntax-no-tdz-in-loop.js: * tests/stress/class-syntax-no-tdz.js: * tests/stress/class-syntax-tdz-in-catch.js: * tests/stress/class-syntax-tdz-in-conditional.js: * tests/stress/class-syntax-tdz-in-loop.js: * tests/stress/class-syntax-tdz.js: Source/WebCore: * Configurations/FeatureDefines.xcconfig: Source/WebKit/mac: * Configurations/FeatureDefines.xcconfig: Source/WebKit2: * Configurations/FeatureDefines.xcconfig: Source/WTF: * wtf/FeatureDefines.h: Tools: * Scripts/webkitperl/FeatureList.pm: LayoutTests: Unskipped tests and also fixed tests so that they can run under run-javascript-tests. * TestExpectations: Unskipped tests. * js/class-syntax-call-expected.txt: * js/class-syntax-declaration-expected.txt: * js/class-syntax-default-constructor-expected.txt: * js/class-syntax-expression-expected.txt: * js/class-syntax-extends-expected.txt: * js/class-syntax-super-expected.txt: * js/dom/reserved-words-as-property-expected.txt: Rebaselined now that "class" is a non-reserved keyword. * js/script-tests/class-syntax-call.js: Don't refer to "window" object as it doesn't exit when ran inside jsc. * js/script-tests/class-syntax-declaration.js: Rebaselined after r181611, which added default constructor support. * js/script-tests/class-syntax-default-constructor.js: Don't refer to "window" object. Also replaced shouldNotBe by an explicit !== check as the former is not supported when ran inside jsc. * js/script-tests/class-syntax-expression.js: Rebaselined after r181611. * js/script-tests/class-syntax-extends.js: Ditto. Also replaced evalAndLog by shouldNotThrow as the former is not supported inside jsc. * js/script-tests/class-syntax-super.js: Don't refer to "window" object as it doesn't exist inside jsc. * sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.11-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.27-expected.txt: * sputnik/Conformance/07_Lexical_Conventions/7.5_Tokens/7.5.3_Future_Reserved_Words/S7.5.3_A1.5-expected.txt: Canonical link: https://commits.webkit.org/160789@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181618 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-17 05:55:46 +00:00
Tests for calling the constructors of ES6 classes
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
ES6 class syntax should use block scoping https://bugs.webkit.org/show_bug.cgi?id=142567 Reviewed by Geoffrey Garen. Source/JavaScriptCore: We treat class declarations like we do "let" declarations. The class name is under TDZ until the class declaration statement is evaluated. Class declarations also follow the same rules as "let": No duplicate definitions inside a lexical environment. * parser/ASTBuilder.h: (JSC::ASTBuilder::createClassDeclStatement): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseClassDeclaration): * tests/stress/class-syntax-block-scoping.js: Added. (assert): (truth): (.): * tests/stress/class-syntax-definition-semantics.js: Added. (shouldBeSyntaxError): (shouldNotBeSyntaxError): (truth): * tests/stress/class-syntax-tdz.js: (assert): (shouldThrowTDZ): (truth): (.): LayoutTests: * js/class-constructor-return-expected.txt: * js/class-syntax-call-expected.txt: * js/class-syntax-declaration-expected.txt: * js/class-syntax-default-constructor-expected.txt: * js/class-syntax-extends-expected.txt: * js/class-syntax-name-expected.txt: * js/class-syntax-super-expected.txt: * js/script-tests/class-constructor-return.js: (shouldThrow): (shouldNotThrow): (shouldBeTrue): (shouldBeFalse): * js/script-tests/class-syntax-call.js: (A): (B): (shouldThrow): (shouldNotThrow): * js/script-tests/class-syntax-declaration.js: (shouldThrow): (shouldNotThrow): (shouldBe): * js/script-tests/class-syntax-default-constructor.js: (shouldThrow): (shouldBe): (shouldBeTrue): (assert): (A): (B): * js/script-tests/class-syntax-extends.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (Base): (Base.prototype.baseMethod): * js/script-tests/class-syntax-name.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (runTestShouldBe): * js/script-tests/class-syntax-super.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (shouldBeFalse): Canonical link: https://commits.webkit.org/165577@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-07-31 21:05:19 +00:00
PASS new A
PASS A():::"TypeError: Cannot call a class constructor without |new|"
ES6 class syntax should use block scoping https://bugs.webkit.org/show_bug.cgi?id=142567 Reviewed by Geoffrey Garen. Source/JavaScriptCore: We treat class declarations like we do "let" declarations. The class name is under TDZ until the class declaration statement is evaluated. Class declarations also follow the same rules as "let": No duplicate definitions inside a lexical environment. * parser/ASTBuilder.h: (JSC::ASTBuilder::createClassDeclStatement): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseClassDeclaration): * tests/stress/class-syntax-block-scoping.js: Added. (assert): (truth): (.): * tests/stress/class-syntax-definition-semantics.js: Added. (shouldBeSyntaxError): (shouldNotBeSyntaxError): (truth): * tests/stress/class-syntax-tdz.js: (assert): (shouldThrowTDZ): (truth): (.): LayoutTests: * js/class-constructor-return-expected.txt: * js/class-syntax-call-expected.txt: * js/class-syntax-declaration-expected.txt: * js/class-syntax-default-constructor-expected.txt: * js/class-syntax-extends-expected.txt: * js/class-syntax-name-expected.txt: * js/class-syntax-super-expected.txt: * js/script-tests/class-constructor-return.js: (shouldThrow): (shouldNotThrow): (shouldBeTrue): (shouldBeFalse): * js/script-tests/class-syntax-call.js: (A): (B): (shouldThrow): (shouldNotThrow): * js/script-tests/class-syntax-declaration.js: (shouldThrow): (shouldNotThrow): (shouldBe): * js/script-tests/class-syntax-default-constructor.js: (shouldThrow): (shouldBe): (shouldBeTrue): (assert): (A): (B): * js/script-tests/class-syntax-extends.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (Base): (Base.prototype.baseMethod): * js/script-tests/class-syntax-name.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (runTestShouldBe): * js/script-tests/class-syntax-super.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (shouldBeFalse): Canonical link: https://commits.webkit.org/165577@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-07-31 21:05:19 +00:00
PASS new B
PASS B():::"TypeError: Cannot call a class constructor without |new|"
ES6 class syntax should use block scoping https://bugs.webkit.org/show_bug.cgi?id=142567 Reviewed by Geoffrey Garen. Source/JavaScriptCore: We treat class declarations like we do "let" declarations. The class name is under TDZ until the class declaration statement is evaluated. Class declarations also follow the same rules as "let": No duplicate definitions inside a lexical environment. * parser/ASTBuilder.h: (JSC::ASTBuilder::createClassDeclStatement): * parser/Parser.cpp: (JSC::Parser<LexerType>::parseClassDeclaration): * tests/stress/class-syntax-block-scoping.js: Added. (assert): (truth): (.): * tests/stress/class-syntax-definition-semantics.js: Added. (shouldBeSyntaxError): (shouldNotBeSyntaxError): (truth): * tests/stress/class-syntax-tdz.js: (assert): (shouldThrowTDZ): (truth): (.): LayoutTests: * js/class-constructor-return-expected.txt: * js/class-syntax-call-expected.txt: * js/class-syntax-declaration-expected.txt: * js/class-syntax-default-constructor-expected.txt: * js/class-syntax-extends-expected.txt: * js/class-syntax-name-expected.txt: * js/class-syntax-super-expected.txt: * js/script-tests/class-constructor-return.js: (shouldThrow): (shouldNotThrow): (shouldBeTrue): (shouldBeFalse): * js/script-tests/class-syntax-call.js: (A): (B): (shouldThrow): (shouldNotThrow): * js/script-tests/class-syntax-declaration.js: (shouldThrow): (shouldNotThrow): (shouldBe): * js/script-tests/class-syntax-default-constructor.js: (shouldThrow): (shouldBe): (shouldBeTrue): (assert): (A): (B): * js/script-tests/class-syntax-extends.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (Base): (Base.prototype.baseMethod): * js/script-tests/class-syntax-name.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (runTestShouldBe): * js/script-tests/class-syntax-super.js: (shouldThrow): (shouldNotThrow): (shouldBe): (shouldBeTrue): (shouldBeFalse): Canonical link: https://commits.webkit.org/165577@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@187680 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-07-31 21:05:19 +00:00
PASS new (class { constructor() {} })()
PASS (class { constructor() {} })():::"TypeError: Cannot call a class constructor without |new|"
PASS new (class extends null { constructor() { super() } })():::"TypeError: function is not a constructor (evaluating 'super()')"
PASS (class extends null { constructor() { super() } })():::"TypeError: Cannot call a class constructor without |new|"
Class constructor should throw TypeError when "called" https://bugs.webkit.org/show_bug.cgi?id=142566 Reviewed by Michael Saboff. Source/JavaScriptCore: Added ConstructorKind::None to denote code that doesn't belong to an ES6 class. This allows BytecodeGenerator to emit code to throw TypeError when generating code block to call ES6 class constructors. Most of changes are about increasing the number of bits to store ConstructorKind from one bit to two bits. * bytecode/UnlinkedCodeBlock.cpp: (JSC::generateFunctionCodeBlock): (JSC::UnlinkedFunctionExecutable::UnlinkedFunctionExecutable): (JSC::UnlinkedCodeBlock::UnlinkedCodeBlock): * bytecode/UnlinkedCodeBlock.h: (JSC::ExecutableInfo::ExecutableInfo): (JSC::ExecutableInfo::needsActivation): (JSC::ExecutableInfo::usesEval): (JSC::ExecutableInfo::isStrictMode): (JSC::ExecutableInfo::isConstructor): (JSC::ExecutableInfo::isBuiltinFunction): (JSC::ExecutableInfo::constructorKind): (JSC::UnlinkedFunctionExecutable::constructorKind): (JSC::UnlinkedCodeBlock::constructorKind): (JSC::UnlinkedFunctionExecutable::constructorKindIsDerived): Deleted. (JSC::UnlinkedCodeBlock::constructorKindIsDerived): Deleted. * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::generate): Don't emit bytecode when we had already emitted code to throw TypeError. (JSC::BytecodeGenerator::BytecodeGenerator): Emit code to throw TypeError when generating code to call. (JSC::BytecodeGenerator::emitReturn): * bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::constructorKind): (JSC::BytecodeGenerator::constructorKindIsDerived): Deleted. * bytecompiler/NodesCodegen.cpp: (JSC::ThisNode::emitBytecode): (JSC::FunctionCallValueNode::emitBytecode): * parser/Nodes.cpp: (JSC::FunctionBodyNode::FunctionBodyNode): * parser/Nodes.h: * parser/Parser.cpp: (JSC::Parser<LexerType>::parseFunctionInfo): Renamed the incoming function argument to ownerClassKind. Set constructorKind to Base or Derived only if we're parsing a constructor. (JSC::Parser<LexerType>::parseFunctionDeclaration): (JSC::Parser<LexerType>::parseClass): Don't parse static methods using MethodMode since that would result in BytecodeGenerator erroneously treating static method named "constructor" as a class constructor. (JSC::Parser<LexerType>::parsePropertyMethod): (JSC::Parser<LexerType>::parsePrimaryExpression): * parser/Parser.h: * parser/ParserModes.h: * runtime/Executable.h: (JSC::EvalExecutable::executableInfo): (JSC::ProgramExecutable::executableInfo): LayoutTests: Added tests for calling class constructors. * TestExpectations: Skipped the test since ES6 class syntax isn't enabled by default. * js/class-syntax-call-expected.txt: Added. * js/class-syntax-call.html: Added. * js/script-tests/class-syntax-call.js: Added. Canonical link: https://commits.webkit.org/160694@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@181490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2015-03-13 23:01:51 +00:00
PASS successfullyParsed is true
TEST COMPLETE