Commit 4bf531c1 authored by dslomov's avatar dslomov Committed by Commit bot

Update strict mode function declaration tests before block scoping.

R=arv@chromium.org,marja@chromium.org
BUG=v8:2198
LOG=N

Review URL: https://codereview.chromium.org/788143004

Cr-Commit-Position: refs/heads/master@{#25760}
parent 4fa7ae1c
......@@ -29,71 +29,78 @@
# A template that performs the same strict-mode test in different
# scopes (global scope, function scope, and nested function scope).
def StrictTest(name, source):
Test(name, '"use strict";\n' + source, "strict_function")
def StrictTest(name, source, legacy):
if legacy:
extra_flags = ["--noharmony-scoping"]
else:
extra_flags = []
Test(name, '"use strict";\n' + source, "strict_function",
extra_flags)
Test(name + '-infunc',
'function foo() {\n "use strict";\n' + source +'\n}\n',
"strict_function")
"strict_function",
extra_flags)
Test(name + '-infunc2',
'function foo() {\n "use strict";\n function bar() {\n' +
source +'\n }\n}\n',
"strict_function")
"strict_function",
extra_flags)
# Not testing with-scope, since with is not allowed in strict mode at all.
StrictTest("block", """
{ function foo() { } }
""")
""", True)
StrictTest("try-w-catch", """
try { function foo() { } } catch (e) { }
""")
""", True)
StrictTest("try-w-finally", """
try { function foo() { } } finally { }
""")
""", True)
StrictTest("catch", """
try { } catch (e) { function foo() { } }
""")
""", True)
StrictTest("finally", """
try { } finally { function foo() { } }
""")
""", True)
StrictTest("for", """
for (;;) { function foo() { } }
""")
""", True)
StrictTest("while", """
while (true) { function foo() { } }
""")
""", True)
StrictTest("do", """
do { function foo() { } } while (true);
""")
""", True)
StrictTest("then", """
if (true) { function foo() { } }
""")
""", True)
StrictTest("then-w-else", """
if (true) { function foo() { } } else { }
""")
""", True)
StrictTest("else", """
if (true) { } else { function foo() { } }
""")
""", True)
StrictTest("switch-case", """
switch (true) { case true: function foo() { } }
""")
""", False)
StrictTest("labeled", """
label: function foo() { }
""")
""", False)
......@@ -63,12 +63,13 @@ class PreparserTestSuite(testsuite.TestSuite):
def _ParsePythonTestTemplates(self, result, filename):
pathname = os.path.join(self.root, filename + ".pyt")
def Test(name, source, expectation):
def Test(name, source, expectation, extra_flags=[]):
source = source.replace("\n", " ")
testname = os.path.join(filename, name)
flags = ["-e", source]
if expectation:
flags += ["--throws"]
flags += extra_flags
test = testcase.TestCase(self, testname, flags=flags)
result.append(test)
def Template(name, source):
......
......@@ -35,6 +35,18 @@
'11.2.3_b': [FAIL],
'12.2.3_b': [FAIL],
############################### ES6 ###################################
# ES6 allows block-local functions.
'Sbp_A1_T1': [PASS, FAIL],
'Sbp_A2_T1': [PASS, FAIL],
'Sbp_A2_T2': [PASS, FAIL],
'Sbp_A3_T1': [PASS, FAIL],
'Sbp_A3_T2': [PASS, FAIL],
'Sbp_A4_T1': [PASS, FAIL],
'Sbp_A4_T2': [PASS, FAIL],
'Sbp_A5_T1': [PASS], # Test is broken (strict reference to unbound variable)
'Sbp_A5_T2': [PASS, FAIL],
######################## NEEDS INVESTIGATION ###########################
# These test failures are specific to the intl402 suite and need investigation
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment