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

* bootstraptest/runner.rb (assert_check): new method.

(assert_match): new method.
  (assert_equal): use assert_check.
  (pretty): give failure description as an argument.

* bootstraptest/test_exception.rb: use assert_match to describe the
  test for [ruby-dev:31407].  [ruby-dev:31412]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2007-08-14 12:48:12 +00:00
parent 7e8d337aa4
commit b235e8f474
3 changed files with 41 additions and 15 deletions

View file

@ -1,3 +1,13 @@
Tue Aug 14 21:43:39 2007 Tanaka Akira <akr@fsij.org>
* bootstraptest/runner.rb (assert_check): new method.
(assert_match): new method.
(assert_equal): use assert_check.
(pretty): give failure description as an argument.
* bootstraptest/test_exception.rb: use assert_match to describe the
test for [ruby-dev:31407]. [ruby-dev:31412]
Tue Aug 14 19:53:15 2007 Koichi Sasada <ko1@atdot.net>
* proc.c (Init_Proc), eval.c (Init_eval), eval_intern.h: move

View file

@ -95,25 +95,47 @@ def exec_test(pathes)
end
end
def assert_equal(expected, testsrc, message = '')
def assert_check(testsrc, message = '')
newtest
$stderr.puts "\##{@count} #{@location}" if @verbose
result = get_result_string(testsrc)
check_coredump
if expected == result
faildesc = yield(result)
if !faildesc
$stderr.print '.'
else
$stderr.print 'F'
error pretty(testsrc, expected, result), message
error faildesc, message
end
rescue Exception => err
$stderr.print 'E'
error err.message, message
end
def pretty(src, ex, result)
(/\n/ =~ src ? "\n#{adjust_indent(src)}" : src) +
" #=> #{result.inspect} (expected #{ex.inspect})"
def assert_equal(expected, testsrc, message = '')
assert_check(testsrc, message) {|result|
if expected == result
nil
else
desc = "#{result.inspect} (expected #{expected.inspect})"
pretty(testsrc, desc, result)
end
}
end
def assert_match(expected_pattern, testsrc, message = '')
assert_check(testsrc, message) {|result|
if expected_pattern =~ result
nil
else
desc = "#{expected_pattern.inspect} expected to be =~\n#{result.inspect}"
pretty(testsrc, desc, result)
end
}
end
def pretty(src, desc, result)
(/\n/ =~ src ? "\n#{adjust_indent(src)}" : src) + " #=> #{desc}"
end
INDENT = 27

View file

@ -370,12 +370,11 @@ assert_equal %q{}, %q{
}
##
assert_equal "ok", %q{
$foo = "ok"
assert_match /undefined method `foo'/, %q{
STDERR.reopen(STDOUT)
class C
def inspect
bar {}
$foo = "ng"
end
def bar
@ -383,11 +382,6 @@ assert_equal "ok", %q{
ensure
end
end
begin
C.new.foo
rescue NoMethodError => e
$foo
end
}, "[ruby-dev:31407]"