class MaRuKu::In::Markdown::SpanLevelParser::CharSourceDebug

A debug scanner that checks the correctness of both by comparing their output

Public Class Methods

new(s, parent) click to toggle source
# File lib/maruku/input/charsource.rb, line 235
def initialize(s, parent)
  @a = CharSourceManual.new(s, parent)
  @b = CharSourceStrscan.new(s, parent)
end

Public Instance Methods

method_missing(methodname, *args) click to toggle source
# File lib/maruku/input/charsource.rb, line 240
def method_missing(methodname, *args)
  a_bef = @a.describe
  b_bef = @b.describe

  a = @a.send(methodname, *args)
  b = @b.send(methodname, *args)

  if a.kind_of? MatchData
    if a.to_a != b.to_a
      puts "called: #{methodname}(#{args})"
      puts "Matchdata:\na = #{a.to_a.inspect}\nb = #{b.to_a.inspect}"
      puts "AFTER: " + @a.describe
      puts "AFTER: " + @b.describe
      puts "BEFORE: " + a_bef
      puts "BEFORE: " + b_bef
      puts caller.join("\n")
      exit
    end
  else
    if a != b
      puts "called: #{methodname}(#{args})"
      puts "Attenzione!\na = #{a.inspect}\nb = #{b.inspect}"
      puts "" + @a.describe
      puts "" + @b.describe
      puts caller.join("\n")
      exit
    end
  end

  if @a.cur_char != @b.cur_char
    puts "Fuori sincronia dopo #{methodname}(#{args})"
    puts "" + @a.describe
    puts "" + @b.describe
    exit
  end

  return a
end