aboutsummaryrefslogtreecommitdiff
path: root/integration
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-17 16:10:43 -0700
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-09-17 16:10:43 -0700
commit84632571c7b516125b84e042e116a6d6bc76e20e (patch)
tree488eb1e69a313528f1b684113b91a38d01914874 /integration
parentaf1061e47ab4b21ef67ff18c40da3f2f6cb342c6 (diff)
downloadbun-84632571c7b516125b84e042e116a6d6bc76e20e.tar.gz
bun-84632571c7b516125b84e042e116a6d6bc76e20e.tar.zst
bun-84632571c7b516125b84e042e116a6d6bc76e20e.zip
Add test for "shuffle" function for lodashbun-v0.0.19
Diffstat (limited to 'integration')
-rw-r--r--integration/scripts/browser.js2
-rw-r--r--integration/snippets/lodash-regexp.js24
-rw-r--r--integration/snippets/package.json1
-rw-r--r--integration/snippets/public/index.html17
4 files changed, 44 insertions, 0 deletions
diff --git a/integration/scripts/browser.js b/integration/scripts/browser.js
index a37e6e2a2..7fe9e8f4c 100644
--- a/integration/scripts/browser.js
+++ b/integration/scripts/browser.js
@@ -94,7 +94,9 @@ async function main() {
"/multiple-imports.js",
"/ts-fallback-rewrite-works.js",
"/tsx-fallback-rewrite-works.js",
+ "/lodash-regexp.js",
];
+ tests.reverse();
for (let test of tests) {
await runPage(test);
diff --git a/integration/snippets/lodash-regexp.js b/integration/snippets/lodash-regexp.js
new file mode 100644
index 000000000..bc683e535
--- /dev/null
+++ b/integration/snippets/lodash-regexp.js
@@ -0,0 +1,24 @@
+import { shuffle } from "lodash";
+
+// Lodash uses a variety of uncommon syntax (such as unicode escapes in regexp)
+// so running it is a broad test of the parser, lexer, and printer
+export function test() {
+ const foo = [1, 2, 3, 4, 6];
+ const bar = shuffle(foo);
+ console.assert(bar !== foo);
+ console.assert(bar.length === foo.length);
+ bar.sort();
+ foo.sort();
+ for (let i = 0; i < bar.length; i++) {
+ console.assert(bar[i] === foo[i], "expected " + i + " to be " + foo[i]);
+ console.assert(typeof bar[i] === "number");
+ console.assert(typeof foo[i] === "number");
+ }
+
+ return testDone(import.meta.url);
+}
+
+// export function test() {
+// const regexp = RegExp("['\u2019]", "g");
+// return testDone(import.meta.url);
+// }
diff --git a/integration/snippets/package.json b/integration/snippets/package.json
index 8edbd79a1..1c0cb8b7b 100644
--- a/integration/snippets/package.json
+++ b/integration/snippets/package.json
@@ -4,6 +4,7 @@
"main": "index.js",
"license": "MIT",
"dependencies": {
+ "lodash": "^4.17.21",
"react": "^17.0.2",
"redux": "^4.1.1"
}
diff --git a/integration/snippets/public/index.html b/integration/snippets/public/index.html
index 74a744a7d..5358fa423 100644
--- a/integration/snippets/public/index.html
+++ b/integration/snippets/public/index.html
@@ -46,6 +46,23 @@
return await testFunction();
};
+
+ if (globalThis.location.pathname.endsWith("-test")) {
+ globalThis.testDone = (path) => alert(`test ${path} success`);
+ globalThis.testFail = (path) => alert(`!test ${path} fail`);
+ runTest(
+ globalThis.location.pathname.substring(
+ 0,
+ location.pathname.length - "-test".length
+ )
+ ).then(
+ () => {},
+ (err) => {
+ console.error(err);
+ alert(err.toString());
+ }
+ );
+ }
</script>
</body>
</html>