Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix corner case in parsing directives (#3615)
- Loading branch information
Showing
5 changed files
with
123 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
simple_statement_is_not_a_directive: { | ||
input: { | ||
"use strict" | ||
.split(" ") | ||
.forEach(function(s) { | ||
console.log(s); | ||
}); | ||
console.log(!this); // is strict mode? | ||
(function() { | ||
"directive" | ||
"" | ||
"use strict" | ||
"hello world" | ||
.split(" ") | ||
.forEach(function(s) { | ||
console.log(s); | ||
}); | ||
console.log(!this); // is strict mode? | ||
})(); | ||
} | ||
expect: { | ||
"use strict".split(" ").forEach(function(s) { | ||
console.log(s); | ||
}); | ||
console.log(!this); | ||
(function() { | ||
"directive"; | ||
""; | ||
"use strict"; | ||
"hello world".split(" ").forEach(function(s) { | ||
console.log(s); | ||
}); | ||
console.log(!this); | ||
})(); | ||
} | ||
expect_stdout: [ | ||
"use", | ||
"strict", | ||
"false", | ||
"hello", | ||
"world", | ||
"true", | ||
] | ||
} | ||
|
||
drop_lone_use_strict: { | ||
options = { | ||
directives: true, | ||
side_effects: true, | ||
} | ||
input: { | ||
function f1() { | ||
"use strict"; | ||
} | ||
function f2() { | ||
"use strict"; | ||
function f3() { | ||
"use strict"; | ||
} | ||
} | ||
(function f4() { | ||
"use strict"; | ||
})(); | ||
} | ||
expect: { | ||
function f1() { | ||
} | ||
function f2() { | ||
"use strict"; | ||
function f3() { | ||
} | ||
} | ||
} | ||
} | ||
|
||
issue_3166: { | ||
options = { | ||
directives: true, | ||
} | ||
input: { | ||
"foo"; | ||
"use strict"; | ||
function f() { | ||
"use strict"; | ||
"bar"; | ||
"use asm"; | ||
} | ||
} | ||
expect: { | ||
"use strict"; | ||
function f() { | ||
"use asm"; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters