ZenTest-4.9.1/0000755000004100000410000000000012141713143013146 5ustar www-datawww-dataZenTest-4.9.1/test/0000755000004100000410000000000012141713143014125 5ustar www-datawww-dataZenTest-4.9.1/test/test_zentest_mapping.rb0000444000004100000410000002177312141713143020730 0ustar www-datawww-data$TESTING = true require 'rubygems' require 'minitest/autorun' require 'zentest_mapping' unless defined? $ZENTEST class Dummy attr_accessor :inherited_methods include ZenTestMapping end class TestZentestMapping < MiniTest::Unit::TestCase def setup @tester = Dummy.new end def util_simple_setup klasses = { "Something" => { "method1" => true, "method1!" => true, "method1=" => true, "method1?" => true, "attrib" => true, "attrib=" => true, "equal?" => true, "self.method3" => true, "self.[]" => true, }, } test_klasses = { "TestSomething" => { "test_class_method4" => true, "test_method2" => true, "setup" => true, "teardown" => true, "test_class_index" => true, }, } @tester.inherited_methods = test_klasses.merge(klasses) @generated_code = " require 'test/unit' unless defined? $ZENTEST and $ZENTEST class Something def self.method4(*args) raise NotImplementedError, 'Need to write self.method4' end def method2(*args) raise NotImplementedError, 'Need to write method2' end end class TestSomething < Test::Unit::TestCase def test_class_method3 raise NotImplementedError, 'Need to write test_class_method3' end def test_attrib raise NotImplementedError, 'Need to write test_attrib' end def test_attrib_equals raise NotImplementedError, 'Need to write test_attrib_equals' end def test_equal_eh raise NotImplementedError, 'Need to write test_equal_eh' end def test_method1 raise NotImplementedError, 'Need to write test_method1' end def test_method1_bang raise NotImplementedError, 'Need to write test_method1_bang' end def test_method1_eh raise NotImplementedError, 'Need to write test_method1_eh' end def test_method1_equals raise NotImplementedError, 'Need to write test_method1_equals' end end # Number of errors detected: 10 " end def test_normal_to_test self.util_simple_setup assert_equal("test_method1", @tester.normal_to_test("method1")) assert_equal("test_method1_bang", @tester.normal_to_test("method1!")) assert_equal("test_method1_eh", @tester.normal_to_test("method1?")) assert_equal("test_method1_equals", @tester.normal_to_test("method1=")) end def test_normal_to_test_cls self.util_simple_setup assert_equal("test_class_method1", @tester.normal_to_test("self.method1")) assert_equal("test_class_method1_bang", @tester.normal_to_test("self.method1!")) assert_equal("test_class_method1_eh", @tester.normal_to_test("self.method1?")) assert_equal("test_class_method1_equals", @tester.normal_to_test("self.method1=")) end def test_normal_to_test_operators self.util_simple_setup assert_equal("test_and", @tester.normal_to_test("&")) assert_equal("test_bang", @tester.normal_to_test("!")) assert_equal("test_carat", @tester.normal_to_test("^")) assert_equal("test_div", @tester.normal_to_test("/")) assert_equal("test_equalstilde", @tester.normal_to_test("=~")) assert_equal("test_minus", @tester.normal_to_test("-")) assert_equal("test_or", @tester.normal_to_test("|")) assert_equal("test_percent", @tester.normal_to_test("%")) assert_equal("test_plus", @tester.normal_to_test("+")) assert_equal("test_tilde", @tester.normal_to_test("~")) end def test_normal_to_test_overlap self.util_simple_setup assert_equal("test_equals2", @tester.normal_to_test("==")) assert_equal("test_equals3", @tester.normal_to_test("===")) assert_equal("test_ge", @tester.normal_to_test(">=")) assert_equal("test_gt", @tester.normal_to_test(">")) assert_equal("test_gt2", @tester.normal_to_test(">>")) assert_equal("test_index", @tester.normal_to_test("[]")) assert_equal("test_index_equals", @tester.normal_to_test("[]=")) assert_equal("test_lt", @tester.normal_to_test("<")) assert_equal("test_lt2", @tester.normal_to_test("<\<")) assert_equal("test_lte", @tester.normal_to_test("<=")) assert_equal("test_method", @tester.normal_to_test("method")) assert_equal("test_method_equals", @tester.normal_to_test("method=")) assert_equal("test_spaceship", @tester.normal_to_test("<=>")) assert_equal("test_times", @tester.normal_to_test("*")) assert_equal("test_times2", @tester.normal_to_test("**")) assert_equal("test_unary_minus", @tester.normal_to_test("-@")) assert_equal("test_unary_plus", @tester.normal_to_test("+@")) assert_equal("test_class_index", @tester.normal_to_test("self.[]")) end def test_test_to_normal self.util_simple_setup assert_equal("method1!", @tester.test_to_normal("test_method1_bang", "Something")) assert_equal("method1", @tester.test_to_normal("test_method1", "Something")) assert_equal("method1=", @tester.test_to_normal("test_method1_equals", "Something")) assert_equal("method1?", @tester.test_to_normal("test_method1_eh", "Something")) end def test_test_to_normal_cls self.util_simple_setup assert_equal("self.method1", @tester.test_to_normal("test_class_method1")) assert_equal("self.method1!", @tester.test_to_normal("test_class_method1_bang")) assert_equal("self.method1?", @tester.test_to_normal("test_class_method1_eh")) assert_equal("self.method1=", @tester.test_to_normal("test_class_method1_equals")) assert_equal("self.[]", @tester.test_to_normal("test_class_index")) end def test_test_to_normal_extended self.util_simple_setup assert_equal("equal?", @tester.test_to_normal("test_equal_eh_extension", "Something")) assert_equal("equal?", @tester.test_to_normal("test_equal_eh_extension_again", "Something")) assert_equal("method1", @tester.test_to_normal("test_method1_extension", "Something")) assert_equal("method1", @tester.test_to_normal("test_method1_extension_again", "Something")) end def test_test_to_normal_mapped self.util_simple_setup assert_equal("*", @tester.test_to_normal("test_times")) assert_equal("*", @tester.test_to_normal("test_times_ext")) assert_equal("==", @tester.test_to_normal("test_equals2")) assert_equal("==", @tester.test_to_normal("test_equals2_ext")) assert_equal("===", @tester.test_to_normal("test_equals3")) assert_equal("===", @tester.test_to_normal("test_equals3_ext")) assert_equal("[]", @tester.test_to_normal("test_index")) assert_equal("[]", @tester.test_to_normal("test_index_ext")) assert_equal("[]=", @tester.test_to_normal("test_index_equals")) assert_equal("[]=", @tester.test_to_normal("test_index_equals_ext")) end def test_test_to_normal_operators self.util_simple_setup assert_equal("&", @tester.test_to_normal("test_and")) assert_equal("!", @tester.test_to_normal("test_bang")) assert_equal("^", @tester.test_to_normal("test_carat")) assert_equal("/", @tester.test_to_normal("test_div")) assert_equal("=~", @tester.test_to_normal("test_equalstilde")) assert_equal("-", @tester.test_to_normal("test_minus")) assert_equal("|", @tester.test_to_normal("test_or")) assert_equal("%", @tester.test_to_normal("test_percent")) assert_equal("+", @tester.test_to_normal("test_plus")) assert_equal("~", @tester.test_to_normal("test_tilde")) end def test_test_to_normal_overlap self.util_simple_setup assert_equal("==", @tester.test_to_normal("test_equals2")) assert_equal("===", @tester.test_to_normal("test_equals3")) assert_equal(">=", @tester.test_to_normal("test_ge")) assert_equal(">", @tester.test_to_normal("test_gt")) assert_equal(">>", @tester.test_to_normal("test_gt2")) assert_equal("[]", @tester.test_to_normal("test_index")) assert_equal("[]=", @tester.test_to_normal("test_index_equals")) assert_equal("<", @tester.test_to_normal("test_lt")) assert_equal("<\<", @tester.test_to_normal("test_lt2")) assert_equal("<=", @tester.test_to_normal("test_lte")) assert_equal("<=>", @tester.test_to_normal("test_spaceship")) assert_equal("*", @tester.test_to_normal("test_times")) assert_equal("**", @tester.test_to_normal("test_times2")) assert_equal("-@", @tester.test_to_normal("test_unary_minus")) assert_equal("+@", @tester.test_to_normal("test_unary_plus")) end def test_to_normal_subset self.util_simple_setup assert_equal("get_foo", @tester.test_to_normal("test_get_foo")) end end ZenTest-4.9.1/test/test_autotest.rb0000444000004100000410000003213212141713143017360 0ustar www-datawww-data#!/usr/local/bin/ruby -w $TESTING = true require 'rubygems' require 'minitest/autorun' require 'stringio' require 'autotest' # NOT TESTED: # class_run # add_sigint_handler # all_good # get_to_green # reset # ruby # run # run_tests class Autotest attr_reader :test_mappings, :exception_list def self.clear_hooks HOOKS.clear end def self.reset_options @@options = {} end end class TestAutotest < MiniTest::Unit::TestCase alias :deny :refute RUBY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) def setup @test_class = 'TestBlah' @test = 'test/test_blah.rb' @other_test = 'test/test_blah_other.rb' @impl = 'lib/blah.rb' @inner_test = 'test/outer/test_inner.rb' @outer_test = 'test/test_outer.rb' @inner_test_class = "TestOuter::TestInner" klassname = self.class.name.sub(/^Test/, '') klassname.sub!(/^(\w+)(Autotest)$/, '\2::\1') unless klassname == "Autotest" @a = klassname.split(/::/).inject(Object) { |k,n| k.const_get(n) }.new @a.output = StringIO.new @a.last_mtime = Time.at(2) @files = {} @files[@impl] = Time.at(1) @files[@test] = Time.at(2) @a.find_order = @files.keys.sort end def test_add_exception current = util_exceptions @a.add_exception 'blah' actual = util_exceptions expect = current + ["blah"] assert_equal expect, actual end def test_add_mapping current = util_mappings @a.add_mapping(/blah/) do 42 end actual = util_mappings expect = current + [/blah/] assert_equal expect, actual end def test_add_mapping_front current = util_mappings @a.add_mapping(/blah/, :front) do 42 end actual = util_mappings expect = [/blah/] + current assert_equal expect, actual end def test_clear_exceptions test_add_exception @a.clear_exceptions actual = util_exceptions expect = [] assert_equal expect, actual end def test_clear_mapping @a.clear_mappings actual = util_mappings expect = [] assert_equal expect, actual end def test_consolidate_failures_experiment @files.clear @files[@impl] = Time.at(1) @files[@test] = Time.at(2) @a.find_order = @files.keys.sort input = [['test_fail1', @test_class], ['test_fail2', @test_class], ['test_error1', @test_class], ['test_error2', @test_class]] result = @a.consolidate_failures input expected = { @test => %w( test_fail1 test_fail2 test_error1 test_error2 ) } assert_equal expected, result end def test_consolidate_failures_green result = @a.consolidate_failures([]) expected = {} assert_equal expected, result end def test_consolidate_failures_multiple_possibilities @files[@other_test] = Time.at(42) result = @a.consolidate_failures([['test_unmatched', @test_class]]) expected = { @test => ['test_unmatched']} assert_equal expected, result expected = "" assert_equal expected, @a.output.string end def test_consolidate_failures_nested_classes @files.clear @files['lib/outer.rb'] = Time.at(5) @files['lib/outer/inner.rb'] = Time.at(5) @files[@inner_test] = Time.at(5) @files[@outer_test] = Time.at(5) @a.find_order = @files.keys.sort result = @a.consolidate_failures([['test_blah1', @inner_test_class]]) expected = { @inner_test => ['test_blah1'] } assert_equal expected, result expected = "" assert_equal expected, @a.output.string end def test_consolidate_failures_no_match result = @a.consolidate_failures([['test_blah1', @test_class], ['test_blah2', @test_class], ['test_blah1', 'TestUnknown']]) expected = {@test => ['test_blah1', 'test_blah2']} assert_equal expected, result expected = "Unable to map class TestUnknown to a file\n" assert_equal expected, @a.output.string end def test_consolidate_failures_red result = @a.consolidate_failures([['test_blah1', @test_class], ['test_blah2', @test_class]]) expected = {@test => ['test_blah1', 'test_blah2']} assert_equal expected, result end def test_exceptions @a.clear_exceptions test_add_exception assert_equal(/blah/, @a.exceptions) end def test_exceptions_nil @a.clear_exceptions assert_nil @a.exceptions end # TODO: lots of filename edgecases for find_files_to_test def test_find_files_to_test @a.last_mtime = Time.at(0) assert @a.find_files_to_test(@files) @a.last_mtime = @files.values.sort.last + 1 deny @a.find_files_to_test(@files) end def test_find_files_to_test_dunno empty = {} files = { "fooby.rb" => Time.at(42) } assert @a.find_files_to_test(files) # we find fooby, assert_equal empty, @a.files_to_test # but it isn't something to test assert_equal "No tests matched fooby.rb\n", @a.output.string end def test_find_files_to_test_lib # ensure we add test_blah.rb when blah.rb updates util_find_files_to_test(@impl, @test => []) end def test_find_files_to_test_no_change empty = {} # ensure world is virginal assert_equal empty, @a.files_to_test # ensure we do nothing when nothing changes... files = { @impl => @files[@impl] } # same time deny @a.find_files_to_test(files) assert_equal empty, @a.files_to_test assert_equal "", @a.output.string files = { @impl => @files[@impl] } # same time assert(! @a.find_files_to_test(files)) assert_equal empty, @a.files_to_test assert_equal "", @a.output.string end def test_find_files_to_test_test # ensure we add test_blah.rb when test_blah.rb itself updates util_find_files_to_test(@test, @test => []) end def test_reorder_alpha @a.order = :alpha expected = @files.sort assert_equal expected, @a.reorder(@files) end def test_reorder_reverse @a.order = :reverse expected = @files.sort.reverse assert_equal expected, @a.reorder(@files) end def test_reorder_random @a.order = :random srand 42 expected, size = @files.dup, @files.size expected = expected.sort_by { rand(size) } srand 42 result = @a.reorder(@files.dup) assert_equal expected, result end def test_reorder_natural srand 42 @files['lib/untested_blah.rb'] = Time.at(2) @a.find_order = @files.keys.sort_by { rand } @a.order = :natural expected = @a.find_order.map { |f| [f, @files[f]] } assert_equal expected, @a.reorder(@files) end def test_handle_results @a.files_to_test.clear @files.clear @files[@impl] = Time.at(1) @files[@test] = Time.at(2) @a.find_order = @files.keys.sort empty = {} assert_equal empty, @a.files_to_test, "must start empty" s1 = "Loaded suite -e Started ............ Finished in 0.001655 seconds. 12 tests, 18 assertions, 0 failures, 0 errors " @a.handle_results(s1) assert_equal empty, @a.files_to_test, "must stay empty" exp = { "tests" => 12, "assertions" => 18, "failures" => 0, "errors" => 0 } assert_equal exp, @a.latest_results # when colours are in the error message color_error = " 1) \e[31mFailure:\e[0m test_fail1(#{@test_class}) [#{@test}:59]: 2) \e[31mFailure:\e[0m test_fail2(#{@test_class}) [#{@test}:60]: 3) \e[31mError:\e[0m test_error1(#{@test_class}): 3) \e[31mError:\e[0m test_error2(#{@test_class}): 12 tests, 18 assertions, 2 failures, 2 errors " @a.handle_results(color_error) assert @a.tainted s2 = " 1) Failure: test_fail1(#{@test_class}) [#{@test}:59]: 2) Failure: test_fail2(#{@test_class}) [#{@test}:60]: 3) Error: test_error1(#{@test_class}): 3) Error: test_error2(#{@test_class}): 12 tests, 18 assertions, 2 failures, 2 errors " @a.handle_results(s2) expected = { @test => %w( test_fail1 test_fail2 test_error1 test_error2 ) } assert_equal expected, @a.files_to_test assert @a.tainted exp = { "tests" => 12, "assertions" => 18, "failures" => 2, "errors" => 2 } assert_equal exp, @a.latest_results @a.handle_results(s1) assert_equal empty, @a.files_to_test s3 = ' /opt/bin/ruby -I.:lib:test -rubygems -e "%w[test/unit #{@test}].each { |f| require f }" | unit_diff -u -e:1:in `require\': ./#{@test}:23: parse error, unexpected tIDENTIFIER, expecting \'}\' (SyntaxError) settings_fields.each {|e| assert_equal e, version.send e.intern} ^ from -e:1 from -e:1:in `each\' from -e:1 ' @a.files_to_test[@test] = Time.at(42) @files[@test] = [] expected = { @test => Time.at(42) } assert_equal expected, @a.files_to_test @a.handle_results(s3) assert_equal expected, @a.files_to_test assert @a.tainted @a.tainted = false @a.handle_results(s1) assert_equal empty, @a.files_to_test deny @a.tainted end def test_hook_overlap_returning_false util_reset_hooks_returning false @a.hook :blah assert @a.instance_variable_get(:@blah1), "Hook1 should work on blah" assert @a.instance_variable_get(:@blah2), "Hook2 should work on blah" assert @a.instance_variable_get(:@blah3), "Hook3 should work on blah" end def test_hook_overlap_returning_true util_reset_hooks_returning true @a.hook :blah assert @a.instance_variable_get(:@blah1), "Hook1 should work on blah" deny @a.instance_variable_get(:@blah2), "Hook2 should NOT work on blah" deny @a.instance_variable_get(:@blah3), "Hook3 should NOT work on blah" end def test_hook_response Autotest.clear_hooks deny @a.hook(:blah) Autotest.add_hook(:blah) { false } deny @a.hook(:blah) Autotest.add_hook(:blah) { false } deny @a.hook(:blah) Autotest.add_hook(:blah) { true } assert @a.hook(:blah) end def test_make_test_cmd f = { @test => [], 'test/test_fooby.rb' => [ 'test_something1', 'test_something2' ] } pre = "#{RUBY} -I.:lib:test -rubygems" req = ".each { |f| require f }\"" expected = [ "#{pre} -e \"%w[test/unit #{@test}]#{req}", "#{pre} test/test_fooby.rb -n \"/^(test_something1|test_something2)$/\"" ].join("; ") result = @a.make_test_cmd f assert_equal expected, result end def test_make_test_cmd_unit_diff @a.unit_diff = "unit_diff -u" f = { @test => [], 'test/test_fooby.rb' => [ 'test_something1', 'test_something2' ] } pre = "#{RUBY} -I.:lib:test -rubygems" req = ".each { |f| require f }\"" post = "| unit_diff -u" expected = [ "#{pre} -e \"%w[test/unit #{@test}]#{req} #{post}", "#{pre} test/test_fooby.rb -n \"/^(test_something1|test_something2)$/\" #{post}" ].join("; ") result = @a.make_test_cmd f assert_equal expected, result end def test_path_to_classname # non-rails util_path_to_classname 'TestBlah', 'test/test_blah.rb' util_path_to_classname 'TestOuter::TestInner', 'test/outer/test_inner.rb' util_path_to_classname 'TestRuby2Ruby', 'test/test_ruby2ruby.rb' end def test_remove_exception test_add_exception current = util_exceptions @a.remove_exception 'blah' actual = util_exceptions expect = current - ["blah"] assert_equal expect, actual end def test_remove_mapping current = util_mappings @a.remove_mapping(/^lib\/.*\.rb$/) actual = util_mappings expect = current - [/^lib\/.*\.rb$/] assert_equal expect, actual end def test_test_files_for assert_equal [@test], @a.test_files_for(@impl) assert_equal [@test], @a.test_files_for(@test) assert_equal [], @a.test_files_for('test/test_unknown.rb') assert_equal [], @a.test_files_for('lib/unknown.rb') assert_equal [], @a.test_files_for('unknown.rb') assert_equal [], @a.test_files_for('test_unknown.rb') end def test_testlib assert_equal "test/unit", @a.testlib @a.testlib = "MONKEY" assert_equal "MONKEY", @a.testlib f = { @test => [], "test/test_fooby.rb" => %w(first second) } assert_match @a.testlib, @a.make_test_cmd(f) end def test_runner_accepts_rc_options begin Autotest.parse_options(['--rc', 'autotest_rc']) Autotest.new rescue deny $!, "It should not throw #{$!.message}" ensure Autotest.reset_options end end def util_exceptions @a.exception_list.sort_by { |r| r.to_s } end def util_find_files_to_test(f, expected) t = @a.last_mtime files = { f => t + 1 } assert @a.find_files_to_test(files) assert_equal expected, @a.files_to_test assert_equal t, @a.last_mtime assert_equal "", @a.output.string end def util_mappings @a.test_mappings.map { |k,v| k } end def util_path_to_classname(e,i) assert_equal e, @a.path_to_classname(i) end def util_reset_hooks_returning val Autotest.clear_hooks @a.instance_variable_set :@blah1, false @a.instance_variable_set :@blah2, false @a.instance_variable_set :@blah3, false Autotest.add_hook(:blah) do |at| at.instance_variable_set :@blah1, true val end Autotest.add_hook(:blah) do |at| at.instance_variable_set :@blah2, true val end Autotest.add_hook(:blah) do |at| at.instance_variable_set :@blah3, true val end end end ZenTest-4.9.1/test/test_focus.rb0000444000004100000410000000066712141713143016637 0ustar www-datawww-datarequire 'rubygems' require 'minitest/autorun' require 'focus' class TestFocus < MiniTest::Unit::TestCase def setup @x = 1 end def teardown assert_equal 2, @x end def test_focus @x += 1 end def test_ignore1 flunk "ignore me!" end def test_ignore2 flunk "ignore me!" end def test_ignore3 flunk "ignore me!" end def test_focus2 @x += 1 end focus :test_focus, :test_focus2 end ZenTest-4.9.1/test/test_unit_diff.rb0000555000004100000410000003372012141713143017466 0ustar www-datawww-data#!/usr/local/bin/ruby -w require 'rubygems' require 'minitest/autorun' require 'stringio' $TESTING = true require 'unit_diff' class TestUnitDiff < MiniTest::Unit::TestCase def setup @diff = UnitDiff.new end def test_input header = "Loaded suite ./blah\nStarted\nFF\nFinished in 0.035332 seconds.\n\n" input = "#{header} 1) Failure:\ntest_test1(TestBlah) [./blah.rb:25]:\n<\"line1\\nline2\\nline3\\n\"> expected but was\n<\"line4\\nline5\\nline6\\n\">.\n\n 2) Failure:\ntest_test2(TestBlah) [./blah.rb:29]:\n<\"line1\"> expected but was\n<\"line2\\nline3\\n\\n\">.\n\n2 tests, 2 assertions, 2 failures, 0 errors\n" # TODO: I think I'd like a separate footer array as well expected = [[[" 1) Failure:\n", "test_test1(TestBlah) [./blah.rb:25]:\n", "<\"line1\\nline2\\nline3\\n\"> expected but was\n", "<\"line4\\nline5\\nline6\\n\">.\n"], [" 2) Failure:\n", "test_test2(TestBlah) [./blah.rb:29]:\n", "<\"line1\"> expected but was\n", "<\"line2\\nline3\\n\\n\">.\n"]], ["\n", "2 tests, 2 assertions, 2 failures, 0 errors\n"]] util_unit_diff(header, input, expected, :parse_input) end def test_input_miniunit header = "Loaded suite -e\nStarted\nF\nFinished in 0.035332 seconds.\n\n" input = "#{header} 1) Failure: test_blah(TestBlah) [./blah.rb:25]: Expected ['a', 'b', 'c'], not ['a', 'c', 'b']. 1 tests, 1 assertions, 1 failures, 0 errors " expected = [[[" 1) Failure:\n", "test_blah(TestBlah) [./blah.rb:25]:\n", "Expected ['a', 'b', 'c'], not ['a', 'c', 'b'].\n"]], ["\n", "1 tests, 1 assertions, 1 failures, 0 errors\n"]] util_unit_diff(header, input, expected, :parse_input) end def test_input_miniunit_multiline header = "Loaded suite -e\nStarted\nF\nFinished in 0.035332 seconds.\n\n" input = "#{header} 1) Failure: test_blah(TestBlah) [./blah.rb:25]: Expected ['a', 'b', 'c'], not ['a', 'c', 'b']. 1 tests, 1 assertions, 1 failures, 0 errors " expected = [[[" 1) Failure:\n", "test_blah(TestBlah) [./blah.rb:25]:\n", "Expected ['a',\n 'b',\n 'c'], not ['a',\n 'c',\n 'b'].\n"]], ["\n", "1 tests, 1 assertions, 1 failures, 0 errors\n"]] util_unit_diff(header, input, expected, :parse_input) end def test_input_mspec header = <<-HEADER Started .......F Finished in 0.1 seconds HEADER failure = <<-FAILURE 1) The unless expression should fail FAILED Expected nil to equal "baz": FAILURE backtrace = <<-BACKTRACE PositiveExpectation#== at spec/mspec.rb:217 main.__script__ {} at spec/language/unless_spec.rb:49 Proc#call at kernel/core/proc.rb:127 SpecRunner#it at spec/mspec.rb:368 main.it at spec/mspec.rb:412 main.__script__ {} at spec/language/unless_spec.rb:48 Proc#call at kernel/core/proc.rb:127 SpecRunner#describe at spec/mspec.rb:378 main.describe at spec/mspec.rb:408 main.__script__ at spec/language/unless_spec.rb:3 CompiledMethod#as_script at kernel/bootstrap/primitives.rb:41 main.load at kernel/core/compile.rb:150 main.__script__ {} at last_mspec.rb:11 Array#each {} at kernel/core/array.rb:545 Integer(Fixnum)#times at kernel/core/integer.rb:15 Array#each at kernel/core/array.rb:545 main.__script__ at last_mspec.rb:16 CompiledMethod#as_script at kernel/bootstrap/primitives.rb:41 main.load at kernel/core/compile.rb:150 main.__script__ at kernel/loader.rb:145 BACKTRACE footer = "\n8 examples, 1 failures\n" input = header + failure + backtrace + footer expected_backtrace = backtrace.split("\n").map {|l| "#{l}\n"} expected = [[["1)\n", "The unless expression should fail FAILED\n", "Expected nil to equal \"baz\":\n", *expected_backtrace]], ["\n", "8 examples, 1 failures\n"]] util_unit_diff(header, input, expected, :parse_input) end def test_input_mspec_multiline header = <<-HEADER Started .......F Finished in 0.1 seconds HEADER failure = <<-FAILURE 1) Compiler compiles a case without an argument FAILED Expected #], [:push_literal, "foo"], [:string_dup], [:goto, #