From: Akinori MUSHA Date: 2002-04-16T00:42:19+09:00 Subject: [ruby-dev:16916] Re: Ruby Shim At Mon, 15 Apr 2002 22:38:11 +0900, nobu.nakada wrote: > おそらくこのへんは無理じゃないかと思います。 > > > Object > > singleton_method_removed > > singleton_method_undefined > > Module > > method_removed > > method_undefined > > Symbol > > Symbol.all_symbols > > Thread > > Thread.list > > keys > > ThreadGroup > > list  そうですねえ。次回、 ToDo を更新するときにマーク入れときます。  最初は、実装できないものは raise NotImplementedError を出すだけの ものを定義したらいいかなと思ったんですが、それだと既存のプログラムで 行っている respond_to? チェックが破綻してしまうのでやめました。 > 簡単なところでこの二つを入れときました。 > > > Proc > > yield > > Symbol > > intern  どうもありがとうございます。  Proc#yield のテストは、 Proc#call との違いをイラストレートした ものにした方がよいと思います。(* とか [] を使って) # でも、いざ考えてみると Proc#yield() の挙動をちゃんと理解して # いるか自信なくなってしまう。 ;)  それと、これは一般的に言えますが、ブロックを渡してその中で assert する場合、ブロックが呼ばれること自体をチェックする必要があります。 イテレータのテストでは、返り値から自明というものを除き、呼ばれた 回数や順序も見た方がいいでしょう。  たとえば、 tc_struct.rb の Struct::*#each_pair のテストはこんな 感じにしています。 def test_instance_each_pair struct_class = Struct.new("ABC", :a, :b, :c) struct = struct_class.new(1, 2, 3) i = 0 struct.each_pair { |*x| case i when 0 assert_equal([:a, 1], x) when 1 assert_equal([:b, 2], x) when 2 assert_equal([:c, 3], x) else flunk("unexpected pair: #{x.inspect}") end i += 1 } if i == 0 flunk("block wasn't yielded once.") end end パラノイアックになりすぎるとバランスを欠くので要注意ですが。 > それと、ruby16/doc/features-ruby18.txtってRDで書くってことでいいですよ > ね。  はい。ただ、これ↓をやったら RDTools でうまくフォーマットでき なかったので今のようになっているのでした。リストは空行をあけちゃ いけないのかも。 > - 1. If a default value is given, returns it. > + (1) If a default value is given, returns it. > > - 2. If a block is given, calls it passing the index and returns the > - block's return value. > + (2) If a block is given, calls it passing the index and returns the > + block's return value. > > - 3. Otherwise, raises IndexError. > + (3) Otherwise, raises IndexError.  でも、 RD としてこれで正しいのなら入れてしまってください。 -- / /__ __ Akinori.org / MUSHA.org / ) ) ) ) / FreeBSD.org / Ruby-lang.org Akinori MUSHA aka / (_ / ( (__( @ iDaemons.org / and.or.jp "Somewhere out of a memory.. of lighted streets on quiet nights.."