Skip to content

Commit 0a60afe

Browse files
committed
additional test coverage
1 parent 46347f7 commit 0a60afe

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

internal/bundler_tests/bundler_lower_test.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2358,3 +2358,32 @@ func TestLowerForAwait2015(t *testing.T) {
23582358
},
23592359
})
23602360
}
2361+
2362+
func TestLowerNestedFunctionDirectEval(t *testing.T) {
2363+
lower_suite.expectBundled(t, bundled{
2364+
files: map[string]string{
2365+
"/1.js": "if (foo) { function x() {} }",
2366+
"/2.js": "if (foo) { function x() {} eval('') }",
2367+
"/3.js": "if (foo) { function x() {} if (bar) { eval('') } }",
2368+
"/4.js": "if (foo) { eval(''); function x() {} }",
2369+
"/5.js": "'use strict'; if (foo) { function x() {} }",
2370+
"/6.js": "'use strict'; if (foo) { function x() {} eval('') }",
2371+
"/7.js": "'use strict'; if (foo) { function x() {} if (bar) { eval('') } }",
2372+
"/8.js": "'use strict'; if (foo) { eval(''); function x() {} }",
2373+
},
2374+
entryPaths: []string{
2375+
"/1.js",
2376+
"/2.js",
2377+
"/3.js",
2378+
"/4.js",
2379+
"/5.js",
2380+
"/6.js",
2381+
"/7.js",
2382+
"/8.js",
2383+
},
2384+
options: config.Options{
2385+
Mode: config.ModePassThrough,
2386+
AbsOutputDir: "/out",
2387+
},
2388+
})
2389+
}

internal/bundler_tests/snapshots/snapshots_lower.txt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,71 @@ export default [
778778
}
779779
];
780780

781+
================================================================================
782+
TestLowerNestedFunctionDirectEval
783+
---------- /out/1.js ----------
784+
if (foo) {
785+
let x2 = function() {
786+
};
787+
var x = x2;
788+
}
789+
790+
---------- /out/2.js ----------
791+
if (foo) {
792+
function x() {
793+
}
794+
eval("");
795+
}
796+
797+
---------- /out/3.js ----------
798+
if (foo) {
799+
function x() {
800+
}
801+
if (bar) {
802+
eval("");
803+
}
804+
}
805+
806+
---------- /out/4.js ----------
807+
if (foo) {
808+
function x() {
809+
}
810+
eval("");
811+
}
812+
813+
---------- /out/5.js ----------
814+
"use strict";
815+
if (foo) {
816+
let x = function() {
817+
};
818+
}
819+
820+
---------- /out/6.js ----------
821+
"use strict";
822+
if (foo) {
823+
function x() {
824+
}
825+
eval("");
826+
}
827+
828+
---------- /out/7.js ----------
829+
"use strict";
830+
if (foo) {
831+
function x() {
832+
}
833+
if (bar) {
834+
eval("");
835+
}
836+
}
837+
838+
---------- /out/8.js ----------
839+
"use strict";
840+
if (foo) {
841+
function x() {
842+
}
843+
eval("");
844+
}
845+
781846
================================================================================
782847
TestLowerNullishCoalescingAssignmentIssue1493
783848
---------- /out.js ----------

0 commit comments

Comments
 (0)