Commit d23f8371 authored by neis's avatar neis Committed by Commit bot

[parsing] Add some more tests of maybe-assigned.

R=adamk@chromium.org, mstarzinger@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2554363002
Cr-Commit-Position: refs/heads/master@{#41577}
parent c4f9e429
...@@ -3261,35 +3261,45 @@ TEST(InnerAssignment) { ...@@ -3261,35 +3261,45 @@ TEST(InnerAssignment) {
const char* prefix = "function f() {"; const char* prefix = "function f() {";
const char* midfix = " function g() {"; const char* midfix = " function g() {";
const char* suffix = "}}; f"; const char* suffix = "}}; f";
struct { const char* source; bool assigned; bool strict; } outers[] = { struct {
// Actual assignments. const char* source;
{ "var x; var x = 5;", true, false }, bool assigned;
{ "var x; { var x = 5; }", true, false }, bool strict;
{ "'use strict'; let x; x = 6;", true, true }, } outers[] = {
{ "var x = 5; function x() {}", true, false }, // Actual assignments.
// Actual non-assignments. {"var x; var x = 5;", true, false},
{ "var x;", false, false }, {"var x; { var x = 5; }", true, false},
{ "var x = 5;", false, false }, {"'use strict'; let x; x = 6;", true, true},
{ "'use strict'; let x;", false, true }, {"var x = 5; function x() {}", true, false},
{ "'use strict'; let x = 6;", false, true }, {"var x = 4; var x = 5;", true, false},
{ "'use strict'; var x = 0; { let x = 6; }", false, true }, {"var [x, x] = [4, 5];", true, false},
{ "'use strict'; var x = 0; { let x; x = 6; }", false, true }, {"var {a: x, b: x} = {a: 4, b: 5};", true, false},
{ "'use strict'; let x = 0; { let x = 6; }", false, true }, {"var x = {a: 4, b: (x = 5)};", true, false},
{ "'use strict'; let x = 0; { let x; x = 6; }", false, true }, {"var {x=1} = {a: 4, b: (x = 5)};", true, false},
{ "var x; try {} catch (x) { x = 5; }", false, false }, {"var {x} = {x: 4, b: (x = 5)};", true, false},
{ "function x() {}", false, false }, // Actual non-assignments.
// Eval approximation. {"var x;", false, false},
{ "var x; eval('');", true, false }, {"var x = 5;", false, false},
{ "eval(''); var x;", true, false }, {"'use strict'; let x;", false, true},
{ "'use strict'; let x; eval('');", true, true }, {"'use strict'; let x = 6;", false, true},
{ "'use strict'; eval(''); let x;", true, true }, {"'use strict'; var x = 0; { let x = 6; }", false, true},
// Non-assignments not recognized, because the analysis is approximative. {"'use strict'; var x = 0; { let x; x = 6; }", false, true},
{ "var x; var x;", true, false }, {"'use strict'; let x = 0; { let x = 6; }", false, true},
{ "var x = 5; var x;", true, false }, {"'use strict'; let x = 0; { let x; x = 6; }", false, true},
{ "var x; { var x; }", true, false }, {"var x; try {} catch (x) { x = 5; }", false, false},
{ "var x; function x() {}", true, false }, {"function x() {}", false, false},
{ "function x() {}; var x;", true, false }, // Eval approximation.
{ "var x; try {} catch (x) { var x = 5; }", true, false }, {"var x; eval('');", true, false},
{"eval(''); var x;", true, false},
{"'use strict'; let x; eval('');", true, true},
{"'use strict'; eval(''); let x;", true, true},
// Non-assignments not recognized, because the analysis is approximative.
{"var x; var x;", true, false},
{"var x = 5; var x;", true, false},
{"var x; { var x; }", true, false},
{"var x; function x() {}", true, false},
{"function x() {}; var x;", true, false},
{"var x; try {} catch (x) { var x = 5; }", true, false},
}; };
struct { const char* source; bool assigned; bool with; } inners[] = { struct { const char* source; bool assigned; bool with; } inners[] = {
// Actual assignments. // Actual assignments.
......
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