Module: RedParse::ReduceWithUtils
- Included in:
- RedParse, ReduceWithsFor_RedParse_1_8, ReduceWithsFor_RedParse_1_9
- Defined in:
- lib/redparse.rb
Constant Summary collapse
- @@unequal_parser_ref_vars =
0
- @@line_mismatch_parser_ref_vars =
0
Instance Method Summary collapse
-
#matcher_unique_inspect(m) ⇒ Object
(also: #mui)
a version of inspect that is especially likely to be stable; no embedded addresses and ivar order is always the same.
- #squote(str) ⇒ Object
- #warn_unless_equal(i, ref, orig) ⇒ Object
Instance Method Details
#matcher_unique_inspect(m) ⇒ Object Also known as: mui
a version of inspect that is especially likely to be stable; no embedded addresses and ivar order is always the same
517 518 519 520 521 522 523 524 525 526 |
# File 'lib/redparse.rb', line 517 def matcher_unique_inspect(m) result=m.inspect return result unless /\A#<[A-Z]/===result "#<#{m.class}: "+ m.instance_variables.sort.map{|iv| val=m.instance_variable_get(iv).inspect val.gsub!(/#<(Proc|(?:Stack|Delete)Monkey):(?:0[xX])?[0-9a-fA-F]+/){ "#<#$1:" } iv.to_s+"="+val }.join(" ")+">" end |
#squote(str) ⇒ Object
529 530 531 |
# File 'lib/redparse.rb', line 529 def squote(str) "'#{str.gsub(/['\\]/){|ch| %[\\]+ch }}'" end |
#warn_unless_equal(i, ref, orig) ⇒ Object
535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
# File 'lib/redparse.rb', line 535 def warn_unless_equal i,ref,orig return if ref==orig msg="expected @ref_#{i} to == #{squote orig}, saw #{squote ref}" ref=ref.gsub(/\.rb:\d+>/,".rb:X>") orig=orig.gsub(/\.rb:\d+>/,".rb:X>") count= if ref==orig msg="@ref_#{i} differed in line nums" warn "more @ref_ vars differed in line nums..." if @@line_mismatch_parser_ref_vars==1 @@line_mismatch_parser_ref_vars+=1 else @@unequal_parser_ref_vars+=1 end warn msg if 1==count end |