haikuwebkit/LayoutTests/js/arrowfunction-lexical-bind-...

30 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

[ES6] Arrow function syntax. Arrow function specific features. Lexical bind "arguments" https://bugs.webkit.org/show_bug.cgi?id=145132 Patch by Skachkov Oleksandr <gskachkov@gmail.com> on 2016-01-25 Reviewed by Saam Barati. Source/JavaScriptCore: Added support of ES6 arrow function specific feature, lexical bind of arguments. http://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions-runtime-semantics-evaluation 'arguments' variable in arrow function must resolve to a binding in a lexically enclosing environment. In srict mode it points to arguments object, and in non-stric mode it points to arguments object or varible with name 'arguments' if it was declared. * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): * parser/Parser.h: (JSC::Scope::Scope): (JSC::Scope::setSourceParseMode): (JSC::Scope::isArrowFunction): (JSC::Scope::collectFreeVariables): (JSC::Scope::setIsArrowFunction): * tests/es6.yaml: * tests/stress/arrowfunction-lexical-bind-arguments-non-strict-1.js: Added. * tests/stress/arrowfunction-lexical-bind-arguments-non-strict-2.js: Added. * tests/stress/arrowfunction-lexical-bind-arguments-strict.js: Added. Source/WebInspectorUI: Current patch is implementing lexical bind of arguments, so in this callback we need to return to ordinary function. * UserInterface/Base/Object.js: (WebInspector.Object.singleFireEventListener.let.wrappedCallback): (WebInspector.Object.singleFireEventListener): LayoutTests: * js/arrowfunction-lexical-bind-arguments-non-strict-expected.txt: Added. * js/arrowfunction-lexical-bind-arguments-non-strict.html: Added. * js/arrowfunction-lexical-bind-arguments-strict-expected.txt: Added. * js/arrowfunction-lexical-bind-arguments-strict.html: Added. * js/script-tests/arrowfunction-lexical-bind-arguments-non-strict.js: Added. * js/script-tests/arrowfunction-lexical-bind-arguments-strict.js: Added. Canonical link: https://commits.webkit.org/171535@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195581 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-26 05:43:11 +00:00
Tests for ES6 arrow function lexical bind of arguments
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS arr.length is 2
PASS arr[0] is "ABC"
PASS arr[1] is "DEF"
PASS typeof arr[2] is "undefined"
PASS afFactory1('AB', 'CD', 'EF')('G', 'H') is "AB-CD-EF-G-H"
PASS (new afFactory2('P1', 'Q2', 'R3')).func('A4', 'B5') is "P1_Q2_R3_A4_B5"
PASS (new afFactory3('PQ', 'RS', 'TU')).func('VW', 'XY')('Z', 'A') is "PQ_RS_TU_VW_XY_Z_A"
PASS af5.func('VW', 'XY')('Z', '') is "GH_IJ_KL_VW_XY_Z_"
PASS objInternal.method('H') is "ABC-H"
PASS (() => arguments)() is arguments
PASS func_with_eval("abc", "def")("xyz")[0] is "abc"
PASS func_with_eval("abc", "def")("xyz")[1] is "def"
PASS af_block_scope('A', 'B')('C') is 'branch-1'
PASS af_function_scope(true, 'D', 'E')('F') is 'af_function_scope'
PASS af_mixed_scope(true, 'G', 'H')('I') is 'local-scope'
PASS test() is 40000
PASS foo(10, 11, 12).next().value()[0] is 10
PASS foo(10, 11, 12).next().value()[1] is 11
PASS foo(10, 11, 12).next().value()[2] is 12
PASS (function (a, b, c) { return (a = arguments) => {return a;}; })('1-1', '2-2', '3-3')()[1] is '2-2'
[ES6] Arrow function syntax. Arrow function specific features. Lexical bind "arguments" https://bugs.webkit.org/show_bug.cgi?id=145132 Patch by Skachkov Oleksandr <gskachkov@gmail.com> on 2016-01-25 Reviewed by Saam Barati. Source/JavaScriptCore: Added support of ES6 arrow function specific feature, lexical bind of arguments. http://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions-runtime-semantics-evaluation 'arguments' variable in arrow function must resolve to a binding in a lexically enclosing environment. In srict mode it points to arguments object, and in non-stric mode it points to arguments object or varible with name 'arguments' if it was declared. * bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator): * parser/Parser.h: (JSC::Scope::Scope): (JSC::Scope::setSourceParseMode): (JSC::Scope::isArrowFunction): (JSC::Scope::collectFreeVariables): (JSC::Scope::setIsArrowFunction): * tests/es6.yaml: * tests/stress/arrowfunction-lexical-bind-arguments-non-strict-1.js: Added. * tests/stress/arrowfunction-lexical-bind-arguments-non-strict-2.js: Added. * tests/stress/arrowfunction-lexical-bind-arguments-strict.js: Added. Source/WebInspectorUI: Current patch is implementing lexical bind of arguments, so in this callback we need to return to ordinary function. * UserInterface/Base/Object.js: (WebInspector.Object.singleFireEventListener.let.wrappedCallback): (WebInspector.Object.singleFireEventListener): LayoutTests: * js/arrowfunction-lexical-bind-arguments-non-strict-expected.txt: Added. * js/arrowfunction-lexical-bind-arguments-non-strict.html: Added. * js/arrowfunction-lexical-bind-arguments-strict-expected.txt: Added. * js/arrowfunction-lexical-bind-arguments-strict.html: Added. * js/script-tests/arrowfunction-lexical-bind-arguments-non-strict.js: Added. * js/script-tests/arrowfunction-lexical-bind-arguments-strict.js: Added. Canonical link: https://commits.webkit.org/171535@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195581 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-01-26 05:43:11 +00:00
PASS successfullyParsed is true
TEST COMPLETE