summaryrefslogtreecommitdiff
path: root/test/ruby/test_iterator.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-08 13:46:09 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-08 13:46:09 +0000
commit6b4ecb32fbaf41a97be27bf20781b5fdc38d7485 (patch)
treea902588877f9cf6fbbbd7fff0406aaa07953e66b /test/ruby/test_iterator.rb
parent22e145141bcd98ab68ff57e9cd991796227b534f (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_iterator.rb')
-rw-r--r--test/ruby/test_iterator.rb34
1 files changed, 17 insertions, 17 deletions
diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb
index 362becc0e0..34652db2bb 100644
--- a/test/ruby/test_iterator.rb
+++ b/test/ruby/test_iterator.rb
@@ -25,14 +25,14 @@ class TestIterator < Test::Unit::TestCase
end
def test_array
- $x = [1, 2, 3, 4]
- $y = []
+ x = [1, 2, 3, 4]
+ y = []
# iterator over array
- for i in $x
- $y.push i
+ for i in x
+ y.push i
end
- assert_equal($x, $y)
+ assert_equal(x, y)
end
def tt
@@ -79,36 +79,36 @@ class TestIterator < Test::Unit::TestCase
assert(done)
done = false
- $bad = false
+ bad = false
loop {
break if done
done = true
next
- $bad = true # should not reach here
+ bad = true # should not reach here
}
- assert(!$bad)
+ assert(!bad)
done = false
- $bad = false
+ bad = false
loop {
break if done
done = true
redo
- $bad = true # should not reach here
+ bad = true # should not reach here
}
- assert(!$bad)
+ assert(!bad)
- $x = []
+ x = []
for i in 1 .. 7
- $x.push i
+ x.push i
end
- assert_equal(7, $x.size)
- assert_equal([1, 2, 3, 4, 5, 6, 7], $x)
+ assert_equal(7, x.size)
+ assert_equal([1, 2, 3, 4, 5, 6, 7], x)
end
def test_append_method_to_built_in_class
- $x = [[1,2],[3,4],[5,6]]
- assert_equal($x.iter_test1{|x|x}, $x.iter_test2{|x|x})
+ x = [[1,2],[3,4],[5,6]]
+ assert_equal(x.iter_test1{|x|x}, x.iter_test2{|x|x})
end
class IterTest