diff options
author | 2021-09-20 22:37:22 -0700 | |
---|---|---|
committer | 2021-09-20 22:37:22 -0700 | |
commit | ab565f1a3ca2d9a320c958786fb3a9df3392ceae (patch) | |
tree | da5d9dbf6fd6b0371661ae8355e664fe909ec406 /integration | |
parent | 90cd3bf4cbe06b1795cd47bcae670d5970564abd (diff) | |
download | bun-ab565f1a3ca2d9a320c958786fb3a9df3392ceae.tar.gz bun-ab565f1a3ca2d9a320c958786fb3a9df3392ceae.tar.zst bun-ab565f1a3ca2d9a320c958786fb3a9df3392ceae.zip |
Fix parsing/printing unicode identifiers, switch to UTF-8 for prefilled strings, remove eagerly loading identifier_name
Diffstat (limited to 'integration')
-rw-r--r-- | integration/scripts/browser.js | 2 | ||||
-rw-r--r-- | integration/snapshots-no-hmr/string-escapes.js | 34 | ||||
-rw-r--r-- | integration/snapshots-no-hmr/unicode-identifiers.js | 7 | ||||
-rw-r--r-- | integration/snapshots/string-escapes.js | 57 | ||||
-rw-r--r-- | integration/snapshots/unicode-identifiers.js | 30 | ||||
-rw-r--r-- | integration/snippets/string-escapes.js | 35 | ||||
-rw-r--r-- | integration/snippets/unicode-identifiers.js | 15 |
7 files changed, 180 insertions, 0 deletions
diff --git a/integration/scripts/browser.js b/integration/scripts/browser.js index 7fe9e8f4c..d062f93ca 100644 --- a/integration/scripts/browser.js +++ b/integration/scripts/browser.js @@ -95,6 +95,8 @@ async function main() { "/ts-fallback-rewrite-works.js", "/tsx-fallback-rewrite-works.js", "/lodash-regexp.js", + "/unicode-identifiers.js", + "/string-escapes.js", ]; tests.reverse(); diff --git a/integration/snapshots-no-hmr/string-escapes.js b/integration/snapshots-no-hmr/string-escapes.js new file mode 100644 index 000000000..05d9c4ce2 --- /dev/null +++ b/integration/snapshots-no-hmr/string-escapes.js @@ -0,0 +1,34 @@ +var tab = "\t"; +var シ = "wow"; +var f = ""; +var obj = { + "\r\n": "\r\n", + "\n": "\n", + "\t": "\t", + "\u2028": "\u2028", + "\u2029": "\u2029", + "😊": "😊", + "😃": "😃", + "㋡": "㋡", + "☺": "☺", + シ: "シ", + f, + "☹": "☹", + "☻": "☻", + children: 123 +}; +const foo = () => { +}; +const Bar = foo("a", { + children: 123 +}); +const carriage = obj["\r\n"]; +const newline = obj["\n"]; + +export {obj}; +export function test() { + console.assert(carriage === "\r\n"); + console.assert(newline === "\n"); + console.assert(tab === "\t"); + return testDone(import.meta.url); +} diff --git a/integration/snapshots-no-hmr/unicode-identifiers.js b/integration/snapshots-no-hmr/unicode-identifiers.js new file mode 100644 index 000000000..c495d69f6 --- /dev/null +++ b/integration/snapshots-no-hmr/unicode-identifiers.js @@ -0,0 +1,7 @@ +var ε = 1.0e-06, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π; + +export {d3_radians}; +export function test() { + console.assert(ε === 1.0e-06); + return testDone(import.meta.url); +} diff --git a/integration/snapshots/string-escapes.js b/integration/snapshots/string-escapes.js new file mode 100644 index 000000000..9231cb6cf --- /dev/null +++ b/integration/snapshots/string-escapes.js @@ -0,0 +1,57 @@ +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +Bun.activate(false); + +var hmr = new HMR(2482749838, "string-escapes.js"), exports = hmr.exports; +(hmr._load = function() { + var tab = "\t"; + var シ = "wow"; + var f = ""; + var obj = { + "\r\n": "\r\n", + "\n": "\n", + "\t": "\t", + "\u2028": "\u2028", + "\u2029": "\u2029", + "😊": "😊", + "😃": "😃", + "㋡": "㋡", + "☺": "☺", + シ: "シ", + f, + "☹": "☹", + "☻": "☻", + children: 123 + }; + const foo = () => { + }; + const Bar = foo("a", { + children: 123 + }); + const carriage = obj["\r\n"]; + const newline = obj["\n"]; + function test() { + console.assert(carriage === "\r\n"); + console.assert(newline === "\n"); + console.assert(tab === "\t"); + return testDone(import.meta.url); + } + hmr.exportAll({ + obj: () => obj, + test: () => test + }); +})(); +var $$hmr_obj = hmr.exports.obj, $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_obj = exports.obj; + $$hmr_test = exports.test; +}; + +export { + $$hmr_obj as obj, + $$hmr_test as test +}; diff --git a/integration/snapshots/unicode-identifiers.js b/integration/snapshots/unicode-identifiers.js new file mode 100644 index 000000000..5d465d559 --- /dev/null +++ b/integration/snapshots/unicode-identifiers.js @@ -0,0 +1,30 @@ +import { +__HMRModule as HMR +} from "http://localhost:8080/__runtime.js"; +import { +__HMRClient as Bun +} from "http://localhost:8080/__runtime.js"; +Bun.activate(false); + +var hmr = new HMR(1398361736, "unicode-identifiers.js"), exports = hmr.exports; +(hmr._load = function() { + var ε = 1.0e-06, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π; + function test() { + console.assert(ε === 1.0e-06); + return testDone(import.meta.url); + } + hmr.exportAll({ + d3_radians: () => d3_radians, + test: () => test + }); +})(); +var $$hmr_d3_radians = hmr.exports.d3_radians, $$hmr_test = hmr.exports.test; +hmr._update = function(exports) { + $$hmr_d3_radians = exports.d3_radians; + $$hmr_test = exports.test; +}; + +export { + $$hmr_d3_radians as d3_radians, + $$hmr_test as test +}; diff --git a/integration/snippets/string-escapes.js b/integration/snippets/string-escapes.js new file mode 100644 index 000000000..dc5c7cff9 --- /dev/null +++ b/integration/snippets/string-escapes.js @@ -0,0 +1,35 @@ +var tab = "\t"; +var シ = "wow"; +var f = ""; +var obj = { + "\r\n": "\r\n", + "\n": "\n", + "\t": "\t", + "\u2028": "\u2028", + "\u2029": "\u2029", + "😊": "😊", + "😃": "😃", + "㋡": "㋡", + "☺": "☺", + シ: "シ", + f: f, + "☹": "☹", + "☻": "☻", + children: 123, +}; +const foo = () => {}; +const Bar = foo("a", { + children: 123, +}); + +const carriage = obj["\r\n"]; +const newline = obj["\n"]; + +export { obj }; + +export function test() { + console.assert(carriage === "\r\n"); + console.assert(newline === "\n"); + console.assert(tab === "\t"); + return testDone(import.meta.url); +} diff --git a/integration/snippets/unicode-identifiers.js b/integration/snippets/unicode-identifiers.js new file mode 100644 index 000000000..5b602f49b --- /dev/null +++ b/integration/snippets/unicode-identifiers.js @@ -0,0 +1,15 @@ +var ε = 1e-6, + ε2 = ε * ε, + π = Math.PI, + τ = 2 * π, + τε = τ - ε, + halfπ = π / 2, + d3_radians = π / 180, + d3_degrees = 180 / π; + +export { d3_radians }; + +export function test() { + console.assert(ε === 1e-6); + return testDone(import.meta.url); +} |