[前][次][番号順一覧][スレッド一覧]

ruby-changes:40045

From: eregon <ko1@a...>
Date: Thu, 15 Oct 2015 01:58:31 +0900 (JST)
Subject: [ruby-changes:40045] eregon:r52126 (trunk): * test/ostruct/test_ostruct.rb: Add tests for OpenStruct#respond_to.

eregon	2015-10-15 01:57:46 +0900 (Thu, 15 Oct 2015)

  New Revision: 52126

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52126

  Log:
    * test/ostruct/test_ostruct.rb: Add tests for OpenStruct#respond_to.
      Patch by @jeremy in [GH-1041]: https://github.com/ruby/ruby/pull/1041

  Modified files:
    trunk/ChangeLog
    trunk/test/ostruct/test_ostruct.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 52125)
+++ ChangeLog	(revision 52126)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Oct 15 01:53:38 2015  Benoit Daloze  <eregontp@g...>
+
+	* test/ostruct/test_ostruct.rb: Add tests for OpenStruct#respond_to.
+	  Patch by @jeremy in [GH-1041]: https://github.com/ruby/ruby/pull/1041
+
 Thu Oct 15 01:49:25 2015  Benoit Daloze  <eregontp@g...>
 
 	* lib/ostruct.rb: Finish defining OpenStruct attributes lazily.
Index: test/ostruct/test_ostruct.rb
===================================================================
--- test/ostruct/test_ostruct.rb	(revision 52125)
+++ test/ostruct/test_ostruct.rb	(revision 52126)
@@ -9,6 +9,19 @@ class TC_OpenStruct < Test::Unit::TestCa https://github.com/ruby/ruby/blob/trunk/test/ostruct/test_ostruct.rb#L9
     assert_equal h, OpenStruct.new(Struct.new(*h.keys).new(*h.values)).to_h
   end
 
+  def test_respond_to
+    o = OpenStruct.new
+    o.a = 1
+    assert_respond_to(o, :a)
+    assert_respond_to(o, :a=)
+  end
+
+  def test_respond_to_with_lazy_getter
+    o = OpenStruct.new a: 1
+    assert_respond_to(o, :a)
+    assert_respond_to(o, :a=)
+  end
+
   def test_equality
     o1 = OpenStruct.new
     o2 = OpenStruct.new

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]