Skip to content

Commit 5201338

Browse files
committed
merge revision(s) 39721:
* test/ruby/envutil.rb (EnvUtil.with_default_external): add for changing Encoding.default_external without warnings. * test/ruby/envutil.rb (EnvUtil.with_default_internal): ditto. * test/ruby/test_io_m17n.rb: use above with_default_external. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@41364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent c03f37d commit 5201338

File tree

4 files changed

+52
-21
lines changed

4 files changed

+52
-21
lines changed

ChangeLog

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
Tue Jun 18 02:21:54 2013 NARUSE, Yui <[email protected]>
2+
3+
* test/ruby/envutil.rb (EnvUtil.with_default_external): add for
4+
changing Encoding.default_external without warnings.
5+
6+
* test/ruby/envutil.rb (EnvUtil.with_default_internal): ditto.
7+
8+
* test/ruby/test_io_m17n.rb: use above with_default_external.
9+
110
Tue Jun 18 00:43:27 2013 Zachary Scott <[email protected]>
211

312
* vm_backtrace.c: Update rdoc for Backtrace#label with @_ko1

test/ruby/envutil.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,30 @@ def under_gc_stress
127127
GC.stress = stress
128128
end
129129
module_function :under_gc_stress
130+
131+
def with_default_external(enc)
132+
verbose, $VERBOSE = $VERBOSE, nil
133+
origenc, Encoding.default_external = Encoding.default_external, enc
134+
$VERBOSE = verbose
135+
yield
136+
ensure
137+
verbose, $VERBOSE = $VERBOSE, nil
138+
Encoding.default_external = origenc
139+
$VERBOSE = verbose
140+
end
141+
module_function :with_default_external
142+
143+
def with_default_internal(enc)
144+
verbose, $VERBOSE = $VERBOSE, nil
145+
origenc, Encoding.default_internal = Encoding.default_internal, enc
146+
$VERBOSE = verbose
147+
yield
148+
ensure
149+
verbose, $VERBOSE = $VERBOSE, nil
150+
Encoding.default_internal = origenc
151+
$VERBOSE = verbose
152+
end
153+
module_function :with_default_internal
130154
end
131155

132156
module Test

test/ruby/test_io_m17n.rb

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -479,32 +479,30 @@ def test_getc_newlineconv
479479
with_tmpdir {
480480
src = "\u3042"
481481
generate_file('tmp', src)
482-
defext = Encoding.default_external
483-
Encoding.default_external = Encoding::UTF_8
484-
open("tmp", "rt") {|f|
485-
s = f.getc
486-
assert_equal(true, s.valid_encoding?)
487-
assert_equal("\u3042", s)
488-
}
489-
Encoding.default_external = defext
482+
EnvUtil.with_default_external(Encoding::UTF_8) do
483+
open("tmp", "rt") {|f|
484+
s = f.getc
485+
assert_equal(true, s.valid_encoding?)
486+
assert_equal("\u3042", s)
487+
}
488+
end
490489
}
491490
end
492491

493492
def test_getc_newlineconv_invalid
494493
with_tmpdir {
495494
src = "\xE3\x81"
496495
generate_file('tmp', src)
497-
defext = Encoding.default_external
498-
Encoding.default_external = Encoding::UTF_8
499-
open("tmp", "rt") {|f|
500-
s = f.getc
501-
assert_equal(false, s.valid_encoding?)
502-
assert_equal("\xE3".force_encoding("UTF-8"), s)
503-
s = f.getc
504-
assert_equal(false, s.valid_encoding?)
505-
assert_equal("\x81".force_encoding("UTF-8"), s)
506-
}
507-
Encoding.default_external = defext
496+
EnvUtil.with_default_external(Encoding::UTF_8) do
497+
open("tmp", "rt") {|f|
498+
s = f.getc
499+
assert_equal(false, s.valid_encoding?)
500+
assert_equal("\xE3".force_encoding("UTF-8"), s)
501+
s = f.getc
502+
assert_equal(false, s.valid_encoding?)
503+
assert_equal("\x81".force_encoding("UTF-8"), s)
504+
}
505+
end
508506
}
509507
end
510508

@@ -1678,7 +1676,7 @@ def test_write_mode
16781676
u16 = "\x85\x35\0\r\x00\xa2\0\r\0\n\0\n".force_encoding("utf-16be")
16791677
i = "\e$B\x42\x22\e(B\r\e$B\x21\x71\e(B\r\n\n".force_encoding("iso-2022-jp")
16801678
n = system_newline
1681-
un = n.encode("utf-16be").force_encoding("ascii-8bit")
1679+
n.encode("utf-16be").force_encoding("ascii-8bit")
16821680

16831681
assert_write("a\rb\r#{n}c#{n}", "wt", a)
16841682
assert_write("\xc2\xa2", "wt", e)

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#define RUBY_VERSION "2.0.0"
22
#define RUBY_RELEASE_DATE "2013-06-18"
3-
#define RUBY_PATCHLEVEL 224
3+
#define RUBY_PATCHLEVEL 225
44

55
#define RUBY_RELEASE_YEAR 2013
66
#define RUBY_RELEASE_MONTH 6

0 commit comments

Comments
 (0)