mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
This commit is contained in:
parent
22e145141b
commit
6b4ecb32fb
4 changed files with 62 additions and 62 deletions
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue