diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-08-08 13:46:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-08-08 13:46:09 +0000 |
commit | 6b4ecb32fbaf41a97be27bf20781b5fdc38d7485 (patch) | |
tree | a902588877f9cf6fbbbd7fff0406aaa07953e66b /test/ruby/test_stringchar.rb | |
parent | 22e145141bcd98ab68ff57e9cd991796227b534f (diff) |
use local variables
* test/ruby/test_eval.rb: use local variables instead global variables
if possible.
* test/ruby/test_ifunless.rb: ditto.
* test/ruby/test_iterator.rb: ditto.
* test/ruby/test_stringchar.rb: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_stringchar.rb')
-rw-r--r-- | test/ruby/test_stringchar.rb | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/test/ruby/test_stringchar.rb b/test/ruby/test_stringchar.rb index 44c8634c02..4cae57f85f 100644 --- a/test/ruby/test_stringchar.rb +++ b/test/ruby/test_stringchar.rb @@ -30,12 +30,12 @@ class TestStringchar < Test::Unit::TestCase assert(/(\s+\d+){2}/ =~ " 1 2"); assert_equal(" 1 2", $&) assert(/(?:\s+\d+){2}/ =~ " 1 2"); assert_equal(" 1 2", $&) - $x = <<END; + x = <<END; ABCD ABCD END - $x.gsub!(/((.|\n)*?)B((.|\n)*?)D/m ,'\1\3') - assert_equal("AC\nAC\n", $x) + x.gsub!(/((.|\n)*?)B((.|\n)*?)D/m ,'\1\3') + assert_equal("AC\nAC\n", x) assert_match(/foo(?=(bar)|(baz))/, "foobar") assert_match(/foo(?=(bar)|(baz))/, "foobaz") @@ -56,12 +56,12 @@ END assert_equal('-', foo * 1) assert_equal('', foo * 0) - $x = "a.gif" - assert_equal("gif", $x.sub(/.*\.([^\.]+)$/, '\1')) - assert_equal("b.gif", $x.sub(/.*\.([^\.]+)$/, 'b.\1')) - assert_equal("", $x.sub(/.*\.([^\.]+)$/, '\2')) - assert_equal("ab", $x.sub(/.*\.([^\.]+)$/, 'a\2b')) - assert_equal("<a.gif>", $x.sub(/.*\.([^\.]+)$/, '<\&>')) + x = "a.gif" + assert_equal("gif", x.sub(/.*\.([^\.]+)$/, '\1')) + assert_equal("b.gif", x.sub(/.*\.([^\.]+)$/, 'b.\1')) + assert_equal("", x.sub(/.*\.([^\.]+)$/, '\2')) + assert_equal("ab", x.sub(/.*\.([^\.]+)$/, 'a\2b')) + assert_equal("<a.gif>", x.sub(/.*\.([^\.]+)$/, '<\&>')) end def test_char @@ -78,16 +78,16 @@ END assert_equal("abc", "abcc".squeeze!("a-z")) assert_equal("ad", "abcd".delete!("bc")) - $x = "abcdef" - $y = [ ?a, ?b, ?c, ?d, ?e, ?f ] - $bad = false - $x.each_byte {|i| - if i.chr != $y.shift - $bad = true + x = "abcdef" + y = [ ?a, ?b, ?c, ?d, ?e, ?f ] + bad = false + x.each_byte {|i| + if i.chr != y.shift + bad = true break end } - assert(!$bad) + assert(!bad) s = "a string" s[0..s.size]="another string" |