Commit 7e6bd6d6 authored by barraclough@apple.com's avatar barraclough@apple.com

Bug 52079 - Syntax errors should be early errors.

Reviewed by Oliver Hunt.

Source/JavaScriptCore: 

From chapter 16 the spec:
    An implementation must report most errors at the time the relevant ECMAScript language construct is
    evaluated. An early error is an error that can be detected and reported prior to the evaluation of
    any construct in the Program containing the error. An implementation must report early errors in a
    Program prior to the first evaluation of that Program. Early errors in eval code are reported at
    the time eval is called but prior to evaluation of any construct within the eval code. All errors
    that are not early errors are runtime errors.

    An implementation must treat any instance of the following kinds of errors as an early error:
        * Any syntax error."

* JavaScriptCore.xcodeproj/project.pbxproj:
    Added new files.
* bytecode/CodeBlock.cpp:
    Removed op_throw_syntax_error.
* bytecode/Opcode.h:
    Removed op_throw_syntax_error.
* bytecompiler/BytecodeGenerator.cpp:
(JSC::BytecodeGenerator::generate):
    If m_expressionTooDeep then throw a runtime error.
(JSC::BytecodeGenerator::BytecodeGenerator):
    Initialize m_expressionTooDeep.
(JSC::BytecodeGenerator::emitThrowExpressionTooDeepException):
    Sets m_expressionTooDeep.
* bytecompiler/BytecodeGenerator.h:
    Added m_expressionTooDeep, removed emitThrowSyntaxError.
* bytecompiler/NodesCodegen.cpp:
(JSC::RegExpNode::emitBytecode):
(JSC::ContinueNode::emitBytecode):
(JSC::BreakNode::emitBytecode):
(JSC::ReturnNode::emitBytecode):
(JSC::LabelNode::emitBytecode):
    Conditions that threw syntax error are now handled during parsing;
    during bytecompilation these are now just ASSERTs.
* interpreter/Interpreter.cpp:
(JSC::Interpreter::privateExecute):
* jit/JIT.cpp:
(JSC::JIT::privateCompileMainPass):
* jit/JIT.h:
* jit/JITOpcodes.cpp:
* jit/JITOpcodes32_64.cpp:
* jit/JITStubs.cpp:
* jit/JITStubs.h:
    Removed op_throw_syntax_error.
* parser/ASTBuilder.h:
(JSC::ASTBuilder::createRegExp):
    Renamed; added syntax check.
* parser/JSParser.cpp:
(JSC::JSParser::breakIsValid):
(JSC::JSParser::hasLabel):
(JSC::JSParser::Scope::Scope):
(JSC::JSParser::Scope::setIsFunction):
(JSC::JSParser::Scope::isFunctionBoundary):
(JSC::JSParser::ScopeRef::hasContainingScope):
(JSC::JSParser::ScopeRef::containingScope):
(JSC::JSParser::AutoPopScopeRef::AutoPopScopeRef):
(JSC::JSParser::AutoPopScopeRef::~AutoPopScopeRef):
(JSC::JSParser::AutoPopScopeRef::setPopped):
(JSC::JSParser::popScopeInternal):
(JSC::JSParser::popScope):
(JSC::jsParse):
(JSC::JSParser::JSParser):
(JSC::JSParser::parseProgram):
(JSC::JSParser::parseBreakStatement):
(JSC::JSParser::parseContinueStatement):
(JSC::JSParser::parseReturnStatement):
(JSC::JSParser::parseTryStatement):
(JSC::JSParser::parseFunctionInfo):
(JSC::JSParser::parseExpressionOrLabelStatement):
(JSC::JSParser::parsePrimaryExpression):
* parser/JSParser.h:
* parser/Nodes.h:
* parser/Parser.cpp:
(JSC::Parser::parse):
* parser/SyntaxChecker.h:
(JSC::SyntaxChecker::createRegExp):
    Renamed; added syntax check.
* runtime/ExceptionHelpers.cpp:
(JSC::createOutOfMemoryError):
(JSC::throwOutOfMemoryError):
* runtime/ExceptionHelpers.h:
    Broke out createOutOfMemoryError.
* runtime/Executable.cpp:
(JSC::EvalExecutable::compileInternal):
(JSC::ProgramExecutable::compileInternal):
(JSC::FunctionExecutable::compileForCallInternal):
(JSC::FunctionExecutable::compileForConstructInternal):
    Add check for exception after bytecode generation.
* runtime/RegExpConstructor.cpp:
(JSC::constructRegExp):
* runtime/RegExpPrototype.cpp:
(JSC::regExpProtoFuncCompile):
    RegExp error prefixes not included in error string.
* yarr/RegexParser.h:
(JSC::Yarr::Parser::parse):
    Removed regexBegin/regexEnd/regexError.
* yarr/RegexPattern.cpp:
(JSC::Yarr::RegexPatternConstructor::regexBegin):
    Removed regexEnd/regexError.
(JSC::Yarr::compileRegex):
    Add call to regexBegin (no longer called from the parser).
* yarr/YarrSyntaxChecker.cpp: Added.
(JSC::Yarr::SyntaxChecker::assertionBOL):
(JSC::Yarr::SyntaxChecker::assertionEOL):
(JSC::Yarr::SyntaxChecker::assertionWordBoundary):
(JSC::Yarr::SyntaxChecker::atomPatternCharacter):
(JSC::Yarr::SyntaxChecker::atomBuiltInCharacterClass):
(JSC::Yarr::SyntaxChecker::atomCharacterClassBegin):
(JSC::Yarr::SyntaxChecker::atomCharacterClassAtom):
(JSC::Yarr::SyntaxChecker::atomCharacterClassRange):
(JSC::Yarr::SyntaxChecker::atomCharacterClassBuiltIn):
(JSC::Yarr::SyntaxChecker::atomCharacterClassEnd):
(JSC::Yarr::SyntaxChecker::atomParenthesesSubpatternBegin):
(JSC::Yarr::SyntaxChecker::atomParentheticalAssertionBegin):
(JSC::Yarr::SyntaxChecker::atomParenthesesEnd):
(JSC::Yarr::SyntaxChecker::atomBackReference):
(JSC::Yarr::SyntaxChecker::quantifyAtom):
(JSC::Yarr::SyntaxChecker::disjunction):
(JSC::Yarr::checkSyntax):
* yarr/YarrSyntaxChecker.h: Added.
    Check RegExp syntax.

LayoutTests: 

Fix syntax errors in layout tests, and update expected results.

* editing/selection/select-crash-001.html:
* editing/selection/select-crash-002.html:
* fast/canvas/webgl/renderbuffer-initialization.html:
* fast/forms/25153.html:
* fast/forms/textfield-drag-into-disabled.html:
* fast/js/exception-codegen-crash-expected.txt:
* fast/js/exception-codegen-crash.html:
* fast/js/kde/parse-expected.txt:
* fast/js/kde/script-tests/parse.js:
* fast/js/large-expressions-expected.txt:
* fast/js/named-function-expression-expected.txt:
* fast/js/parser-syntax-check-expected.txt:
* fast/js/script-tests/large-expressions.js:
* fast/js/script-tests/named-function-expression.js:
* fast/js/script-tests/parser-syntax-check.js:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A11.1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A11_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A12.1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A12_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T4-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A6-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A8_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A8_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T4-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A6-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A8_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A8_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T10-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T4-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T5-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T6-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T7-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T8-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T9-expected.txt:
* http/tests/security/isolatedWorld/events.html:
* http/tests/security/isolatedWorld/userGestureEvents.html:
* svg/custom/resources/use-instanceRoot-event-listeners.js:
* svg/custom/rgbcolor-syntax.svg:
* svg/custom/use-instanceRoot-modifications.svg:
* svg/custom/use-property-changes-through-svg-dom.svg:
* webarchive/adopt-attribute-styled-body-webarchive-expected.webarchive:
* webarchive/resources/adopt-attribute-styled-body-iframe.html:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75408 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f4be0920
2011-01-10 Gavin Barraclough <barraclough@apple.com>
Reviewed by Oliver Hunt.
Bug 52079 - Syntax errors should be early errors.
Fix syntax errors in layout tests, and update expected results.
* editing/selection/select-crash-001.html:
* editing/selection/select-crash-002.html:
* fast/canvas/webgl/renderbuffer-initialization.html:
* fast/forms/25153.html:
* fast/forms/textfield-drag-into-disabled.html:
* fast/js/exception-codegen-crash-expected.txt:
* fast/js/exception-codegen-crash.html:
* fast/js/kde/parse-expected.txt:
* fast/js/kde/script-tests/parse.js:
* fast/js/large-expressions-expected.txt:
* fast/js/named-function-expression-expected.txt:
* fast/js/parser-syntax-check-expected.txt:
* fast/js/script-tests/large-expressions.js:
* fast/js/script-tests/named-function-expression.js:
* fast/js/script-tests/parser-syntax-check.js:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A11.1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A11_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A12.1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.6_Iteration_Statements/12.6.3_The_for_Statement/S12.6.3_A12_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A1_T4-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A5_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A6-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A8_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.7_The_continue_Statement/S12.7_A8_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A1_T4-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A5_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A6-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A8_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.8_The_break_Statement/S12.8_A8_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T1-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T10-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T2-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T3-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T4-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T5-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T6-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T7-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T8-expected.txt:
* fast/js/sputnik/Conformance/12_Statement/12.9_The_return_Statement/S12.9_A1_T9-expected.txt:
* http/tests/security/isolatedWorld/events.html:
* http/tests/security/isolatedWorld/userGestureEvents.html:
* svg/custom/resources/use-instanceRoot-event-listeners.js:
* svg/custom/rgbcolor-syntax.svg:
* svg/custom/use-instanceRoot-modifications.svg:
* svg/custom/use-property-changes-through-svg-dom.svg:
* webarchive/adopt-attribute-styled-body-webarchive-expected.webarchive:
* webarchive/resources/adopt-attribute-styled-body-iframe.html:
2011-01-10 Tony Chang <tony@chromium.org>
Unreviewed, remove duplicate test expectation for gif-loop-count.
......
......@@ -10,14 +10,14 @@ html,body,h1{font-size:100%;font-style:inherit;font-weight:inherit;margin:0;padd
<body>
<h1 id="test">The Longest German Word?</h1>
<script type="text/javascript" language="javascript">
if (!window.layoutTestController)
return;
layoutTestController.dumpAsText();
var element = document.getElementById("test");
var selection = window.getSelection();
selection.setPosition(element.firstChild, 2);
extendSelectionForwardByCharacterCommand();
copyCommand();
if (window.layoutTestController) {
layoutTestController.dumpAsText();
var element = document.getElementById("test");
var selection = window.getSelection();
selection.setPosition(element.firstChild, 2);
extendSelectionForwardByCharacterCommand();
copyCommand();
}
</script>
</body>
</html>
......@@ -10,11 +10,11 @@ html,body,h1{font-size:100%;font-style:inherit;font-weight:inherit;margin:0;padd
<body>
<h1>The Longest German Word?</h1>
<script type="text/javascript" language="javascript">
if (!window.layoutTestController)
return;
layoutTestController.dumpAsText();
selectAllCommand();
copyCommand();
if (window.layoutTestController) {
layoutTestController.dumpAsText();
selectAllCommand();
copyCommand();
}
</script>
</body>
</html>
......@@ -66,24 +66,22 @@ description('Verify renderbuffers are initialized to 0 before being read in WebG
var canvas = document.getElementById("testbed");
var gl = canvas.getContext("experimental-webgl");
if (!gl) {
testFailed('canvas.getContext() failed');
return false;
}
if (gl) {
runTest(gl, canvas.width, canvas.height);
runTest(gl, canvas.width, canvas.height);
// Testing that canvas resizing will clear the buffers with 0 instead of the current clear values.
gl.clearColor(1, 0, 0, 1);
canvas.width += 1;
canvas.height += 1;
runTest(gl, canvas.width, canvas.height);
// Testing that canvas resizing will clear the buffers with 0 instead of the current clear values.
gl.clearColor(1, 0, 0, 1);
canvas.width += 1;
canvas.height += 1;
runTest(gl, canvas.width, canvas.height);
// Testing buffer clearing won't change the clear values.
var clearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE);
shouldBe("clearColor", "[1, 0, 0, 1]");
// Testing buffer clearing won't change the clear values.
var clearColor = gl.getParameter(gl.COLOR_CLEAR_VALUE);
shouldBe("clearColor", "[1, 0, 0, 1]");
successfullyParsed = true;
successfullyParsed = true;
} else
testFailed('canvas.getContext() failed');
</script>
<script src="../../js/resources/js-test-post.js"></script>
</body>
......
......@@ -2,18 +2,18 @@ This tests to make sure that clicking inside a text field places the caret in it
<input id="textfield" onFocus="window.scrollBy(0, 40)" value="click in me"><br>
<div style="height: 1500px;">
<script>
if (!window.layoutTestController)
return;
window.layoutTestController.dumpAsText();
textfield = document.getElementById("textfield");
// Click near the end of the field so that the caret after all of the text inside it.
x = textfield.offsetParent.offsetLeft + textfield.offsetLeft + textfield.offsetWidth - 5;
y = textfield.offsetParent.offsetTop + textfield.offsetTop + textfield.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
if (textfield.selectionStart == textfield.value.length && textfield.selectionEnd == textfield.value.length)
document.body.innerText = "Success"
else
document.body.innerText = "Failure. Expected selection to be after all of the text in the text field."
if (window.layoutTestController) {
window.layoutTestController.dumpAsText();
textfield = document.getElementById("textfield");
// Click near the end of the field so that the caret after all of the text inside it.
x = textfield.offsetParent.offsetLeft + textfield.offsetLeft + textfield.offsetWidth - 5;
y = textfield.offsetParent.offsetTop + textfield.offsetTop + textfield.offsetHeight / 2;
eventSender.mouseMoveTo(x, y);
eventSender.mouseDown();
eventSender.mouseUp();
if (textfield.selectionStart == textfield.value.length && textfield.selectionEnd == textfield.value.length)
document.body.innerText = "Success"
else
document.body.innerText = "Failure. Expected selection to be after all of the text in the text field."
}
</script>
......@@ -17,21 +17,20 @@ var fieldY = field.offsetTop + field.offsetHeight / 2;
window.getSelection().setBaseAndExtent(text, 0, text, 1);
if (!window.layoutTestController)
return;
if (window.layoutTestController) {
eventSender.mouseMoveTo(textX, textY);
eventSender.mouseDown();
// leap forward so mouseDown will kick off a drag instead of starting a new selection.
eventSender.leapForward(1000);
eventSender.mouseMoveTo(textX, textY);
eventSender.mouseDown();
// leap forward so mouseDown will kick off a drag instead of starting a new selection.
eventSender.leapForward(1000);
eventSender.mouseMoveTo(fieldX, fieldY);
eventSender.mouseUp();
eventSender.mouseMoveTo(fieldX, fieldY);
eventSender.mouseUp();
layoutTestController.dumpAsText();
var resultText = "FAIL"
if (!field.value)
resultText = "PASS -- http://bugs.webkit.org/show_bug.cgi?id=10177";
document.body.innerText = resultText;
layoutTestController.dumpAsText();
var resultText = "FAIL"
if (!field.value)
resultText = "PASS -- http://bugs.webkit.org/show_bug.cgi?id=10177";
document.body.innerText = resultText;
}
</script>
</body>
CONSOLE MESSAGE: line 1: ReferenceError: Postfix ++ operator applied to value that is not a reference.
This page tests some conditions that used to cause crashes during codegen.
If you don't crash, you pass.
......@@ -14,5 +14,8 @@ var scripts = [
"(1 = 1).x;"
];
eval(scripts.join("\n"));
try {
eval(scripts.join("\n"));
} catch (e) {
}
</script>
......@@ -3,6 +3,18 @@ KDE JS Test
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS function test() { return;}; lab: 1 is 1
PASS function test() { while(0) break; } lab: 1 is 1
PASS function test() { while(0) continue; } lab: 1 is 1
PASS function test() { return lab;} lab: 1 is 1
PASS function test() { while(0) break lab; } lab: 1 threw exception SyntaxError: Parse error.
PASS function test() { while(0) continue lab; } lab: 1 threw exception SyntaxError: Parse error.
PASS function test() { return } lab: 1 is 1
PASS function test() { while(0) break } lab: 1 is 1
PASS function test() { while(0) continue } lab: 1 is 1
PASS function test() { return 0 } lab: 1 is 1
PASS function test() { while(0) break lab } lab: 1 threw exception SyntaxError: Parse error.
PASS function test() { while(0) continue lab } lab: 1 threw exception SyntaxError: Parse error.
PASS var éĀʯΈᢨ = 101; éĀʯΈᢨ; is 101
PASS var f÷; threw exception SyntaxError: Parse error.
PASS var \u0061 = 102; a is 102
......
function test() { return;}
function test() { while(0) break; }
function test() { while(0) continue; }
function test() { return lab;}
function test() { while(0) break lab; }
function test() { while(0) continue lab; }
function test() { return }
function test() { while(0) break }
function test() { while(0) continue }
function test() { return 0 }
function test() { while(0) break lab }
function test() { while(0) continue lab }
lab:
// Check parsing of nested scopes; a couple of the break/continue to label cases are invalid.
shouldBe("function test() { return;}; lab: 1", "1");
shouldBe("function test() { while(0) break; } lab: 1", "1");
shouldBe("function test() { while(0) continue; } lab: 1", "1");
shouldBe("function test() { return lab;} lab: 1", "1");
shouldThrow("function test() { while(0) break lab; } lab: 1");
shouldThrow("function test() { while(0) continue lab; } lab: 1");
shouldBe("function test() { return } lab: 1", "1");
shouldBe("function test() { while(0) break } lab: 1", "1");
shouldBe("function test() { while(0) continue } lab: 1", "1");
shouldBe("function test() { return 0 } lab: 1", "1");
shouldThrow("function test() { while(0) break lab } lab: 1");
shouldThrow("function test() { while(0) continue lab } lab: 1");
a = 1
b = 123 // comment
......
......@@ -6,7 +6,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
PASS eval(repeatedExpression("letterA", "+", 100)) is repeatedString("a", 100)
PASS eval(repeatedExpression("letterA", "+", 1000)) is repeatedString("a", 1000)
PASS eval(repeatedExpression("letterA", "+", 10000)) is repeatedString("a", 10000)
PASS eval(repeatedExpression("letterA", "+", 100000)) threw exception SyntaxError: Expression too deep.
PASS eval(repeatedExpression("letterA", "+", 100000)) threw exception Error: Out of memory.
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -16,7 +16,7 @@ PASS (function Foo(){ return 1; }); try { Foo(); throw "FuncExpr was stored"; }
recursion is possible, though
PASS var ctr = 3; var x = (function Named(a,b){ if(--ctr) return 2 * Named(a,b); else return a + b; }); x(5,6) is 44
regression test where kjs regarded an anonymous function declaration (which is illegal) as a FunctionExpr
PASS try { eval("function(){ return 2; };"); return 0; } catch(e) { 1; } is 1
PASS var hadError = 0; try { eval("function(){ return 2; };"); } catch(e) { hadError = 1; }; hadError; is 1
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -265,8 +265,8 @@ PASS Valid: "do while (0) if (a) {} else y; while(0)"
PASS Valid: "function f() { do while (0) if (a) {} else y; while(0) }"
PASS Valid: "if (a) while (b) if (c) with(d) {} else e; else f"
PASS Valid: "function f() { if (a) while (b) if (c) with(d) {} else e; else f }"
PASS Valid: "break ; break your_limits ; continue ; continue living ; debugger"
PASS Valid: "function f() { break ; break your_limits ; continue ; continue living ; debugger }"
PASS Invalid: "break ; break your_limits ; continue ; continue living ; debugger"
PASS Invalid: "function f() { break ; break your_limits ; continue ; continue living ; debugger }"
PASS Invalid: "debugger X"
PASS Invalid: "function f() { debugger X }"
PASS Invalid: "break 0.2"
......@@ -452,8 +452,8 @@ PASS Invalid: "function f() { for (var (a) in b) { } }"
PASS Valid: "for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}"
PASS Valid: "function f() { for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {} }"
try statement
PASS Valid: "try { break } catch(e) {}"
PASS Valid: "function f() { try { break } catch(e) {} }"
PASS Invalid: "try { break } catch(e) {}"
PASS Invalid: "function f() { try { break } catch(e) {} }"
PASS Valid: "try {} finally { c++ }"
PASS Valid: "function f() { try {} finally { c++ } }"
PASS Valid: "try { with (x) { } } catch(e) {} finally { if (a) ; }"
......
......@@ -27,6 +27,6 @@ function repeatedString(value, count)
shouldBe('eval(repeatedExpression("letterA", "+", 100))', 'repeatedString("a", 100)');
shouldBe('eval(repeatedExpression("letterA", "+", 1000))', 'repeatedString("a", 1000)');
shouldBe('eval(repeatedExpression("letterA", "+", 10000))', 'repeatedString("a", 10000)');
shouldThrow('eval(repeatedExpression("letterA", "+", 100000))', '"SyntaxError: Expression too deep"');
shouldThrow('eval(repeatedExpression("letterA", "+", 100000))');
var successfullyParsed = true;
......@@ -23,6 +23,6 @@ debug("recursion is possible, though");
shouldBe("var ctr = 3; var x = (function Named(a,b){ if(--ctr) return 2 * Named(a,b); else return a + b; }); x(5,6)", "44");
debug("regression test where kjs regarded an anonymous function declaration (which is illegal) as a FunctionExpr");
shouldBe('try { eval("function(){ return 2; };"); return 0; } catch(e) { 1; }', "1");
shouldBe('var hadError = 0; try { eval("function(){ return 2; };"); } catch(e) { hadError = 1; }; hadError;', "1");
var successfullyParsed = true;
......@@ -195,7 +195,7 @@ invalid("do g; while ((4)");
valid ("{ { do do do ; while(0) while(0) while(0) } }");
valid ("do while (0) if (a) {} else y; while(0)");
valid ("if (a) while (b) if (c) with(d) {} else e; else f");
valid ("break ; break your_limits ; continue ; continue living ; debugger");
invalid("break ; break your_limits ; continue ; continue living ; debugger");
invalid("debugger X");
invalid("break 0.2");
invalid("continue a++");
......@@ -296,7 +296,7 @@ valid ("for (var a = 7, b = c < d >= d ; f()[6]++ ; --i()[1]++ ) {}");
debug ("try statement");
valid ("try { break } catch(e) {}");
invalid("try { break } catch(e) {}");
valid ("try {} finally { c++ }");
valid ("try { with (x) { } } catch(e) {} finally { if (a) ; }");
invalid("try {}");
......
CONSOLE MESSAGE: line 82: SyntaxError: Parse error
S12.6.3_A11.1_T3
PASS SyntaxError: Undefined label: 'nonexist'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 82: SyntaxError: Parse error
S12.6.3_A11_T3
PASS SyntaxError: Undefined label: 'nonexist'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 82: SyntaxError: Parse error
S12.6.3_A12.1_T3
PASS SyntaxError: Undefined label: 'nonexist'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 82: SyntaxError: Parse error
S12.6.3_A12_T3
PASS SyntaxError: Undefined label: 'nonexist'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 80: SyntaxError: Parse error
S12.7_A1_T1
PASS SyntaxError: Invalid continue statement.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 81: SyntaxError: Parse error
S12.7_A1_T2
PASS SyntaxError: Undefined label: 'LABEL'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 82: SyntaxError: Parse error
S12.7_A1_T3
PASS SyntaxError: Undefined label: 'LABEL'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 81: SyntaxError: Parse error
S12.7_A1_T4
PASS SyntaxError: Invalid continue statement.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 80: SyntaxError: Parse error
S12.7_A5_T1
PASS SyntaxError: Undefined label: 'LABEL_ANOTHER_LOOP'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 80: SyntaxError: Parse error
S12.7_A5_T2
PASS SyntaxError: Undefined label: 'IN_DO_FUNC'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 81: SyntaxError: Parse error
S12.7_A5_T3
PASS SyntaxError: Undefined label: 'LABEL_IN'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 80: SyntaxError: Parse error
S12.7_A6
PASS SyntaxError: Undefined label: 'LABEL1'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 86: SyntaxError: Parse error
S12.7_A8_T1
PASS SyntaxError: Undefined label: 'LABEL2'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 87: SyntaxError: Parse error
S12.7_A8_T2
PASS SyntaxError: Invalid continue statement.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 80: SyntaxError: Parse error
S12.8_A1_T1
PASS SyntaxError: Invalid break statement.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 81: SyntaxError: Parse error
S12.8_A1_T2
PASS SyntaxError: Undefined label: 'LABEL'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 81: SyntaxError: Parse error
S12.8_A1_T3
PASS SyntaxError: Invalid break statement.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 82: SyntaxError: Parse error
S12.8_A1_T4
PASS SyntaxError: Undefined label: 'LABEL'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 82: SyntaxError: Parse error
S12.8_A5_T1
PASS SyntaxError: Undefined label: 'LABEL_ANOTHER_LOOP'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 82: SyntaxError: Parse error
S12.8_A5_T2
PASS SyntaxError: Undefined label: 'IN_DO_FUNC'.
PASS Expected parsing failure
TEST COMPLETE
CONSOLE MESSAGE: line 82: SyntaxError: Parse error
S12.8_A5_T3
PASS SyntaxError: Undefined label: 'LABEL_IN'.
PASS Expected parsing failure