diff options
-rw-r--r-- | Libraries/LibJS/Parser.cpp | 4 | ||||
-rw-r--r-- | Libraries/LibJS/Tests/object-basic.js | 2 | ||||
-rw-r--r-- | Libraries/LibJS/Tests/ternary-basic.js | 2 |
3 files changed, 6 insertions, 2 deletions
diff --git a/Libraries/LibJS/Parser.cpp b/Libraries/LibJS/Parser.cpp index 97b46d8db9..df5330af58 100644 --- a/Libraries/LibJS/Parser.cpp +++ b/Libraries/LibJS/Parser.cpp @@ -1105,9 +1105,9 @@ NonnullRefPtr<ContinueStatement> Parser::parse_continue_statement() NonnullRefPtr<ConditionalExpression> Parser::parse_conditional_expression(NonnullRefPtr<Expression> test) { consume(TokenType::QuestionMark); - auto consequent = parse_expression(0); + auto consequent = parse_expression(2); consume(TokenType::Colon); - auto alternate = parse_expression(0); + auto alternate = parse_expression(2); return create_ast_node<ConditionalExpression>(move(test), move(consequent), move(alternate)); } diff --git a/Libraries/LibJS/Tests/object-basic.js b/Libraries/LibJS/Tests/object-basic.js index 2d02c9f453..beebed1f35 100644 --- a/Libraries/LibJS/Tests/object-basic.js +++ b/Libraries/LibJS/Tests/object-basic.js @@ -7,6 +7,7 @@ try { 1: 23, foo, bar: "baz", + qux: true ? 10 : 20, "hello": "friends", [1 + 2]: 42, ["I am a " + computed + " key"]: foo, @@ -17,6 +18,7 @@ try { assert(o["1"] === 23); assert(o.foo === "bar"); assert(o["foo"] === "bar"); + assert(o.qux === 10), assert(o.hello === "friends"); assert(o["hello"] === "friends"); assert(o[3] === 42); diff --git a/Libraries/LibJS/Tests/ternary-basic.js b/Libraries/LibJS/Tests/ternary-basic.js index 6eb62bda3d..c01f611902 100644 --- a/Libraries/LibJS/Tests/ternary-basic.js +++ b/Libraries/LibJS/Tests/ternary-basic.js @@ -6,6 +6,8 @@ try { assert(x === 1 ? true : false); assert((x ? x : 0) === x); assert(1 < 2 ? (true) : (false)); + assert((0 ? 1 : 1 ? 10 : 20) === 10); + assert((0 ? 1 ? 1 : 10 : 20) === 20); var o = {}; o.f = true; |