+ Add tests for bidi rule W4

This commit is contained in:
Nils Dagsson Moskopp 2023-03-26 20:46:38 +02:00
parent fb971deccf
commit 732b063dcd
1 changed files with 41 additions and 2 deletions

View File

@ -230,7 +230,7 @@ assert(
"R" == test_output[3].bidi_class
)
bidi.W4 = function(run)
local W4 = function(run)
for i = 1, #run do
if "ES" == run[i].bidi_class then
-- A single European separator between two European numbers
@ -268,6 +268,45 @@ bidi.W4 = function(run)
return run
end
-- Test W4: EN ES EN → EN EN EN
local test_input = {
{ ["bidi_class"] = "EN" },
{ ["bidi_class"] = "ES" },
{ ["bidi_class"] = "EN" },
}
local test_output = W4(test_input)
assert(
"EN" == test_output[1].bidi_class and
"EN" == test_output[2].bidi_class and
"EN" == test_output[3].bidi_class
)
-- Test W4: EN CS EN → EN EN EN
local test_input = {
{ ["bidi_class"] = "EN" },
{ ["bidi_class"] = "CS" },
{ ["bidi_class"] = "EN" },
}
local test_output = W4(test_input)
assert(
"EN" == test_output[1].bidi_class and
"EN" == test_output[2].bidi_class and
"EN" == test_output[3].bidi_class
)
-- Test W4: AN CS AN → AN AN AN
local test_input = {
{ ["bidi_class"] = "AN" },
{ ["bidi_class"] = "CS" },
{ ["bidi_class"] = "AN" },
}
local test_output = W4(test_input)
assert(
"AN" == test_output[1].bidi_class and
"AN" == test_output[2].bidi_class and
"AN" == test_output[3].bidi_class
)
bidi.W5 = function(run)
for i = 1, #run do
if "ET" == run[i].bidi_class then
@ -337,7 +376,7 @@ bidi.resolve_weak_types = function(run, sos)
run = bidi.W1(run, sos)
run = W2(run, sos)
run = W3(run)
run = bidi.W4(run)
run = W4(run)
run = bidi.W5(run)
run = bidi.W6(run)
run = bidi.W7(run, sos)