1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Imported minitest 3.2.0 (r7598). Reviewed by drbrain

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ryan 2012-07-11 23:52:04 +00:00
parent 35784d1019
commit 9696b3eb16
8 changed files with 33 additions and 31 deletions

View file

@ -1,3 +1,8 @@
Thu Jul 12 08:48:33 2012 Ryan Davis <ryand-ruby@zenspider.com>
* lib/minitest/*: Imported minitest 3.2.0 (r7598)
* test/minitest/*: ditto
Thu Jul 12 05:11:41 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> Thu Jul 12 05:11:41 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* insns.def (defined): use method entry and id in cfp for proper * insns.def (defined): use method entry and id in cfp for proper

View file

@ -57,12 +57,12 @@ module MiniTest
self self
end end
def call name, data def __call name, data
case data case data
when Hash then when Hash then
"#{name}(#{data[:args].inspect[1..-2]}) => #{data[:retval].inspect}" "#{name}(#{data[:args].inspect[1..-2]}) => #{data[:retval].inspect}"
else else
data.map { |d| call name, d }.join ", " data.map { |d| __call name, d }.join ", "
end end
end end
@ -74,15 +74,16 @@ module MiniTest
def verify def verify
@expected_calls.each do |name, calls| @expected_calls.each do |name, calls|
calls.each do |expected| calls.each do |expected|
msg1 = "expected #{call name, expected}" msg1 = "expected #{__call name, expected}"
msg2 = "#{msg1}, got [#{call name, @actual_calls[name]}]" msg2 = "#{msg1}, got [#{__call name, @actual_calls[name]}]"
raise MockExpectationError, msg2 if raise MockExpectationError, msg2 if
@actual_calls.has_key? name and @actual_calls.has_key?(name) and
not @actual_calls[name].include?(expected) not @actual_calls[name].include?(expected)
raise MockExpectationError, msg1 unless raise MockExpectationError, msg1 unless
@actual_calls.has_key? name and @actual_calls[name].include?(expected) @actual_calls.has_key?(name) and
@actual_calls[name].include?(expected)
end end
end end
true true
@ -163,7 +164,7 @@ class Object # :nodoc:
end end
end end
yield yield self
ensure ensure
metaclass.send :undef_method, name metaclass.send :undef_method, name
metaclass.send :alias_method, name, new_name metaclass.send :alias_method, name, new_name

View file

@ -181,12 +181,6 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
add_teardown_hook {|tc| tc.instance_eval(&block) } add_teardown_hook {|tc| tc.instance_eval(&block) }
end end
NAME_RE = if RUBY_VERSION >= "1.9"
Regexp.new("[^[[:word:]]]+")
else
/\W+/u
end
## ##
# Define an expectation with name +desc+. Name gets morphed to a # Define an expectation with name +desc+. Name gets morphed to a
# proper test method name. For some freakish reason, people who # proper test method name. For some freakish reason, people who
@ -204,7 +198,7 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
@specs ||= 0 @specs ||= 0
@specs += 1 @specs += 1
name = "test_%04d_%s" % [ @specs, desc.gsub(NAME_RE, '_').downcase ] name = "test_%04d_%s" % [ @specs, desc ]
define_method name, &block define_method name, &block

View file

@ -652,7 +652,7 @@ module MiniTest
end end
class Unit # :nodoc: class Unit # :nodoc:
VERSION = "3.0.0" # :nodoc: VERSION = "3.2.0" # :nodoc:
attr_accessor :report, :failures, :errors, :skips # :nodoc: attr_accessor :report, :failures, :errors, :skips # :nodoc:
attr_accessor :test_count, :assertion_count # :nodoc: attr_accessor :test_count, :assertion_count # :nodoc:
@ -713,16 +713,6 @@ module MiniTest
@@out @@out
end end
##
# Returns the stream to use for output.
#
# DEPRECATED: use ::output instead.
def self.out
warn "::out deprecated, use ::output instead." if $VERBOSE
output
end
## ##
# Sets MiniTest::Unit to write output to +stream+. $stdout is the default # Sets MiniTest::Unit to write output to +stream+. $stdout is the default
# output # output

View file

@ -27,6 +27,8 @@ class MetaMetaMetaTestCase < MiniTest::Unit::TestCase
output.sub!(/Finished tests in .*/, "Finished tests in 0.00") output.sub!(/Finished tests in .*/, "Finished tests in 0.00")
output.sub!(/Loaded suite .*/, 'Loaded suite blah') output.sub!(/Loaded suite .*/, 'Loaded suite blah')
output.gsub!(/ = \d+.\d\d s = /, ' = 0.00 s = ')
if windows? then if windows? then
output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, '[FILE:LINE]') output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, '[FILE:LINE]')
output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in') output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in')

View file

@ -211,7 +211,7 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
end end
end end
require "metametameta" require "minitest/metametameta"
class TestMiniTestStub < MiniTest::Unit::TestCase class TestMiniTestStub < MiniTest::Unit::TestCase
def setup def setup
@ -268,4 +268,14 @@ class TestMiniTestStub < MiniTest::Unit::TestCase
assert_stub obj assert_stub obj
end end
def test_stub_yield_self
obj = "foo"
val = obj.stub :to_s, "bar" do |s|
s.to_s
end
@tc.assert_equal "bar", val
end
end end

View file

@ -645,8 +645,8 @@ class TestMeta < MiniTest::Unit::TestCase
assert_equal "inner thingy", y.desc assert_equal "inner thingy", y.desc
assert_equal "very inner thingy", z.desc assert_equal "very inner thingy", z.desc
top_methods = %w(test_0001_top_level_it) top_methods = %w(test_0001_top-level-it)
inner_methods1 = %w(test_0001_inner_it) inner_methods1 = %w(test_0001_inner-it)
inner_methods2 = inner_methods1 + inner_methods2 = inner_methods1 +
%w(test_0002_anonymous test_0003_anonymous) %w(test_0002_anonymous test_0003_anonymous)
@ -690,13 +690,13 @@ class TestMeta < MiniTest::Unit::TestCase
x = describe "top-level thingy" do x = describe "top-level thingy" do
y = describe "first thingy" do end y = describe "first thingy" do end
x1 = it "top-level-it" do end x1 = it "top level it" do end
x2 = it "не латинские буквы-и-спецсимволы&いった α, β, γ, δ, ε hello!!! world" do end x2 = it "не латинские буквы-и-спецсимволы&いった α, β, γ, δ, ε hello!!! world" do end
z = describe "second thingy" do end z = describe "second thingy" do end
end end
test_methods = ['test_0001_top_level_it', 'test_0002_неатинские_буквы_и_спецсимволы_いった_α_β_γ_δ_ε_hello_world'].sort test_methods = ['test_0001_top level it', 'test_0002_не латинские буквы-и-спецсимволы&いった α, β, γ, δ, ε hello!!! world'].sort
assert_equal test_methods, [x1, x2] assert_equal test_methods, [x1, x2]
assert_equal test_methods, assert_equal test_methods,

View file

@ -6,7 +6,7 @@
###################################################################### ######################################################################
require 'pathname' require 'pathname'
require 'metametameta' require 'minitest/metametameta'
module MyModule; end module MyModule; end
class AnError < StandardError; include MyModule; end class AnError < StandardError; include MyModule; end