diff options
Diffstat (limited to 'test/strscan')
-rw-r--r-- | test/strscan/test_stringscanner.rb | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/test/strscan/test_stringscanner.rb b/test/strscan/test_stringscanner.rb index b9f7f7ddae..72961efd68 100644 --- a/test/strscan/test_stringscanner.rb +++ b/test/strscan/test_stringscanner.rb @@ -240,11 +240,15 @@ class TestStringScanner < Test::Unit::TestCase assert_equal true, s.getch.tainted? assert_nil s.getch - $KCODE = 'EUC' - s = StringScanner.new("\244\242") - assert_equal "\244\242", s.getch - assert_nil s.getch - $KCODE = 'NONE' + kc_backup = $KCODE + begin + $KCODE = 'EUC' + s = StringScanner.new("\244\242") + assert_equal "\244\242", s.getch + assert_nil s.getch + ensure + $KCODE = kc_backup + end s = StringScanner.new('test') s.scan(/te/) @@ -270,12 +274,16 @@ class TestStringScanner < Test::Unit::TestCase assert_equal true, s.get_byte.tainted? assert_nil s.get_byte - $KCODE = 'EUC' - s = StringScanner.new("\244\242") - assert_equal "\244", s.get_byte - assert_equal "\242", s.get_byte - assert_nil s.get_byte - $KCODE = 'NONE' + kc_backup = $KCODE + begin + $KCODE = 'EUC' + s = StringScanner.new("\244\242") + assert_equal "\244", s.get_byte + assert_equal "\242", s.get_byte + assert_nil s.get_byte + ensure + $KCODE = kc_backup + end s = StringScanner.new('test') s.scan(/te/) @@ -368,11 +376,15 @@ class TestStringScanner < Test::Unit::TestCase assert_nil s[0] - $KCODE = 'EUC' - s = StringScanner.new("\244\242") - s.getch - assert_equal "\244\242", s[0] - $KCODE = 'NONE' + kc_backup = $KCODE + begin + $KCODE = 'EUC' + s = StringScanner.new("\244\242") + s.getch + assert_equal "\244\242", s[0] + ensure + $KCODE = kc_backup + end str = 'test' |