2007-08-28 23:48:19 -04:00
|
|
|
#
|
|
|
|
# This test file concludes tests which point out known bugs.
|
|
|
|
# So all tests will cause failure.
|
|
|
|
#
|
2007-09-26 18:40:44 -04:00
|
|
|
|
2007-12-01 12:29:43 -05:00
|
|
|
assert_equal '0', %q{
|
|
|
|
GC.stress = true
|
|
|
|
pid = fork {}
|
|
|
|
Process.wait pid
|
|
|
|
$?.to_i
|
|
|
|
}, '[ruby-dev:32404]'
|
2007-12-01 20:43:29 -05:00
|
|
|
|
2007-12-04 01:31:42 -05:00
|
|
|
assert_normal_exit %q{
|
2007-12-06 05:09:44 -05:00
|
|
|
"abcdefghij\xf0".force_encoding("utf-8").reverse.inspect
|
2007-12-04 01:31:42 -05:00
|
|
|
}, '[ruby-dev:32448]'
|
2007-12-05 19:27:35 -05:00
|
|
|
|
2007-12-05 21:04:19 -05:00
|
|
|
assert_equal 'ok', %q{
|
2007-12-05 19:27:35 -05:00
|
|
|
class C
|
2007-12-05 21:04:19 -05:00
|
|
|
define_method(:foo) do |arg, &block|
|
2007-12-05 19:27:35 -05:00
|
|
|
if block then block.call else arg end
|
2007-12-05 21:04:19 -05:00
|
|
|
end
|
2007-12-05 19:27:35 -05:00
|
|
|
end
|
|
|
|
C.new.foo("ng") {"ok"}
|
|
|
|
}, '[ruby-talk:266422]'
|
2007-12-05 21:04:19 -05:00
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
STDERR.reopen(STDOUT)
|
|
|
|
class C
|
|
|
|
define_method(:foo) do |&block|
|
|
|
|
block.call if block
|
|
|
|
end
|
|
|
|
result = "ng"
|
|
|
|
new.foo() {result = "ok"}
|
|
|
|
result
|
|
|
|
end
|
|
|
|
}
|
2007-12-06 20:42:16 -05:00
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
begin
|
|
|
|
if ("\xa1\xa2\xa1\xa3").force_encoding("euc-jp").split(//) ==
|
|
|
|
["\xa1\xa2".force_encoding("euc-jp"), "\xa1\xa3".force_encoding("euc-jp")]
|
|
|
|
:ok
|
|
|
|
else
|
|
|
|
:ng
|
|
|
|
end
|
|
|
|
rescue
|
|
|
|
:ng
|
|
|
|
end
|
|
|
|
}, '[ruby-dev:32452]'
|
2007-12-08 12:41:47 -05:00
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
begin
|
|
|
|
"\xa1\xa1".force_encoding("euc-jp") + "\xa1".force_encoding("ascii-8bit")
|
|
|
|
:ng
|
|
|
|
rescue ArgumentError
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
}
|
2007-12-08 13:45:20 -05:00
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
s1 = "\x81\x41".force_encoding("sjis")
|
|
|
|
s2 = "\x81\x61".force_encoding("sjis")
|
2007-12-08 13:47:42 -05:00
|
|
|
s1.casecmp(s2) == 0 ? :ng : :ok
|
2007-12-08 13:45:20 -05:00
|
|
|
}
|
|
|
|
|
2007-12-08 19:31:02 -05:00
|
|
|
assert_equal 'EUC-JP', %q{ ("\xc2\xa1 %s".force_encoding("EUC-JP") % "foo").encoding.name }
|
|
|
|
assert_equal 'true', %q{ "\xa1\xa2\xa3\xa4".force_encoding("euc-jp")["\xa2\xa3".force_encoding("euc-jp")] == nil }
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
begin
|
|
|
|
s["\xb0\xa3"] = "foo"
|
|
|
|
:ng
|
2007-12-13 04:05:49 -05:00
|
|
|
rescue ArgumentError
|
2007-12-08 19:31:02 -05:00
|
|
|
:ok
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'EUC-JP', %q{ "\xa3\xb0".force_encoding("EUC-JP").center(10).encoding.name }
|
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
begin
|
|
|
|
s.chomp("\xa3\xb4".force_encoding("shift_jis"))
|
|
|
|
:ng
|
|
|
|
rescue ArgumentError
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
begin
|
|
|
|
s.count("\xa3\xb0".force_encoding("ascii-8bit"))
|
|
|
|
:ng
|
|
|
|
rescue ArgumentError
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
begin
|
|
|
|
s.delete("\xa3\xb2".force_encoding("ascii-8bit"))
|
|
|
|
:ng
|
|
|
|
rescue ArgumentError
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
begin
|
|
|
|
s.each_line("\xa3\xb1".force_encoding("ascii-8bit")) {|l| }
|
|
|
|
:ng
|
|
|
|
rescue ArgumentError
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'true', %q{
|
|
|
|
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
s.gsub(/\xa3\xb1/e, "z") == "\xa3\xb0z\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
}
|
2007-12-08 19:56:10 -05:00
|
|
|
|
|
|
|
assert_equal 'false', %q{
|
|
|
|
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
s.include?("\xb0\xa3".force_encoding("euc-jp"))
|
|
|
|
}
|
|
|
|
|
2007-12-13 04:20:13 -05:00
|
|
|
assert_equal 'ok', %q{
|
2007-12-08 19:56:10 -05:00
|
|
|
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
2007-12-13 04:20:13 -05:00
|
|
|
s.index("\xb3\xa3".force_encoding("euc-jp")) or :ok
|
2007-12-08 19:56:10 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
s.insert(-1, "a")
|
|
|
|
:ok
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_finish 1, %q{ "\xa3\xfe".force_encoding("euc-jp").next }
|
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
begin
|
|
|
|
s.rindex("\xb1\xa3".force_encoding("ascii-8bit"))
|
|
|
|
:ng
|
|
|
|
rescue ArgumentError
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'true', %q{
|
|
|
|
s = "\xa3\xb0\xa3\xb1\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
s.split("\xa3\xb1".force_encoding("euc-jp")) == [
|
2007-12-08 20:25:32 -05:00
|
|
|
"\xa3\xb0".force_encoding("euc-jp"),
|
2007-12-08 19:56:10 -05:00
|
|
|
"\xa3\xb2\xa3\xb3\xa3\xb4".force_encoding("euc-jp")
|
|
|
|
]
|
2007-12-08 22:12:25 -05:00
|
|
|
}, '[ruby-dev:32452]'
|
2007-12-10 04:49:37 -05:00
|
|
|
|
|
|
|
assert_normal_exit %q{ // =~ :a }
|
2007-12-12 21:37:27 -05:00
|
|
|
|
|
|
|
assert_equal '[nil, []]', %q{
|
|
|
|
def m() yield nil,[] end
|
|
|
|
l = lambda {|*v| v}
|
|
|
|
GC.stress=true
|
|
|
|
r = m(&l)
|
|
|
|
GC.stress=false
|
|
|
|
r.inspect
|
|
|
|
}, '[ruby-dev:32567]'
|
|
|
|
|
2007-12-14 16:27:16 -05:00
|
|
|
assert_normal_exit %q{
|
2007-12-14 21:39:34 -05:00
|
|
|
e = [1,2,3].each
|
2007-12-14 16:27:16 -05:00
|
|
|
10000.times {
|
2007-12-14 21:39:34 -05:00
|
|
|
e = [e].each
|
2007-12-14 16:27:16 -05:00
|
|
|
}
|
|
|
|
Thread.new { GC.start }.join
|
|
|
|
}, '[ruby-dev:32604]'
|
2007-12-15 11:29:26 -05:00
|
|
|
|
|
|
|
assert_equal 'nil', %q{
|
|
|
|
doit = false
|
|
|
|
exc = nil
|
|
|
|
t = Thread.new {
|
|
|
|
begin
|
|
|
|
doit = true
|
|
|
|
sleep 10
|
|
|
|
ensure
|
|
|
|
exc = $!
|
|
|
|
end
|
|
|
|
}
|
|
|
|
Thread.pass until doit
|
|
|
|
t.kill
|
|
|
|
t.join
|
|
|
|
exc.inspect
|
|
|
|
}, '[ruby-dev:32608]'
|
2007-12-15 21:17:42 -05:00
|
|
|
|
|
|
|
assert_equal 'true', %q{
|
|
|
|
"abc".sub(/b/, "\xa1\xa1".force_encoding("euc-jp")) ==
|
|
|
|
"a\xa1\xa1c".force_encoding("euc-jp")
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
begin
|
|
|
|
"%s%s" % ["\xc2\xa1".force_encoding("sjis"), "\xc2\xa1".force_encoding("euc-jp")]
|
|
|
|
rescue ArgumentError
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal '0', %q{
|
|
|
|
"\xa1\xa2".force_encoding("euc-jp").count("z")
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal '1', %q{
|
|
|
|
"\xa1\xa2".force_encoding("euc-jp").delete("z").length
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'false', %q{
|
|
|
|
"\xa1\xa2\xa3\xa4".force_encoding("euc-jp").include?("\xa3".force_encoding("euc-jp"))
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'nil', %q{
|
|
|
|
"\xa1\xa2\xa3\xa4".force_encoding("euc-jp").index("\xa3".force_encoding("euc-jp"))
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'nil', %q{
|
|
|
|
"\xa1\xa2\xa3\xa4".force_encoding("euc-jp").rindex("\xa3".force_encoding("euc-jp"))
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'false', %q{
|
|
|
|
s1 = "\xa1\xa1".force_encoding("euc-jp")
|
|
|
|
s2 = s1.dup
|
|
|
|
(94*94+94).times { s2.next! }
|
|
|
|
s1 == s2
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
"\xa1\xa2a\xa3\xa4".force_encoding("euc-jp").scan(/a/)
|
|
|
|
:ok
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
"\xa1\xa2a\xa3\xa4".force_encoding("euc-jp").split(/a/)
|
|
|
|
:ok
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_equal 'ok', %q{
|
|
|
|
s1 = "\xa1\xa2".force_encoding("euc-jp")
|
|
|
|
s2 = "\xa1\xa2".force_encoding("sjis")
|
|
|
|
begin
|
|
|
|
s1.upto(s2) {|x| break }
|
|
|
|
:ng
|
|
|
|
rescue ArgumentError
|
|
|
|
:ok
|
|
|
|
end
|
|
|
|
}
|