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
18 changes: 16 additions & 2 deletions lib/interscript/isc/node_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions spec/interscript/isc/node_adapter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 10 additions & 2 deletions spec/interscript_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading