Bug #984

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

Added by Naohisa Goto about 3 years ago. Updated 10 months ago.

[ruby-dev:37703]
Status:Closed Start date:01/05/2009
Priority:Normal Due date:
Assignee:- % Done:

100%

Category:-
Target version:1.9.1 RC2
ruby -v:ruby 1.9.1p5000 (2009-01-27 trunk 21804) [i686-linux]

Description

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

Associated revisions

Revision 21887
Added by Nobuyoshi Nakada about 3 years ago

* lib/test/unit/assertions.rb (assert_respond_to): gets rid of overcounting. [ruby-dev:37703]

History

Updated by okkez _ about 3 years ago

okkez です。

2009/1/5 Naohisa Goto <redmine@ruby-lang.org>:
> 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
okkez000@gmail.com

Updated by Yuki Sonoda about 3 years ago

  • Target version set to 1.9.1 RC2
  • Reproducible Version set to 1.9.1 RC1

Updated by Yuki Sonoda about 3 years ago

  • Status changed from Open to Closed
applied in r21599.

Updated by Naohisa Goto about 3 years ago

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の数が一致するのを確認することで、テスト自体を含めて
変なことが発生せず想定通り動いているかどうかを見たいからです。

Updated by Yukihiro Matsumoto about 3 years ago

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

Updated by Nobuyoshi Nakada about 3 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100
Applied in changeset r21887.

Also available in: Atom PDF