Class: BinTest_MrubyBinDebugger
- Defined in:
- ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/mrdb.rb,
ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/print.rb
Class Method Summary collapse
-
.test(rubysource, testcase) ⇒ Object
@debug2=true.
Class Method Details
.test(rubysource, testcase) ⇒ Object
@debug2=true
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-bin-debugger/bintest/print.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 `#{cmd("mrbc")} -g -o "#{bin.path}" "#{script.path}"` # add mrdb quit testcase << {:cmd=>"quit"} stdin_data = testcase.map{|t| t[:cmd]}.join("\n") << "\n" ["#{cmd('mrdb')} #{script.path}", "#{cmd('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 |