Skip to content

Commit

Permalink
test: improve test for sorting alternations
Browse files Browse the repository at this point in the history
  • Loading branch information
DGCK81LNN committed Jan 9, 2024
1 parent d141e39 commit 370fcd5
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion package/test/base_transcribers.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ describe("base_transcribers", function () {
it("reorders alternations according to hints", function () {
const t = new HanziToAlphaTranscriber({
dict: [
{ h: "A", x: "111", n: "bottom", hh: "-" },
// Correct order is:
// conditional matching > regular > conditional non-matching > exceptional > legacy
// A should give 333-222-111-000 when condition for 333 matches, 222-333-111-000 otherwise
{ h: "A", x: "000", n: "legacy", hh: "-", xh: "-" },
{ h: "A", x: "111", n: "exceptional", hh: "-" },
{ h: "A", x: "222", n: "regular" },
{ h: "A", x: "333", n: "conditional", hh: "A~ B~ ~D" },
{ h: "B", x: "444" },
Expand All @@ -77,18 +81,21 @@ describe("base_transcribers", function () {
OW({ content: [OW({ h: "A", x: "222" })] }),
OW({ content: [OW({ h: "A", x: "333" })] }),
OW({ content: [OW({ h: "A", x: "111" })] }),
OW({ content: [OW({ h: "A", x: "000" })] }),
],
])
expect(t.transcribe("AA")).toEqual([
[
OW({ content: [OW({ h: "A", x: "222" })] }),
OW({ content: [OW({ h: "A", x: "333" })] }),
OW({ content: [OW({ h: "A", x: "111" })] }),
OW({ content: [OW({ h: "A", x: "000" })] }),
],
[
OW({ content: [OW({ h: "A", x: "333" })] }),
OW({ content: [OW({ h: "A", x: "222" })] }),
OW({ content: [OW({ h: "A", x: "111" })] }),
OW({ content: [OW({ h: "A", x: "000" })] }),
],
])
expect(t.transcribe("BA")).toEqual([
Expand All @@ -97,6 +104,7 @@ describe("base_transcribers", function () {
OW({ content: [OW({ h: "A", x: "333" })] }),
OW({ content: [OW({ h: "A", x: "222" })] }),
OW({ content: [OW({ h: "A", x: "111" })] }),
OW({ content: [OW({ h: "A", x: "000" })] }),
],
])
expect(t.transcribe("CA")).toEqual([
Expand All @@ -105,13 +113,15 @@ describe("base_transcribers", function () {
OW({ content: [OW({ h: "A", x: "222" })] }),
OW({ content: [OW({ h: "A", x: "333" })] }),
OW({ content: [OW({ h: "A", x: "111" })] }),
OW({ content: [OW({ h: "A", x: "000" })] }),
],
])
expect(t.transcribe("AD")).toEqual([
[
OW({ content: [OW({ h: "A", x: "333" })] }),
OW({ content: [OW({ h: "A", x: "222" })] }),
OW({ content: [OW({ h: "A", x: "111" })] }),
OW({ content: [OW({ h: "A", x: "000" })] }),
],
OW({ h: "D", x: "666" }),
])
Expand All @@ -120,6 +130,7 @@ describe("base_transcribers", function () {
OW({ content: [OW({ h: "A", x: "222" })] }),
OW({ content: [OW({ h: "A", x: "333" })] }),
OW({ content: [OW({ h: "A", x: "111" })] }),
OW({ content: [OW({ h: "A", x: "000" })] }),
],
OW({ h: "E", x: "777" }),
])
Expand Down

0 comments on commit 370fcd5

Please sign in to comment.