[#35406] RE: win32ole で excel が終了しない — "Oka Yasushi" <oka@...>

こんにちは、岡といいます。

20 messages 2002/06/19
[#35407] Re: win32ole で excel が終了しない — Takashi Kanai <kanai@...4u.or.jp> 2002/06/19

金井です。

[#35408] Re: win32ole で excel が終了しない — Takashi Kanai <kanai@...4u.or.jp> 2002/06/19

金井です。

[#35412] Re: win32ole で excel が終了しない — "NAKAMURA, Hiroshi" <nakahiro@...> 2002/06/20

なひです。

[#35418] Re: win32ole で excel が終了しない — Takashi Kanai <kanai@...4u.or.jp> 2002/06/20

金井です。

[#35419] Re: win32ole で excel が終了しない — nobu.nakada@... 2002/06/21

なかだです。

[#35480] Re: 1.7 系を使っていますが、5月頃は式展開内のコメントが使えていましたが、今は使えなくなっていますね。 — "井上 浩一" <kyoui32@...>

=1B$B0f>e$G$9!#=1B(B

12 messages 2002/06/28
[#35490] Re: 1.7 系を使っていますが、5月頃は式展開内のコメントが使えていましたが、今は使えなくなっていますね。 — "Inoue" <rubyist@117.ne.jp> 2002/06/28

井上です。

[ruby-list:35411] Re: RubyUnit: Extended assert module and stacktrace

From: "Shirai,Kaoru" <shirai@...1jp.com>
Date: 2002-06-20 04:22:23 UTC
List: ruby-list #35411
 白井です。

> 上は、RubyUnitの実装通りの動作だと思います。
> 
> 例外が起こったとき、スタックトレースは TestFailure.initialize()メソッド
> で整形されます。この整形は、'#{$LOADPATH}/runit/' を含む行を削除しますか
> ら、通常は assert文を呼び出した位置の情報が残ります。

 なるほど、例外を発生した時ではなく捕捉した時にソースファイルによってスタ
ックトレースを削っているわけなんですね。

> 実は、私も、元のassert文を module_evalで定義し直して、
> その内部で AssertionFailErrorを発生させるようなのを書いたのですが、
> トレースが`(eval)'という表示が残ってしまい、対応を思案中です。

 同じアプローチですが、 caller を使った次のような方法ではいかがでしょうか
。

test.rb:
  require 'rubyunit'
  
  module MyAssert
    include RUNIT::Assert
    
    def self.assert_method(*name)
      module_eval <<-EOF
      alias __#{name} #{name}
      def #{name}(*args,&block)
        stacktrace = caller
        begin
          __#{name}(*args,&block)
        rescue RUNIT::AssertionFailedError
          $!.set_backtrace(stacktrace)
          raise
        end
      end
      EOF
    end
  
    def assert_my_fail(message)
      setup_assert
      raise_assertion_error message
    end
    assert_method :assert_my_fail
  end #/MyAssert
  
  class MyTest < RUNIT::TestCase
    include MyAssert
    def test_original_fail
      assert_fail "failed"
    end
  
    def test_my_fail
      assert_my_fail "failed"
    end
  end #/MyTest

実行結果:
  $ ruby test.rb 
  
  MyTest#test_my_fail F.
  MyTest#test_original_fail F.
  Time: 0.016503
  FAILURES!!!
  Test Results:
   Run: 2/2(2 asserts) Failures: 2 Errors: 0
  Failures: 2
  test.rb:35:in `test_my_fail'(MyTest): failed
(RUNIT::AssertionFailedError)
  	from test.rb:34
  test.rb:31:in `test_original_fail'(MyTest): failed
(RUNIT::AssertionFailedError)
  	from test.rb:34
  $ 

-- 
shirai@p1jp.com

Shirai,Kaoru
  PlusOne Co.,Ltd

In This Thread