summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-11-12 14:55:08 +1100
committerdaurnimator <quae@daurnimator.com>2017-11-12 15:22:22 +1100
commit2ec10cc9151920aa286a7ae376888d61cf9a3bca (patch)
tree09034ab8d9757e6d717dc81551ec08091880b9a0 /tests
parent0b903fef1bfe08d0fe573f4bdb02a6c90fd39ab2 (diff)
downloadfengari-2ec10cc9151920aa286a7ae376888d61cf9a3bca.tar.gz
fengari-2ec10cc9151920aa286a7ae376888d61cf9a3bca.tar.bz2
fengari-2ec10cc9151920aa286a7ae376888d61cf9a3bca.zip
src/defs.js: Refactor to_jsstring
Now fails on non-utf8 input. Previously it would convert to equivalent unicode codepoints as bytes, which did not round-trip
Diffstat (limited to 'tests')
-rw-r--r--tests/defs.js8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/defs.js b/tests/defs.js
index 07e863b..b00fda0 100644
--- a/tests/defs.js
+++ b/tests/defs.js
@@ -56,3 +56,11 @@ test('to_jsstring', function (t) {
t.deepEqual(defs.to_jsstring(v.byte_array), v.literal, v.description);
});
});
+
+test('to_jsstring fails on invalid unicode', function (t) {
+ t.plan(1);
+
+ t.throws(function() {
+ defs.to_jsstring([165]);
+ }, "non-utf8 char");
+});