e$B1sF#$G$9!#e(B
2008/07/24 0:44 Yui NARUSE [email protected]:
e$B0J>e$N$h$&$JM}M3$N$?$a!"=$@5$Oe(B transcode e$B$N;EMM$N3NDjBT$A$H$J$k$?$a!"e(B
e$B!VEvLL$N4V=$@5$5$l$J$$4{CN$N%P%0!W$H$$$&$N$,8=:_$N%9%F!<%?%9$K$J$j$^$9!#e(Be$B$J$N$G!"$=$N$h$&$J<q;]$NJL%U%!%$%k$K%F%9%H$r0\F0$7$?$$e(B
e$B;?@.$G$9!#D>$kM=Dj$N$J$$%F%9%H$re(B make test-all
e$B$KJ|CV$7$F$*$/$N$O!"e(B
e$B%F%9%H7k2L$N;kG’@-$,0-$/$J$j!"%j%0%l%C%7%g%s%F%9%H$,$7$K$/$/$J$ke(B
e$B!V%F%9%H$OB?>/<:GT$7$F$F$b$$$$!W$H$$$&%@%a$JG’<1$,9-$^$C$F$7$^$&e(B
- e$B;v>p$rCN$i$J$$?M$K$O%S%k%I$N<:GT$J$I$H6hJL$,$D$+$J$$e(B
e$B$Ne(B 3 e$BE@$+$i!"$h$/$J$$$H;W$$$^$9!#e(B
e$B$=$N$h$&$J>uBV$@$H;W$o$l$k%F%9%H$O!"0J2<$Ne(B 3 e$BE@$G$9!#e(B
-
test_getc_stateful_conversion(TestIO_M17N)
-
test_terminator_stateful_conversion(TestIO_M17N)
- stateful encoding e$B$OEvJ,%5%]!<%H$5$l$J$$e(B
-
test_iso_2022_jp(TestTranscode)
- EUC e$B$NJd=u4A;z$OEvJ,%5%]!<%H$5$l$J$$e(B
e$B$3$l$i$Oe(B test/ruby/PENDINGS.rb e$B$K0$7!"e(Bmake test-all
(e$B$de(B make check)
e$B$G$O<B9T$7$J$$$h$&$K$7$?$$$H;W$$$^$9!#e(B
(e$B$?$@$7!"2?$G$b$+$s$G$be(B PENDINGS.rb
e$B$KF~$l$?$i%@%a$G$9!#=EMW!#e(B)
e$B$I$s$J$b$s$G$7$g$&$+!#e(B
e$B0J2<$N%Q%C%A$G$O!"e(Bmake test-all-including-pendings e$B$Ge(B
PENDINGS.rb e$B$be(B
e$B4^$a$?%F%9%H$rAv$i$;$k$h$&$K$7$F$_$^$7$?!#e(B
Index: common.mk
— common.mk (revision 18196)
+++ common.mk (working copy)
@@ -368,6 +368,9 @@
test-all:
$(RUNRUBY) “$(srcdir)/test/runner.rb” --basedir=“$(TESTSDIR)”
–runner=$(TESTUI) $(TESTS)
+test-all-including-pendings:
- $(RUNRUBY) “$(srcdir)/test/runner.rb” --basedir=“$(TESTSDIR)”
–runner=$(TESTUI) --pattern=PENDINGS.rb $(TESTS)
extconf: $(PREP)
$(MINIRUBY) -run -e mkdir – -p “$(EXTCONFDIR)”
$(RUNRUBY) -C “$(EXTCONFDIR)” $(EXTCONF) $(EXTCONFARGS)
Index: test/ruby/test_transcode.rb
— test/ruby/test_transcode.rb (revision 18196)
+++ test/ruby/test_transcode.rb (working copy)
@@ -259,13 +259,11 @@
assert_raise(RuntimeError) { “\x1b$(A”.encode(“utf-8”,
“iso-2022-jp”) }
assert_equal(“\uff71\uff72\uff73\uff74\uff75”,
“\x1b(I12345\x1b(B”.force_encoding(“iso-2022-jp”).encode(“utf-8”)) #
JIS X 0201 e$B%!%#%%%'%)e(B
-
assert_equal(“\u9299”, “\x1b$(Dd!\x1b(B”.encode(“utf-8”,
“iso-2022-jp”)) # JIS X 0212 e$B6he(B68 e$BE@e(B01 ?
assert_raise(RuntimeError) { “\x1b$C”.encode(“utf-8”,
“iso-2022-jp”) }
assert_raise(RuntimeError) { “\x1e”.encode(“utf-8”, “iso-2022-jp”)
}
assert_raise(RuntimeError) { “\x80”.encode(“utf-8”, “iso-2022-jp”)
}assert_equal(“\x1b(I12345\x1b(B”.force_encoding(“iso-2022-jp”),
“\uff71\uff72\uff73\uff74\uff75”.encode(“iso-2022-jp”)) -
assert_equal(“\x1b$(Dd!\x1b(B”.force_encoding(“iso-2022-jp”),
“\u9299”.encode(“iso-2022-jp”))
end
end
Index: test/ruby/test_io_m17n.rb
===================================================================
— test/ruby/test_io_m17n.rb (revision 18196)
+++ test/ruby/test_io_m17n.rb (working copy)
@@ -157,18 +157,6 @@
}
end -
def test_terminator_stateful_conversion
-
with_tmpdir {
-
src = "before \e$B\x23\x30\x23\x31\e(B
after".force_encoding(“iso-2022-jp”)
-
generate_file('tmp', src)
-
s = open("tmp", "r:iso-2022-jp:euc-jp") {|f|
-
f.gets("0".force_encoding("euc-jp"))
-
}
-
assert_equal(Encoding.find("euc-jp"), s.encoding)
-
assert_str_equal(src.encode("euc-jp"), s)
-
}
-
end
-
def test_nonascii_terminator
with_tmpdir {
generate_file(‘tmp’, “before \xA2\xA2 after”)
@@ -214,17 +202,6 @@
}
end -
def test_getc_stateful_conversion
-
with_tmpdir {
-
src = "\e$B\x23\x30\x23\x31\e(B".force_encoding("iso-2022-jp")
-
generate_file('tmp', src)
-
open("tmp", "r:iso-2022-jp:euc-jp") {|f|
-
assert_equal("\xa3\xb0".force_encoding("euc-jp"), f.getc)
-
assert_equal("\xa3\xb1".force_encoding("euc-jp"), f.getc)
-
}
-
}
-
end
-
def test_open_ascii
with_tmpdir {
src = “abc\n”
Index: test/ruby/PENDINGS.rb
===================================================================
— test/ruby/PENDINGS.rb (revision 0)
+++ test/ruby/PENDINGS.rb (revision 0)
@@ -0,0 +1,62 @@
+# -- encoding: ASCII-8BIT -- # make sure this runs in binary mode
+# some of the comments are in UTF-8
+require ‘test/unit’
+require ‘tmpdir’
+require ‘timeout’
+
+class TestIO_M17N_PENDING < Test::Unit::TestCase
- def with_tmpdir
- Dir.mktmpdir {|dir|
-
Dir.chdir(dir) {
-
yield dir
-
}
- }
- end
- def generate_file(path, content)
- open(path, “wb”) {|f| f.write content }
- end
- def encdump(str)
- “#{str.dump}.force_encoding(#{str.encoding.name.dump})”
- end
- def assert_str_equal(expected, actual, message=nil)
- full_message = build_message(message, <<EOT)
+#{encdump expected} expected but not equal to
+#{encdump actual}.
+EOT - assert_block(full_message) { expected == actual }
- end
- def test_getc_stateful_conversion
- with_tmpdir {
-
src = "\e$B\x23\x30\x23\x31\e(B".force_encoding("iso-2022-jp")
-
generate_file('tmp', src)
-
open("tmp", "r:iso-2022-jp:euc-jp") {|f|
-
assert_equal("\xa3\xb0".force_encoding("euc-jp"), f.getc)
-
assert_equal("\xa3\xb1".force_encoding("euc-jp"), f.getc)
-
}
- }
- end
- def test_terminator_stateful_conversion
- with_tmpdir {
-
src = "before \e$B\x23\x30\x23\x31\e(B
after".force_encoding(“iso-2022-jp”)
-
generate_file('tmp', src)
-
s = open("tmp", "r:iso-2022-jp:euc-jp") {|f|
-
f.gets("0".force_encoding("euc-jp"))
-
}
-
assert_equal(Encoding.find("euc-jp"), s.encoding)
-
assert_str_equal(src.encode("euc-jp"), s)
- }
- end
+end
+class TestTranscode_PENDING < Test::Unit::TestCase
- def test_euc_jis_x_0212
- assert_equal(“\u9299”, “\x1b$(Dd!\x1b(B”.encode(“utf-8”,
“iso-2022-jp”)) # JIS X 0212 e$B6he(B68 e$BE@e(B01 ? - assert_equal(“\x1b$(Dd!\x1b(B”.force_encoding(“iso-2022-jp”),
“\u9299”.encode(“iso-2022-jp”)) - end
+end