ruby-changes:8409
From: ryan <ko1@a...>
Date: Sun, 26 Oct 2008 07:38:27 +0900 (JST)
Subject: [ruby-changes:8409] Ruby:r19940 (trunk): Imported minitest 1.3.0 r4429. Fixes issues reported by akira and nobu
ryan 2008-10-26 07:38:09 +0900 (Sun, 26 Oct 2008) New Revision: 19940 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=19940 Log: Imported minitest 1.3.0 r4429. Fixes issues reported by akira and nobu Modified files: trunk/ChangeLog trunk/lib/minitest/unit.rb trunk/test/minitest/test_mini_spec.rb trunk/test/minitest/test_mini_test.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 19939) +++ ChangeLog (revision 19940) @@ -1,3 +1,8 @@ +Sun Oct 26 07:35:56 2008 Ryan Davis <ryan@w...> + + * lib/minitest/unit.rb: Imported minitest 1.3.0 r4429. + * test/minitest/*: ditto. + Sun Oct 26 02:16:29 2008 Yuki Sonoda (Yugui) <yugui@y...> * configure.in ($MANTYPE): followed ruby.1, which had moved. Index: lib/minitest/unit.rb =================================================================== --- lib/minitest/unit.rb (revision 19939) +++ lib/minitest/unit.rb (revision 19940) @@ -87,7 +87,7 @@ def assert_in_delta exp, act, delta = 0.001, msg = nil n = (exp - act).abs msg = message(msg) { "Expected #{exp} - #{act} (#{n}) to be < #{delta}" } - assert delta > n, msg + assert delta >= n, msg end def assert_in_epsilon a, b, epsilon = 0.001, msg = nil @@ -139,7 +139,10 @@ yield should_raise = true rescue Exception => e - assert_includes(exp, e.class, exception_details(e, "<#{mu_pp(exp)}> exception expected, not")) + assert(exp.any? { |ex| + ex.instance_of?(Module) ? e.kind_of?(ex) : ex == e.class + }, exception_details(e, "#{mu_pp(exp)} exception expected, not")) + return e end @@ -188,12 +191,12 @@ assert caught, message(msg) { default } end - def capture_io - require 'stringio' + def capture_io + require 'stringio' - orig_stdout, orig_stderr = $stdout.dup, $stderr.dup - captured_stdout, captured_stderr = StringIO.new, StringIO.new - $stdout, $stderr = captured_stdout, captured_stderr + orig_stdout, orig_stderr = $stdout, $stderr + captured_stdout, captured_stderr = StringIO.new, StringIO.new + $stdout, $stderr = captured_stdout, captured_stderr yield @@ -303,14 +306,14 @@ refute exp.equal?(act), msg end - def skip msg = nil + def skip msg = nil, bt = caller msg ||= "Skipped, no message given" - raise MiniTest::Skip, msg + raise MiniTest::Skip, msg, bt end end class Unit - VERSION = "1.3.0" + VERSION = "1.3.1" attr_accessor :report, :failures, :errors, :skips attr_accessor :test_count, :assertion_count Index: test/minitest/test_mini_spec.rb =================================================================== --- test/minitest/test_mini_spec.rb (revision 19939) +++ test/minitest/test_mini_spec.rb (revision 19940) @@ -10,7 +10,7 @@ describe MiniTest::Spec do before do - @assertion_count = 5 + @assertion_count = 4 end after do @@ -65,7 +65,7 @@ end it "needs to verify kinds of objects" do - @assertion_count = 7 + @assertion_count = 6 (6 * 7).must_be_kind_of(Fixnum).must_equal true (6 * 7).must_be_kind_of(Numeric).must_equal true @@ -73,7 +73,8 @@ end it "needs to verify regexp matches" do - @assertion_count = 7 + @assertion_count = 6 + "blah".must_match(/\w+/).must_equal true proc { "blah".must_match(/\d+/) }.must_raise MiniTest::Assertion end @@ -89,14 +90,14 @@ end it "needs to catch an expected exception" do - @assertion_count = 4 + @assertion_count = 2 proc { raise "blah" }.must_raise RuntimeError proc { raise MiniTest::Assertion }.must_raise MiniTest::Assertion end it "needs to catch an unexpected exception" do - @assertion_count = 4 + @assertion_count = 2 proc { proc { raise MiniTest::Assertion }.must_raise(RuntimeError) @@ -104,13 +105,13 @@ end it "needs raise if an expected exception is not raised" do - @assertion_count = 3 + @assertion_count = 2 proc { proc { 42 }.must_raise(RuntimeError) }.must_raise MiniTest::Assertion end it "needs to be able to catch a MiniTest::Assertion exception" do - @assertion_count = 3 + @assertion_count = 2 proc { 1.wont_equal 1 }.must_raise MiniTest::Assertion end @@ -126,7 +127,7 @@ end it "needs to verify throw" do - @assertion_count = 8 + @assertion_count = 6 proc { throw :blah }.must_throw(:blah).must_equal true proc { proc { }.must_throw(:blah) }.must_raise MiniTest::Assertion Index: test/minitest/test_mini_test.rb =================================================================== --- test/minitest/test_mini_test.rb (revision 19939) +++ test/minitest/test_mini_test.rb (revision 19940) @@ -9,8 +9,10 @@ MiniTest::Unit.autorun +module M; end +class E < StandardError; include M; end + class TestMiniTest < MiniTest::Unit::TestCase - def setup srand 42 MiniTest::Unit::TestCase.reset @@ -248,10 +250,10 @@ " output = @output.string.sub(/Finished in .*/, "Finished in 0.00") output.sub!(/Loaded suite .*/, 'Loaded suite blah') - output.sub!(/[\w\/\.]+:\d+/, 'FILE:LINE') + output.sub!(/^(\s+)(?:#{Regexp.union(__FILE__, File.expand_path(__FILE__))}):\d+:/o, '\1FILE:LINE:') + output.sub!(/\[(?:#{Regexp.union(__FILE__, File.expand_path(__FILE__))}):\d+\]/o, '[FILE:LINE]') assert_equal(expected, output) - end - + end def test_run_failing_filtered tc = Class.new(MiniTest::Unit::TestCase) do def test_something @@ -426,7 +428,7 @@ end def test_assert_includes_triggered - @assertion_count = 4 + @assertion_count = 3 e = @tc.assert_raises MiniTest::Assertion do @tc.assert_includes [true], false @@ -489,31 +491,35 @@ end def test_assert_raises - @assertion_count = 2 - @tc.assert_raises RuntimeError do raise "blah" end end + def test_assert_raises_module + @tc.assert_raises M do + raise E + end + end + def test_assert_raises_triggered_different - @assertion_count = 2 - e = assert_raises MiniTest::Assertion do @tc.assert_raises RuntimeError do raise SyntaxError, "icky" end end - expected = "<[RuntimeError]> exception expected, not + expected = "[RuntimeError] exception expected, not Class: <SyntaxError> Message: <\"icky\"> ---Backtrace--- FILE:LINE:in `test_assert_raises_triggered_different' ----------------. -Expected [RuntimeError] to include SyntaxError." +---------------" - assert_equal expected, expected.gsub(/[\w\/\.]+:\d+/, 'FILE:LINE') + actual = e.message.gsub(/[\w\/\.]+:\d+/, 'FILE:LINE') + actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION =~ /^1\.9/ + + assert_equal expected, actual end def test_assert_raises_triggered_none @@ -528,6 +534,26 @@ assert_equal expected, e.message end + def test_assert_raises_triggered_subclass + e = assert_raises MiniTest::Assertion do + @tc.assert_raises StandardError do + raise E + end + end + + expected = "[StandardError] exception expected, not +Class: <E> +Message: <\"E\"> +---Backtrace--- +FILE:LINE:in `test_assert_raises_triggered_subclass' +---------------" + + actual = e.message.gsub(/[\w\/\.]+:\d+/, 'FILE:LINE') + actual.gsub!(/block \(\d+ levels\) in /, '') if RUBY_VERSION =~ /^1\.9/ + + assert_equal expected, actual + end + def test_assert_respond_to @tc.assert_respond_to "blah", :empty? end @@ -733,7 +759,7 @@ end def test_refute_includes_triggered - @assertion_count = 4 + @assertion_count = 3 e = @tc.assert_raises MiniTest::Assertion do @tc.refute_includes [true], true -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/