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

ruby-changes:24784

From: tenderlove <ko1@a...>
Date: Tue, 28 Aug 2012 02:57:45 +0900 (JST)
Subject: [ruby-changes:24784] tenderlove:r36835 (trunk): adding test coverage for invalid attribute names

tenderlove	2012-08-28 02:57:32 +0900 (Tue, 28 Aug 2012)

  New Revision: 36835

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

  Log:
    adding test coverage for invalid attribute names
    
    Fixes #171 on github

  Modified files:
    trunk/test/ruby/test_module.rb

Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 36834)
+++ test/ruby/test_module.rb	(revision 36835)
@@ -1452,4 +1452,17 @@
     assert_nothing_raised(NoMethodError, Bug6891) {Class.new(x)}
     assert_equal(['public', 'protected'], list)
   end
+
+  def test_invalid_attr
+    %w[
+      foo?
+      @foo
+      @@foo
+      $foo
+    ].each do |name|
+      assert_raises(NameError) do
+        Module.new { attr_accessor name.to_sym }
+      end
+    end
+  end
 end

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

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