From 849c4eaaf3a03e98ee1f7aefbf58ec152585e4df Mon Sep 17 00:00:00 2001 From: nobu Date: Thu, 18 Oct 2012 01:29:54 +0000 Subject: [PATCH] test_syntax.rb: test_unassignable * test/ruby/test_syntax.rb (TestSyntax#test_unassignable): assert keywords are unassignable. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37250 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_syntax.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/ruby/test_syntax.rb b/test/ruby/test_syntax.rb index 35c70254bf..8b89f95dc4 100644 --- a/test/ruby/test_syntax.rb +++ b/test/ruby/test_syntax.rb @@ -186,6 +186,12 @@ class TestSyntax < Test::Unit::TestCase assert_valid_syntax("def self; :foo; end", __FILE__, bug6403) end + def test_unassignable + %w[self nil true false __FILE__ __LINE__ __ENCODING__].each do |kwd| + assert_raise(SyntaxError) {eval("#{kwd} = nil")} + end + end + private def not_label(x) @result = x; @not_label ||= nil end