diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-22 08:08:31 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-12-22 08:08:31 +0000 |
commit | 161f4a511ad01c0e7f013b03aae6afd4c386b1df (patch) | |
tree | 8629683dbee51ed72310edf7463394a3d3e3bf60 /test/erb | |
parent | 84e462758de5e1992d5fc763766ff85628aec1c5 (diff) | |
download | ruby-161f4a511ad01c0e7f013b03aae6afd4c386b1df.tar.gz |
erb.rb: shadow by keys
* lib/erb.rb (ERB#new_toplevel): shadow already defined local
variables by block local variabes, not to overwrite them.
[ruby-core:84390] [Bug #14215]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/erb')
-rw-r--r-- | test/erb/test_erb.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/test/erb/test_erb.rb b/test/erb/test_erb.rb index 173e71cd7a..46f81c778b 100644 --- a/test/erb/test_erb.rb +++ b/test/erb/test_erb.rb @@ -611,6 +611,10 @@ EOS erb = @erb.new("<%= foo %>") erb.result_with_hash(foo: "1") assert_equal(false, TOPLEVEL_BINDING.local_variable_defined?(:foo)) + TOPLEVEL_BINDING.eval 'template2 = "two"' + erb = @erb.new("<%= template2 %>") + erb.result_with_hash(template2: "TWO") + assert_equal "two", TOPLEVEL_BINDING.local_variable_get("template2") end # This depends on the behavior that #local_variable_set raises TypeError by invalid key. |