2019-11-29 10:57:29 +00:00
|
|
|
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,
|
2020-04-23 00:31:35 +00:00
|
|
|
unused: true,
|
2019-11-29 10:57:29 +00:00
|
|
|
}
|
|
|
|
|
input: {
|
|
|
|
|
function f1() {
|
|
|
|
|
"use strict";
|
|
|
|
|
}
|
|
|
|
|
function f2() {
|
|
|
|
|
"use strict";
|
|
|
|
|
function f3() {
|
|
|
|
|
"use strict";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
(function f4() {
|
|
|
|
|
"use strict";
|
|
|
|
|
})();
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
function f1() {
|
|
|
|
|
}
|
|
|
|
|
function f2() {
|
|
|
|
|
}
|
2020-04-23 00:31:35 +00:00
|
|
|
(function() {})();
|
2019-11-29 10:57:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
issue_3166: {
|
|
|
|
|
options = {
|
|
|
|
|
directives: true,
|
|
|
|
|
}
|
|
|
|
|
input: {
|
|
|
|
|
"foo";
|
|
|
|
|
"use strict";
|
|
|
|
|
function f() {
|
|
|
|
|
"use strict";
|
|
|
|
|
"bar";
|
|
|
|
|
"use asm";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
"use strict";
|
|
|
|
|
function f() {
|
|
|
|
|
"use asm";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-25 00:55:39 +00:00
|
|
|
|
|
|
|
|
valid_after_invalid_1: {
|
|
|
|
|
input: {
|
|
|
|
|
console.log(typeof function() {
|
|
|
|
|
"use\x20strict";
|
|
|
|
|
"use strict";
|
|
|
|
|
return this;
|
|
|
|
|
}());
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
console.log(typeof function() {
|
|
|
|
|
"use\x20strict";
|
|
|
|
|
"use strict";
|
|
|
|
|
return this;
|
|
|
|
|
}());
|
|
|
|
|
}
|
|
|
|
|
expect_stdout: "undefined"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
valid_after_invalid_2: {
|
|
|
|
|
options = {
|
|
|
|
|
directives: true,
|
|
|
|
|
}
|
|
|
|
|
input: {
|
|
|
|
|
console.log(typeof function() {
|
|
|
|
|
"use\x20strict";
|
|
|
|
|
"use strict";
|
|
|
|
|
return this;
|
|
|
|
|
}());
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
console.log(typeof function() {
|
|
|
|
|
"use strict";
|
|
|
|
|
return this;
|
|
|
|
|
}());
|
|
|
|
|
}
|
|
|
|
|
expect_stdout: "undefined"
|
|
|
|
|
}
|
2022-02-23 21:04:04 +00:00
|
|
|
|
|
|
|
|
issue_5368_1: {
|
|
|
|
|
options = {
|
|
|
|
|
directives: true,
|
|
|
|
|
expression: true,
|
|
|
|
|
}
|
|
|
|
|
input: {
|
|
|
|
|
"foo";
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
"foo";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
issue_5368_2: {
|
|
|
|
|
options = {
|
|
|
|
|
directives: true,
|
|
|
|
|
expression: true,
|
|
|
|
|
}
|
|
|
|
|
input: {
|
|
|
|
|
"foo";
|
|
|
|
|
(function() {
|
|
|
|
|
"bar";
|
|
|
|
|
})();
|
|
|
|
|
}
|
|
|
|
|
expect: {
|
|
|
|
|
(function() {})();
|
|
|
|
|
}
|
|
|
|
|
}
|