X-Git-Url: https://git.kianting.info/?a=blobdiff_plain;f=tests%2Findex.js;fp=tests%2Findex.js;h=ad27d2799728993b66841e82fe8d8a6f1029b29c;hb=cda463d89022d09a5273b59bcd3e776f1127697a;hp=36eefccb13e5501e5112f3630a855ffc9b957bb9;hpb=aefa3e14791ba05b7959572338ad2377f528ab0b;p=clo diff --git a/tests/index.js b/tests/index.js index 36eefcc..ad27d27 100644 --- a/tests/index.js +++ b/tests/index.js @@ -1,22 +1,21 @@ "use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const src_1 = require("../src"); let assert = require("assert"); -let cloMain = require("../src"); -let a = cloMain.match1Char("我"); +let tokenize = require("../src/tokenize"); +let a = tokenize.match1Char("我"); let example1 = a({ matched: "", remained: "我的" }); assert(example1._tag == "Some"); assert(example1.value.matched == "我"); assert(example1.value.remained == "的"); let example2 = a({ matched: "", remained: "妳的" }); assert(example2._tag == "None"); -let thenDo = cloMain.thenDo; -let orDo = cloMain.orDo; -let zeroOrMoreDo = cloMain.zeroOrMoreDo; -let notDo = cloMain.notDo; +let thenDo = tokenize.thenDo; +let orDo = tokenize.orDo; +let zeroOrMoreDo = tokenize.zeroOrMoreDo; +let notDo = tokenize.notDo; +let matchAny = tokenize.matchAny; // composed part x -let compPart1 = cloMain.match1Char("我"); -let compPart2 = cloMain.match1Char("的"); +let compPart1 = tokenize.match1Char("我"); +let compPart2 = tokenize.match1Char("的"); let doThenTestee1 = { _tag: "Some", value: { matched: "", remained: "我的貓" } }; let doTestRes1 = thenDo(thenDo(doThenTestee1, compPart1), compPart2); assert(doTestRes1._tag == "Some"); @@ -53,39 +52,40 @@ let doTestRes8 = thenDo(thenDo(doThenTestee8, notDo(compPart1)), compPart2); assert(doTestRes8._tag == "Some"); assert(doTestRes8.value.matched == "妳的"); let doThenTestee9 = { _tag: "Some", value: { matched: "", remained: "妳的" } }; -let doTestRes9 = thenDo(doThenTestee9, src_1.matchAny); +let doTestRes9 = thenDo(doThenTestee9, matchAny); assert(doTestRes9._tag == "Some"); assert(doTestRes9.value.matched == "妳"); assert(doTestRes9.value.remained == "的"); -(0, src_1.tokenize)("+123"); -(0, src_1.tokenize)("123"); -(0, src_1.tokenize)("-123"); -(0, src_1.tokenize)(" 123"); +tokenize.tokenize("+123"); +tokenize.tokenize("123"); +tokenize.tokenize("-123"); +tokenize.tokenize(" 123"); try { - (0, src_1.tokenize)("c123"); + tokenize.tokenize("c123"); } catch (error) { console.log(error); } -(0, src_1.tokenize)(" "); -(0, src_1.tokenize)(" "); -(0, src_1.tokenize)(" \t"); -(0, src_1.tokenize)(" \t123"); +tokenize.tokenize(" "); +tokenize.tokenize(" "); +tokenize.tokenize(" \t"); +tokenize.tokenize(" \t123"); try { - (0, src_1.tokenize)(" \t123aaa456"); + tokenize.tokenize(" \t123aaa456"); } catch (error) { console.log(error); } -(0, src_1.tokenize)(" \t123\n456"); -(0, src_1.tokenize)("\"\""); -(0, src_1.tokenize)("\"123\""); -(0, src_1.tokenize)("\"1\\\"23\""); -(0, src_1.tokenize)("\"1\\\"23\" abc123"); -(0, src_1.tokenize)("+0.012"); -(0, src_1.tokenize)("0.0"); -(0, src_1.tokenize)("-222.0"); -(0, src_1.tokenize)("1+1 ==2; 3+8 foo(12)"); +tokenize.tokenize(" \t123\n456"); +tokenize.tokenize("\"\""); +tokenize.tokenize("\"123\""); +tokenize.tokenize("\"1\\\"23\""); +tokenize.tokenize("\"1\\\"23\" abc123"); +tokenize.tokenize("+0.012"); +tokenize.tokenize("0.0"); +tokenize.tokenize("-222.0"); +tokenize.tokenize("1+1 ==2; 3+8 foo(12)"); +console.log(tokenize.tokenize("2+2")); // harfbuzz test let harfbuzz = require("../src/harfbuzz.js"); harfbuzz.harfbuzzTest("123.abc");