summaryrefslogtreecommitdiff
path: root/test/test-japanese.js
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-28 17:51:58 -0400
committertoasted-nutbread <toasted-nutbread@users.noreply.github.com>2020-03-28 18:17:00 -0400
commitae84d13757a98e640c8d62f8d856cecbd84dd66f (patch)
treebdf21d4ec0b45460b1838c8df8ca06a7141a0f66 /test/test-japanese.js
parenta0c4ce779d35cab39c62ca42ad3fe58a82faa1bb (diff)
Create simplified source map class
Diffstat (limited to 'test/test-japanese.js')
-rw-r--r--test/test-japanese.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/test/test-japanese.js b/test/test-japanese.js
index c5d220e7..a16a73b7 100644
--- a/test/test-japanese.js
+++ b/test/test-japanese.js
@@ -23,9 +23,11 @@ const vm = new VM();
vm.execute([
'mixed/lib/wanakana.min.js',
'mixed/js/japanese.js',
+ 'bg/js/text-source-map.js',
'bg/js/japanese.js'
]);
const jp = vm.get('jp');
+const TextSourceMap = vm.get('TextSourceMap');
function testIsCodePointKanji() {
@@ -262,13 +264,13 @@ function testConvertHalfWidthKanaToFullWidth() {
];
for (const [string, expected, expectedSourceMapping] of data) {
- const sourceMapping = new Array(string.length).fill(1);
+ const sourceMap = new TextSourceMap(string);
const actual1 = jp.convertHalfWidthKanaToFullWidth(string, null);
- const actual2 = jp.convertHalfWidthKanaToFullWidth(string, sourceMapping);
+ const actual2 = jp.convertHalfWidthKanaToFullWidth(string, sourceMap);
assert.strictEqual(actual1, expected);
assert.strictEqual(actual2, expected);
- if (Array.isArray(expectedSourceMapping)) {
- vm.assert.deepStrictEqual(sourceMapping, expectedSourceMapping);
+ if (typeof expectedSourceMapping !== 'undefined') {
+ assert.ok(sourceMap.equals(new TextSourceMap(string, expectedSourceMapping)));
}
}
}
@@ -285,13 +287,13 @@ function testConvertAlphabeticToKana() {
];
for (const [string, expected, expectedSourceMapping] of data) {
- const sourceMapping = new Array(string.length).fill(1);
+ const sourceMap = new TextSourceMap(string);
const actual1 = jp.convertAlphabeticToKana(string, null);
- const actual2 = jp.convertAlphabeticToKana(string, sourceMapping);
+ const actual2 = jp.convertAlphabeticToKana(string, sourceMap);
assert.strictEqual(actual1, expected);
assert.strictEqual(actual2, expected);
- if (Array.isArray(expectedSourceMapping)) {
- vm.assert.deepStrictEqual(sourceMapping, expectedSourceMapping);
+ if (typeof expectedSourceMapping !== 'undefined') {
+ assert.ok(sourceMap.equals(new TextSourceMap(string, expectedSourceMapping)));
}
}
}