diff --git a/lib/interscript/isc/node_adapter.rb b/lib/interscript/isc/node_adapter.rb index 4229bcbb..c2cca5eb 100644 --- a/lib/interscript/isc/node_adapter.rb +++ b/lib/interscript/isc/node_adapter.rb @@ -29,7 +29,7 @@ def build doc.aliases = build_aliases build_stages.each { |name, stage| doc.stages[name] = stage } build_dependencies(doc) - doc.name = @isc_doc[:system_code] + doc.name = @isc_doc[:systemCode] end end @@ -202,7 +202,21 @@ def convert_concat(concat) def convert_set(set) Interscript::Node::Item::Any.new( - set.chars.map { |c| Interscript::Node::Item::String.new(c) } + set.chars.map do |c| + # Entries may be primitives/alias refs (e.g. any([boundary, + # "\u200c", "\u200d"])) — stringifying them baked an object + # inspect into the compiled character class. + case c + when ::String + Interscript::Node::Item::String.new(c) + when Items::Primitive + convert_primitive(c) + when Items::AliasRef + convert_alias_ref(c) + else + convert_item(c) + end + end ) end end diff --git a/spec/interscript/isc/node_adapter_spec.rb b/spec/interscript/isc/node_adapter_spec.rb index aae5423b..301e8a83 100644 --- a/spec/interscript/isc/node_adapter_spec.rb +++ b/spec/interscript/isc/node_adapter_spec.rb @@ -249,3 +249,17 @@ def parse_and_adapt(src) end end end + +RSpec.describe "NodeAdapter document identity" do + it "carries the system code into the document name" do + tree = Interscript::Isc::Parser.parse( + 'system "X:a-b:C-D:1" { stage main { sub { from "a" to "b" } } }' + ) + doc = Interscript::Isc::DocumentBuilder.build(tree) + node = Interscript::Isc::NodeAdapter.to_interscript_node(doc) + # The Ruby compiler registers compiled maps under Document#name; a + # nil name registered them under "" and every transliterate call + # crashed on nil.call. + expect(node.name).to eq("X:a-b:C-D:1") + end +end diff --git a/spec/interscript_spec.rb b/spec/interscript_spec.rb index 62564564..1f022067 100644 --- a/spec/interscript_spec.rb +++ b/spec/interscript_spec.rb @@ -2,8 +2,16 @@ cache = {} mask = ENV["TRANSLIT_SYSTEM"] || "*" -# The legacy .imp sweep only (see legacy_maps in spec_helper). -maps = legacy_maps(select: mask) +# The ISC corpus sweep runs behind ISC_SWEEP=1: each example is +# timeout-guarded (at least one map hangs the interpreter) and +# per-map failures are expected until the ISC-era conformance work +# completes — the sweep exists to MEASURE that gap, gated so CI stays +# green while it closes. +maps = if ENV["ISC_SWEEP"] + Interscript.maps(basename: false, select: mask) +else + legacy_maps(select: mask) +end # Precache can be used to compare interpreter to compiler performance if ENV.include? "PRECACHE"