diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-04-05 12:51:56 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-05 12:51:56 -0400 |
commit | 058f626efd6c5d6fae66346d487c10930d769971 (patch) | |
tree | 13045c5866953d6886db6faaf87fbff715fd7ceb /test/test-japanese.js | |
parent | f439d12718247411ccd0575af0d1de82aa22564a (diff) | |
parent | 7225201fb6776664d7a820e45e85c3500e83c80f (diff) |
Merge pull request #423 from toasted-nutbread/text-source-map
Text source map
Diffstat (limited to 'test/test-japanese.js')
-rw-r--r-- | test/test-japanese.js | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/test/test-japanese.js b/test/test-japanese.js index eab632bf..ca65dde2 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))); } } } |