aboutsummaryrefslogtreecommitdiff
path: root/test/compress
diff options
context:
space:
mode:
authorAlex Lam S.L <alexlamsl@gmail.com>2019-11-29 18:57:29 +0800
committerGitHub <noreply@github.com>2019-11-29 18:57:29 +0800
commit1283d738539b4f899e4941f556b516c071bfa55a (patch)
treee563bbcfbe2932579f2f1778a0946ac3df945445 /test/compress
parent1b61a81b5d6c9489466fe4707c1b01810a01d03a (diff)
downloadtracifyjs-1283d738539b4f899e4941f556b516c071bfa55a.tar.gz
tracifyjs-1283d738539b4f899e4941f556b516c071bfa55a.zip
fix corner case in parsing directives (#3615)
Diffstat (limited to 'test/compress')
-rw-r--r--test/compress/directives.js95
-rw-r--r--test/compress/functions.js51
2 files changed, 95 insertions, 51 deletions
diff --git a/test/compress/directives.js b/test/compress/directives.js
new file mode 100644
index 00000000..590d1623
--- /dev/null
+++ b/test/compress/directives.js
@@ -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";
+ }
+ }
+}
diff --git a/test/compress/functions.js b/test/compress/functions.js
index 8795afb1..4fea42dc 100644
--- a/test/compress/functions.js
+++ b/test/compress/functions.js
@@ -2004,57 +2004,6 @@ deduplicate_parenthesis: {
expect_exact: "({}).a=b;({}.a=b)();(function(){}).a=b;(function(){}.a=b)();"
}
-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";
- }
- }
-}
-
issue_3016_1: {
options = {
inline: true,