From f268cabf9e8c4e37f8a50bebffc83f6a1edbf143 Mon Sep 17 00:00:00 2001 From: dcode Date: Sat, 4 Sep 2021 11:07:20 +0200 Subject: [PATCH] Cherry pick some loader string test cases --- lib/loader/tests/index.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/loader/tests/index.js b/lib/loader/tests/index.js index 2808a24b0e..e9ead9d13e 100644 --- a/lib/loader/tests/index.js +++ b/lib/loader/tests/index.js @@ -59,6 +59,22 @@ function test(file) { assert.strictEqual(exports.strlen(ref), str.length); } + // should be able to allocate and work with a string containing an isolated high surrogate + { + let str = "𝄞".substring(0, 1); + let ref = exports.__newString(str); + assert.strictEqual(exports.__getString(ref), str); + assert.strictEqual(exports.strlen(ref), str.length); + } + + // should be able to allocate and work with a string containing an isolated low surrogate + { + let str = "𝄞".substring(1); + let ref = exports.__newString(str); + assert.strictEqual(exports.__getString(ref), str); + assert.strictEqual(exports.strlen(ref), str.length); + } + // should be able to allocate a typed array { let arr = [1, 2, 3, 4, 5, 0x80000000 | 0];