In Files

  • mrbgems/mruby-bin-debugger/bintest/mrdb.rb
  • mrbgems/mruby-bin-debugger/bintest/print.rb

Parent

Methods

toggle debugging

BinTest_MrubyBinDebugger

Public Class Methods

test(rubysource, testcase) click to toggle source
 
               # File mrbgems/mruby-bin-debugger/bintest/mrdb.rb, line 8
  def self.test(rubysource, testcase)
    script, bin = Tempfile.new(['test', '.rb']), Tempfile.new(['test', '.mrb'])

    # .rb
    script.write rubysource
    script.flush

    # compile
    %x`./bin/mrbc -g -o "#{bin.path}" "#{script.path}"`

    # add mrdb quit
    testcase << {:cmd=>"quit"}

    stdin_data = testcase.map{|t| t[:cmd]}.join("\n") << "\n"

    ["bin/mrdb #{script.path}","bin/mrdb -b #{bin.path}"].each do |cmd|
      o, s = Open3.capture2(cmd, :stdin_data => stdin_data)

      exp_vals = testcase.map{|t| t.fetch(:exp, nil)}
      unexp_vals = testcase.map{|t| t.fetch(:unexp, nil)}

if @debug1
  o.split("\n").each_with_index do |i,actual|
    p [i,actual]
  end
end
      # compare actual / expected
      o.split("\n").each do |actual|
        next if actual.empty?
        exp = exp_vals.shift
if @debug2
  a = true
  a = actual.include?(exp) unless exp.nil?
  p [actual, exp] unless a
end
        assert_true actual.include?(exp) unless exp.nil?
      end
      # compare actual / unexpected
      o.split("\n").each do |actual|
        next if actual.empty?
        unexp = unexp_vals.shift
if @debug3
  a = false
  a = actual.include?(unexp) unless unexp.nil?
  p [actual, unexp] if a
end
        assert_false actual.include?(unexp) unless unexp.nil?
      end
    end
  end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.