From 26ef389d71e8a561ab7f2f38ed95a4b09e34cfde Mon Sep 17 00:00:00 2001 From: Ronald Tse Date: Wed, 21 Oct 2026 23:09:53 +0800 Subject: [PATCH] test(WO80/A4): normative rulings for parallel composition Two rulings pinned as frozen vectors: a parallel block is single-pass longest-match; duplicate rules resolve last-declared-wins. Each A4 ruling lands this way -- empirical vectors first, the IS-1 v2 normative text accretes per ruled point. --- spec/isc/semantics_spec.rb | 58 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 spec/isc/semantics_spec.rb diff --git a/spec/isc/semantics_spec.rb b/spec/isc/semantics_spec.rb new file mode 100644 index 00000000..fc01075d --- /dev/null +++ b/spec/isc/semantics_spec.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true + +# WO80/A4 — normative rulings for the ISC semantic surface. Each vector +# pins the reference behavior; IS-1 v2 documents these as normative +# sections (the spec text accretes one section per ruled point). + +require "tmpdir" + +RSpec.describe "ISC semantics — parallel composition" do + def with_map(name, body) + dir = Dir.mktmpdir + File.write(File.join(dir, name), body) + Interscript.load_path.unshift(dir) + yield + ensure + Interscript.load_path.delete(dir) if dir + end + + it "rules: a parallel block is single-pass longest-match" do + with_map("tst-long-1.isc", <<~ISC) do + system "TST:xx-Latn:Latn:1" { + metadata { + authority_id tst + id 1 + language iso-639-2:xx + source_script Latn + destination_script Latn + } + stage main { parallel { + sub "b" "Y" + sub "ab" "X" + } } + } + ISC + expect(Interscript.transliterate("tst-long-1", "ab")).to eq("X") + end + end + + it "rules: duplicate rules in a parallel resolve last-declared-wins" do + with_map("tst-tie-1.isc", <<~ISC) do + system "TST:xx-Latn:Latn:2" { + metadata { + authority_id tst + id 2 + language iso-639-2:xx + source_script Latn + destination_script Latn + } + stage main { parallel { + sub "a" "1" + sub "a" "2" + } } + } + ISC + expect(Interscript.transliterate("tst-tie-1", "a")).to eq("2") + end + end +end