Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/interscript/node/item/alias.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ def boundary_like?
Interscript::Stdlib.boundary_like_alias?(name)
end

# rs parity (WO17): the deterministic parallel sort counts every
# alias as 1 (0 for none) — rs Item::max_length treats Prim/Alias
# uniformly, and resolving the expansion here would need document
# context the sort site does not carry.
def max_length
if stdlib?
[:none].include?(name) ? 0 : 1
else
return 1 if name == :unicode_hangul
raise NotImplementedError, "can't get a max length of this alias"
1
end
end

Expand Down
37 changes: 37 additions & 0 deletions spec/isc/semantics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,43 @@ def context_map(id, rule)
.to raise_error(NoMethodError, /max_length/)
end
end

# WO17 — rs parity: the deterministic parallel sort counts every
# alias as max_length 1 (rs Item::max_length: Prim/Alias => 1). The
# reference runtime raised NotImplementedError for map-local aliases,
# erroring the whole megaregexp pass — 33 golden rows across the
# Arabic maps. Pinned to the rs outputs for the same document.
it "rules: a map-local alias in a megaregexp pass sorts like the rs runtime (WO17)" do
body = <<~ISC
system "TST:xx-Arab:Latn:31" {
metadata {
authority_id tst
id 31
language iso-639-2:xx
source_script Arab
destination_script Latn
}
aliases {
arab_letter = any("ابتثجحخدذرزسشصضطظعغفقكلمنهوي")
}
stage main {
parallel {
sub { from "ب" + arab_letter to "X" not_before "ن" }
}
}
}
ISC
with_map("tst-aliasmax-1.isc", body) do
expect(Interscript.transliterate("tst-aliasmax-1", "بتة")).to eq("Xة")
expect(Interscript.transliterate("tst-aliasmax-1", "بتن")).to eq("Xن")
end
end

it "rules: Item::Alias#max_length counts 1 for any alias (rs parity, WO17)" do
expect(Interscript::Node::Item::Alias.new(:some_document_alias).max_length).to eq(1)
expect(Interscript::Node::Item::Alias.new(:none).max_length).to eq(0)
expect(Interscript::Node::Item::Alias.new(:arab_alphabet).max_length).to eq(1)
end
end

RSpec.describe "ISC semantics — run and to-directives" do
Expand Down
Loading