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:
parent
35784d1019
commit
9696b3eb16
8 changed files with 33 additions and 31 deletions
|
@ -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>
|
||||
|
||||
* insns.def (defined): use method entry and id in cfp for proper
|
||||
|
|
|
@ -57,12 +57,12 @@ module MiniTest
|
|||
self
|
||||
end
|
||||
|
||||
def call name, data
|
||||
def __call name, data
|
||||
case data
|
||||
when Hash then
|
||||
"#{name}(#{data[:args].inspect[1..-2]}) => #{data[:retval].inspect}"
|
||||
else
|
||||
data.map { |d| call name, d }.join ", "
|
||||
data.map { |d| __call name, d }.join ", "
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -74,15 +74,16 @@ module MiniTest
|
|||
def verify
|
||||
@expected_calls.each do |name, calls|
|
||||
calls.each do |expected|
|
||||
msg1 = "expected #{call name, expected}"
|
||||
msg2 = "#{msg1}, got [#{call name, @actual_calls[name]}]"
|
||||
msg1 = "expected #{__call name, expected}"
|
||||
msg2 = "#{msg1}, got [#{__call name, @actual_calls[name]}]"
|
||||
|
||||
raise MockExpectationError, msg2 if
|
||||
@actual_calls.has_key? name and
|
||||
@actual_calls.has_key?(name) and
|
||||
not @actual_calls[name].include?(expected)
|
||||
|
||||
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
|
||||
true
|
||||
|
@ -163,7 +164,7 @@ class Object # :nodoc:
|
|||
end
|
||||
end
|
||||
|
||||
yield
|
||||
yield self
|
||||
ensure
|
||||
metaclass.send :undef_method, name
|
||||
metaclass.send :alias_method, name, new_name
|
||||
|
|
|
@ -181,12 +181,6 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|||
add_teardown_hook {|tc| tc.instance_eval(&block) }
|
||||
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
|
||||
# proper test method name. For some freakish reason, people who
|
||||
|
@ -204,7 +198,7 @@ class MiniTest::Spec < MiniTest::Unit::TestCase
|
|||
@specs ||= 0
|
||||
@specs += 1
|
||||
|
||||
name = "test_%04d_%s" % [ @specs, desc.gsub(NAME_RE, '_').downcase ]
|
||||
name = "test_%04d_%s" % [ @specs, desc ]
|
||||
|
||||
define_method name, &block
|
||||
|
||||
|
|
|
@ -652,7 +652,7 @@ module MiniTest
|
|||
end
|
||||
|
||||
class Unit # :nodoc:
|
||||
VERSION = "3.0.0" # :nodoc:
|
||||
VERSION = "3.2.0" # :nodoc:
|
||||
|
||||
attr_accessor :report, :failures, :errors, :skips # :nodoc:
|
||||
attr_accessor :test_count, :assertion_count # :nodoc:
|
||||
|
@ -713,16 +713,6 @@ module MiniTest
|
|||
@@out
|
||||
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
|
||||
# output
|
||||
|
|
|
@ -27,6 +27,8 @@ class MetaMetaMetaTestCase < MiniTest::Unit::TestCase
|
|||
output.sub!(/Finished tests in .*/, "Finished tests in 0.00")
|
||||
output.sub!(/Loaded suite .*/, 'Loaded suite blah')
|
||||
|
||||
output.gsub!(/ = \d+.\d\d s = /, ' = 0.00 s = ')
|
||||
|
||||
if windows? then
|
||||
output.gsub!(/\[(?:[A-Za-z]:)?[^\]:]+:\d+\]/, '[FILE:LINE]')
|
||||
output.gsub!(/^(\s+)(?:[A-Za-z]:)?[^:]+:\d+:in/, '\1FILE:LINE:in')
|
||||
|
|
|
@ -211,7 +211,7 @@ class TestMiniTestMock < MiniTest::Unit::TestCase
|
|||
end
|
||||
end
|
||||
|
||||
require "metametameta"
|
||||
require "minitest/metametameta"
|
||||
|
||||
class TestMiniTestStub < MiniTest::Unit::TestCase
|
||||
def setup
|
||||
|
@ -268,4 +268,14 @@ class TestMiniTestStub < MiniTest::Unit::TestCase
|
|||
|
||||
assert_stub obj
|
||||
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
|
||||
|
|
|
@ -645,8 +645,8 @@ class TestMeta < MiniTest::Unit::TestCase
|
|||
assert_equal "inner thingy", y.desc
|
||||
assert_equal "very inner thingy", z.desc
|
||||
|
||||
top_methods = %w(test_0001_top_level_it)
|
||||
inner_methods1 = %w(test_0001_inner_it)
|
||||
top_methods = %w(test_0001_top-level-it)
|
||||
inner_methods1 = %w(test_0001_inner-it)
|
||||
inner_methods2 = inner_methods1 +
|
||||
%w(test_0002_anonymous test_0003_anonymous)
|
||||
|
||||
|
@ -690,13 +690,13 @@ class TestMeta < MiniTest::Unit::TestCase
|
|||
x = describe "top-level thingy" do
|
||||
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
|
||||
|
||||
z = describe "second thingy" do 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,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
######################################################################
|
||||
|
||||
require 'pathname'
|
||||
require 'metametameta'
|
||||
require 'minitest/metametameta'
|
||||
|
||||
module MyModule; end
|
||||
class AnError < StandardError; include MyModule; end
|
||||
|
|
Loading…
Reference in a new issue