Project

General

Profile

Actions

Bug #984

closed

Test::Unit::Assertions#assert_match double counts number of assertions

Added by ngoto (Naohisa Goto) about 15 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
ruby -v:
ruby 1.9.1p5000 (2009-01-27 trunk 21804) [i686-linux]
Backport:
[ruby-dev:37703]

Description

=begin
Ruby 1.9.1-rc1 にて、Test::Unit::Assertions#assert_match が
assertionsの数を1回あたり2ずつ増やしています。
なお、failure の数は正しく増えています。

以下の例では、2回しかassert_matchを実行しないはずなのに"4 assertions"になっています。

$ ruby191rc1 -v -r test/unit -e 'class A<Test::Unit::TestCase; def test_a; assert_match(/a/, "a"); end; def test_b; assert_match(/b/, "a"); end; end'
ruby 1.9.1 (2008-12-30 patchlevel-0 revision 21203) [i686-linux]
Loaded suite -e
Started
.F
Finished in 0.001318 seconds.

  1. Failure:
    test_b(A) [-e:1]:
    Expected /b/ to match "a".

2 tests, 4 assertions, 1 failures, 0 errors, 0 skips

1.8.7 では正しくカウントしています。

% ruby187p72 -v -r test/unit -e 'class A<Test::Unit::TestCase; def test_a; assert_match(/a/, "a"); end; def test_b; assert_match(/b/, "a"); end; end'
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-linux]
Loaded suite -e
Started
.F
Finished in 0.030196 seconds.

  1. Failure:
    test_b(A) [-e:1]:
    <"a"> expected to be =~
    </b/>.

2 tests, 2 assertions, 1 failures, 0 errors
=end

Actions #1

Updated by okkez (okkez _) about 15 years ago

=begin
okkez です。

2009/1/5 Naohisa Goto :

Bug #984: Test::Unit::Assertions#assert_match double counts number of assertions
http://redmine.ruby-lang.org/issues/show/984

起票者: Naohisa Goto
ステータス: Open, 優先度: Normal

Ruby 1.9.1-rc1 にて、Test::Unit::Assertions#assert_match が
assertionsの数を1回あたり2ずつ増やしています。
なお、failure の数は正しく増えています。

assert_match 以外でも assert_respond_to でメソッドの存在チェックをしているため
assertions が二回増えるものがいくつかあります。

  • assert_match
  • assert_empty
  • assert_includes
  • 対応する refute_*

一回の assert_* 呼び出しで二回 assertions が増えるのはうれしくないと思います。

--
okkez

=end

Actions #2

Updated by yugui (Yuki Sonoda) about 15 years ago

  • Target version set to 1.9.1 RC2

=begin

=end

Actions #3

Updated by yugui (Yuki Sonoda) about 15 years ago

  • Status changed from Open to Closed

=begin
applied in r21599.
=end

Actions #4

Updated by ngoto (Naohisa Goto) about 15 years ago

=begin
r21599はr21695でrevertされているため、1.9.1-rc2では再発しています。
また、現時点のRUBY_1_9_1およびtrunkでも同様に再発しているようです。
Bug #984を再openすることを希望します。

assertionsの数が2増えるのが嫌なのは、Ruby 1.8.xと1.9.1の両方で動く
プログラムを作成する際に、両バージョンでテストを走らせたときの
assertionsの数が一致するのを確認することで、テスト自体を含めて
変なことが発生せず想定通り動いているかどうかを見たいからです。

=end

Actions #5

Updated by matz (Yukihiro Matsumoto) about 15 years ago

  • Status changed from Closed to Open
  • ruby -v set to ruby 1.9.1p5000 (2009-01-27 trunk 21804) [i686-linux]

=begin

=end

Actions #6

Updated by nobu (Nobuyoshi Nakada) about 15 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r21887.
=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0