From 994dfc0ae6a3c42bb9311f736ca30275779e348a Mon Sep 17 00:00:00 2001 From: nahi Date: Wed, 18 Feb 2004 13:08:08 +0000 Subject: * test/*: should not depend on $KCODE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ test/ruby/test_alias.rb | 2 -- test/ruby/test_array.rb | 2 -- test/ruby/test_assignment.rb | 2 -- test/ruby/test_bignum.rb | 2 -- test/ruby/test_call.rb | 2 -- test/ruby/test_case.rb | 2 -- test/ruby/test_clone.rb | 2 -- test/ruby/test_condition.rb | 2 -- test/ruby/test_const.rb | 2 -- test/ruby/test_defined.rb | 2 -- test/ruby/test_env.rb | 2 -- test/ruby/test_eval.rb | 2 -- test/ruby/test_exception.rb | 2 -- test/ruby/test_file.rb | 2 -- test/ruby/test_float.rb | 2 -- test/ruby/test_gc.rb | 2 -- test/ruby/test_hash.rb | 2 -- test/ruby/test_ifunless.rb | 2 -- test/ruby/test_iterator.rb | 2 -- test/ruby/test_marshal.rb | 2 -- test/ruby/test_math.rb | 2 -- test/ruby/test_pack.rb | 2 -- test/ruby/test_path.rb | 2 -- test/ruby/test_pipe.rb | 2 -- test/ruby/test_proc.rb | 2 -- test/ruby/test_range.rb | 2 -- test/ruby/test_signal.rb | 2 -- test/ruby/test_sprintf.rb | 2 -- test/ruby/test_stringchar.rb | 2 -- test/ruby/test_struct.rb | 2 -- test/ruby/test_system.rb | 2 -- test/ruby/test_trace.rb | 2 -- test/ruby/test_variable.rb | 2 -- test/ruby/test_whileuntil.rb | 2 -- test/strscan/test_stringscanner.rb | 44 ++++++++++++++++++++++++-------------- 36 files changed, 32 insertions(+), 84 deletions(-) diff --git a/ChangeLog b/ChangeLog index de76d3e801..4106ad7cab 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Wed Feb 18 22:03:11 2004 NAKAMURA, Hiroshi + + * test/*: should not depend on $KCODE. + Wed Feb 18 18:07:09 2004 NAKAMURA Usaku * test/ruby/test_sprintf.rb: added tests. diff --git a/test/ruby/test_alias.rb b/test/ruby/test_alias.rb index 50fe452734..83f897fb00 100644 --- a/test/ruby/test_alias.rb +++ b/test/ruby/test_alias.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestAlias < Test::Unit::TestCase class Alias0 def foo; "foo" end diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index ed2ee5961c..62582864e3 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestArray < Test::Unit::TestCase def test_array assert_equal([1, 2, 3, 4], [1, 2] + [3, 4]) diff --git a/test/ruby/test_assignment.rb b/test/ruby/test_assignment.rb index 51d1c780f8..63f37a9d73 100644 --- a/test/ruby/test_assignment.rb +++ b/test/ruby/test_assignment.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestAssignment < Test::Unit::TestCase def test_assign a=[]; a[0] ||= "bar"; diff --git a/test/ruby/test_bignum.rb b/test/ruby/test_bignum.rb index d05bc5406b..c238337db5 100644 --- a/test/ruby/test_bignum.rb +++ b/test/ruby/test_bignum.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestBignum < Test::Unit::TestCase def fact(n) return 1 if n == 0 diff --git a/test/ruby/test_call.rb b/test/ruby/test_call.rb index 7694d5196c..da7ee93c73 100644 --- a/test/ruby/test_call.rb +++ b/test/ruby/test_call.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestCall < Test::Unit::TestCase def aaa(a, b=100, *rest) res = [a, b] diff --git a/test/ruby/test_case.rb b/test/ruby/test_case.rb index 2407356965..41a22038a0 100644 --- a/test/ruby/test_case.rb +++ b/test/ruby/test_case.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestCase < Test::Unit::TestCase def test_case case 5 diff --git a/test/ruby/test_clone.rb b/test/ruby/test_clone.rb index 612636c046..43c0cffa1d 100644 --- a/test/ruby/test_clone.rb +++ b/test/ruby/test_clone.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestClone < Test::Unit::TestCase module M001; end module M002; end diff --git a/test/ruby/test_condition.rb b/test/ruby/test_condition.rb index 2ef2e0db30..ba2e0688f3 100644 --- a/test/ruby/test_condition.rb +++ b/test/ruby/test_condition.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestCondition < Test::Unit::TestCase # [should] first test to see if we can run the tests. diff --git a/test/ruby/test_const.rb b/test/ruby/test_const.rb index dfacceb629..8d01379dbd 100644 --- a/test/ruby/test_const.rb +++ b/test/ruby/test_const.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestConst < Test::Unit::TestCase TEST1 = 1 TEST2 = 2 diff --git a/test/ruby/test_defined.rb b/test/ruby/test_defined.rb index d386b4bddc..8a7fcf45a9 100644 --- a/test/ruby/test_defined.rb +++ b/test/ruby/test_defined.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestDefined < Test::Unit::TestCase class Foo def foo diff --git a/test/ruby/test_env.rb b/test/ruby/test_env.rb index 7d660f05a5..edc7dcaf61 100644 --- a/test/ruby/test_env.rb +++ b/test/ruby/test_env.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestEnv < Test::Unit::TestCase IGNORE_CASE = /djgpp|bccwin|mswin|mingw/ =~ RUBY_PLATFORM diff --git a/test/ruby/test_eval.rb b/test/ruby/test_eval.rb index c64741df33..28fd01c70c 100644 --- a/test/ruby/test_eval.rb +++ b/test/ruby/test_eval.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestEval < Test::Unit::TestCase # eval with binding def test_ev diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index b6abf38c89..4c27c52f3c 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestException < Test::Unit::TestCase def test_exception begin diff --git a/test/ruby/test_file.rb b/test/ruby/test_file.rb index 375ff66721..c4095428e1 100644 --- a/test/ruby/test_file.rb +++ b/test/ruby/test_file.rb @@ -2,8 +2,6 @@ require 'test/unit' require 'tempfile' require 'ut_eof' -$KCODE = 'none' - class TestFile < Test::Unit::TestCase # I don't know Ruby's spec about "unlink-before-close" exactly. diff --git a/test/ruby/test_float.rb b/test/ruby/test_float.rb index efb69954a1..c18700a575 100644 --- a/test/ruby/test_float.rb +++ b/test/ruby/test_float.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestFloat < Test::Unit::TestCase def test_float assert_equal(2, 2.6.floor) diff --git a/test/ruby/test_gc.rb b/test/ruby/test_gc.rb index 5b824309ac..d0b4e3df77 100644 --- a/test/ruby/test_gc.rb +++ b/test/ruby/test_gc.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestGc < Test::Unit::TestCase class S def initialize(a) diff --git a/test/ruby/test_hash.rb b/test/ruby/test_hash.rb index c20f67f573..5bec012bf8 100644 --- a/test/ruby/test_hash.rb +++ b/test/ruby/test_hash.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestHash < Test::Unit::TestCase def test_hash x = {1=>2, 2=>4, 3=>6} diff --git a/test/ruby/test_ifunless.rb b/test/ruby/test_ifunless.rb index 7910f81b52..bffc794512 100644 --- a/test/ruby/test_ifunless.rb +++ b/test/ruby/test_ifunless.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestIfunless < Test::Unit::TestCase def test_if_unless $x = 'test'; diff --git a/test/ruby/test_iterator.rb b/test/ruby/test_iterator.rb index c8631653f3..f3c2201e0a 100644 --- a/test/ruby/test_iterator.rb +++ b/test/ruby/test_iterator.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class Array def iter_test1 collect{|e| [e, yield(e)]}.sort{|a,b|a[1]<=>b[1]} diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb index 2008e3f36a..9c9fd9470b 100644 --- a/test/ruby/test_marshal.rb +++ b/test/ruby/test_marshal.rb @@ -8,8 +8,6 @@ ensure $:.replace(orgpath) end -$KCODE = 'none' - class TestMarshal < Test::Unit::TestCase include MarshalTestLib diff --git a/test/ruby/test_math.rb b/test/ruby/test_math.rb index c5ddbbdb05..e1e49dba01 100644 --- a/test/ruby/test_math.rb +++ b/test/ruby/test_math.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestMath < Test::Unit::TestCase def test_math assert_equal(2, Math.sqrt(4)) diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb index 9939f9f07b..863dfbe82f 100644 --- a/test/ruby/test_pack.rb +++ b/test/ruby/test_pack.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestPack < Test::Unit::TestCase def test_pack $format = "c2x5CCxsdils_l_a6"; diff --git a/test/ruby/test_path.rb b/test/ruby/test_path.rb index 55452beb70..95a5d5b1d1 100644 --- a/test/ruby/test_path.rb +++ b/test/ruby/test_path.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestPath < Test::Unit::TestCase def test_path assert_equal("a", File.basename("a")) diff --git a/test/ruby/test_pipe.rb b/test/ruby/test_pipe.rb index a6b7c14edd..c2f355185b 100644 --- a/test/ruby/test_pipe.rb +++ b/test/ruby/test_pipe.rb @@ -2,8 +2,6 @@ require 'test/unit' require 'ut_eof' require 'envutil' -$KCODE = 'none' - class TestPipe < Test::Unit::TestCase include TestEOF def open_file(content) diff --git a/test/ruby/test_proc.rb b/test/ruby/test_proc.rb index 23b84ed20f..f0b78ffb23 100644 --- a/test/ruby/test_proc.rb +++ b/test/ruby/test_proc.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestProc < Test::Unit::TestCase def test_proc p1 = proc{|i| i} diff --git a/test/ruby/test_range.rb b/test/ruby/test_range.rb index 0b79f5f098..66ed555887 100644 --- a/test/ruby/test_range.rb +++ b/test/ruby/test_range.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestRange < Test::Unit::TestCase def test_range_string # XXX: Is this really the test of Range? diff --git a/test/ruby/test_signal.rb b/test/ruby/test_signal.rb index 77c97be98c..d212f9fcc3 100644 --- a/test/ruby/test_signal.rb +++ b/test/ruby/test_signal.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestSignal < Test::Unit::TestCase def test_signal defined?(Process.kill) or return diff --git a/test/ruby/test_sprintf.rb b/test/ruby/test_sprintf.rb index e6cfb5b016..8716e7021d 100644 --- a/test/ruby/test_sprintf.rb +++ b/test/ruby/test_sprintf.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestSprintf < Test::Unit::TestCase def test_binary assert_equal("0", sprintf("%b", 0)) diff --git a/test/ruby/test_stringchar.rb b/test/ruby/test_stringchar.rb index e9b643ad3f..943b656510 100644 --- a/test/ruby/test_stringchar.rb +++ b/test/ruby/test_stringchar.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestStringchar < Test::Unit::TestCase def test_string assert_equal("abcd", "abcd") diff --git a/test/ruby/test_struct.rb b/test/ruby/test_struct.rb index 4a57537d37..fa1bb1549a 100644 --- a/test/ruby/test_struct.rb +++ b/test/ruby/test_struct.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestStruct < Test::Unit::TestCase def test_struct struct_test = Struct.new("Test", :foo, :bar) diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index 322b0c9ceb..410dd83e2a 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -1,8 +1,6 @@ require 'test/unit' require 'envutil' -$KCODE = 'none' - class TestSystem < Test::Unit::TestCase def valid_syntax?(code, fname) eval("BEGIN {return true}\n#{code}", nil, fname, 0) diff --git a/test/ruby/test_trace.rb b/test/ruby/test_trace.rb index 69c0c24fe7..6adfe0bf64 100644 --- a/test/ruby/test_trace.rb +++ b/test/ruby/test_trace.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestTrace < Test::Unit::TestCase def test_trace $x = 1234 diff --git a/test/ruby/test_variable.rb b/test/ruby/test_variable.rb index ab0e405115..8726160826 100644 --- a/test/ruby/test_variable.rb +++ b/test/ruby/test_variable.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestVariable < Test::Unit::TestCase class Gods @@rule = "Uranus" diff --git a/test/ruby/test_whileuntil.rb b/test/ruby/test_whileuntil.rb index 841a15135d..6faed31160 100644 --- a/test/ruby/test_whileuntil.rb +++ b/test/ruby/test_whileuntil.rb @@ -1,7 +1,5 @@ require 'test/unit' -$KCODE = 'none' - class TestWhileuntil < Test::Unit::TestCase def test_while tmp = open("while_tmp", "w") 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' -- cgit v1.2.3