Skip to content

Commit 7b90ff4

Browse files
committed
Update to release MRI 2.2 tests.
1 parent be55f79 commit 7b90ff4

File tree

239 files changed

+4314
-1506
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

239 files changed

+4314
-1506
lines changed

test/mri/-ext-/bug_reporter/test_bug_reporter.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require 'test/unit'
22
require 'tmpdir'
3-
require_relative "../../ruby/envutil"
43

54
class TestBugReporter < Test::Unit::TestCase
65
def test_bug_reporter_add

test/mri/-ext-/exception/test_data_error.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'test/unit'
2-
require_relative '../../ruby/envutil'
32

43
module Bug
54
class TestException < Test::Unit::TestCase

test/mri/-ext-/exception/test_ensured.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'test/unit'
2-
require_relative '../../ruby/envutil'
32

43
module Bug
54
class Bug7802 < RuntimeError
+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
require 'test/unit'
2+
3+
class TestIseqLoad < Test::Unit::TestCase
4+
require '-test-/iseq_load/iseq_load'
5+
ISeq = RubyVM::InstructionSequence
6+
7+
def test_bug8543
8+
assert_iseq_roundtrip <<-'end;'
9+
puts "tralivali"
10+
def funct(a, b)
11+
a**b
12+
end
13+
3.times { |i| puts "Hello, world#{funct(2,i)}!" }
14+
end;
15+
end
16+
17+
def test_case_when
18+
assert_iseq_roundtrip <<-'end;'
19+
def user_mask(target)
20+
target.each_char.inject(0) do |mask, chr|
21+
case chr
22+
when "u"
23+
mask | 04700
24+
when "g"
25+
mask | 02070
26+
when "o"
27+
mask | 01007
28+
when "a"
29+
mask | 07777
30+
else
31+
raise ArgumentError, "invalid `who' symbol in file mode: #{chr}"
32+
end
33+
end
34+
end
35+
end;
36+
end
37+
38+
def test_splatsplat
39+
assert_iseq_roundtrip('def splatsplat(**); end')
40+
end
41+
42+
def test_hidden
43+
assert_iseq_roundtrip('def x(a, (b, *c), d: false); end')
44+
end
45+
46+
def assert_iseq_roundtrip(src)
47+
a = ISeq.compile(src).to_a
48+
b = ISeq.iseq_load(a).to_a
49+
warn diff(a, b) if a != b
50+
assert_equal a, b
51+
assert_equal a, ISeq.iseq_load(b).to_a
52+
end
53+
54+
def test_next_in_block_in_block
55+
skip "failing due to stack_max mismatch"
56+
assert_iseq_roundtrip <<-'end;'
57+
3.times { 3.times { next } }
58+
end;
59+
end
60+
61+
def test_break_ensure
62+
skip "failing due to exception entry sp mismatch"
63+
assert_iseq_roundtrip <<-'end;'
64+
def m
65+
bad = true
66+
while true
67+
begin
68+
break
69+
ensure
70+
bad = false
71+
end
72+
end
73+
end
74+
end;
75+
end
76+
77+
# FIXME: still failing
78+
def test_require_integration
79+
skip "iseq loader require integration tests still failing"
80+
f = File.expand_path(__FILE__)
81+
# $(top_srcdir)/test/ruby/test_....rb
82+
3.times { f = File.dirname(f) }
83+
Dir[File.join(f, 'ruby', '*.rb')].each do |f|
84+
iseq = ISeq.compile_file(f)
85+
orig = iseq.to_a.freeze
86+
87+
loaded = ISeq.iseq_load(orig).to_a
88+
if loaded != orig
89+
warn f
90+
warn diff(orig, loaded)
91+
end
92+
#assert_equal orig, loaded
93+
end
94+
end
95+
end

test/mri/-ext-/marshal/test_usrmarshal.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
require 'test/unit'
2-
require_relative '../../ruby/envutil'
32
require '-test-/marshal/usr'
43

54
module Bug end

test/mri/-ext-/proc/test_bmethod.rb

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
require 'test/unit'
2+
require '-test-/proc'
3+
4+
class TestProc < Test::Unit::TestCase
5+
class TestBMethod < Test::Unit::TestCase
6+
end
7+
end
8+
9+
class TestProc::TestBMethod
10+
class Base
11+
def foo(*a)
12+
a
13+
end
14+
end
15+
16+
class Bound < Base
17+
define_method(:foo, Bug::Proc.make_call_super(42))
18+
define_method(:receiver, Bug::Proc.make_call_receiver(nil))
19+
end
20+
21+
def test_super_in_bmethod
22+
obj = Bound.new
23+
assert_equal([1, 42], obj.foo(1))
24+
end
25+
26+
def test_block_super
27+
obj = Bound.new
28+
result = nil
29+
obj.foo(2) {|*a| result = a}
30+
assert_equal([2, 42], result)
31+
end
32+
33+
def test_receiver_in_bmethod
34+
obj = Bound.new
35+
assert_same(obj, obj.receiver)
36+
end
37+
end

test/mri/-ext-/string/test_cstr.rb

+60-3
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,67 @@ def test_wchar_long
3333
len = str.size * n
3434
WCHARS.each do |enc|
3535
s = Bug::String.new(str.encode(enc))*n
36-
assert_nothing_raised(ArgumentError) {s.cstr_term}
36+
assert_nothing_raised(ArgumentError, enc.name) {s.cstr_term}
3737
s.set_len(s.bytesize / 2)
38-
assert_equal(len / 2, s.size)
39-
assert_equal(0, s.cstr_term)
38+
assert_equal(len / 2, s.size, enc.name)
39+
assert_equal(0, s.cstr_term, enc.name)
40+
end
41+
end
42+
43+
def test_wchar_lstrip!
44+
assert_wchars_term_char(" a") {|s| s.lstrip!}
45+
end
46+
47+
def test_wchar_rstrip!
48+
assert_wchars_term_char("a ") {|s| s.rstrip!}
49+
end
50+
51+
def test_wchar_chop!
52+
assert_wchars_term_char("a\n") {|s| s.chop!}
53+
end
54+
55+
def test_wchar_chomp!
56+
assert_wchars_term_char("a\n") {|s| s.chomp!}
57+
end
58+
59+
def test_wchar_aset
60+
assert_wchars_term_char("a"*30) {|s| s[29,1] = ""}
61+
end
62+
63+
def test_wchar_sub!
64+
assert_wchars_term_char("foobar") {|s| s.sub!(/#{"foo".encode(s.encoding)}/, "")}
65+
end
66+
67+
def test_wchar_delete!
68+
assert_wchars_term_char("foobar") {|s| s.delete!("ao".encode(s.encoding))}
69+
end
70+
71+
def test_wchar_squeeze!
72+
assert_wchars_term_char("foo!") {|s| s.squeeze!}
73+
end
74+
75+
def test_wchar_tr!
76+
assert_wchars_term_char("\u{3042}foobar") {|s|
77+
enc = s.encoding
78+
s.tr!("\u{3042}".encode(enc), "c".encode(enc))
79+
}
80+
end
81+
82+
def test_wchar_tr_s!
83+
assert_wchars_term_char("\u{3042}foobar") {|s|
84+
enc = s.encoding
85+
s.tr_s!("\u{3042}".encode(enc), "c".encode(enc))
86+
}
87+
end
88+
89+
def assert_wchars_term_char(str)
90+
result = {}
91+
WCHARS.map do |enc|
92+
s = Bug::String.new(str.encode(enc))
93+
yield s
94+
c = s.cstr_term_char
95+
result[enc] = c if c
4096
end
97+
assert_empty(result)
4198
end
4299
end

test/mri/-ext-/string/test_modify_expand.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require 'test/unit'
22
require "-test-/string/string"
3-
require_relative '../../ruby/envutil'
43

54
class Test_StringModifyExpand < Test::Unit::TestCase
65
def test_modify_expand_memory_leak

test/mri/-ext-/struct/test_member.rb

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require 'test/unit'
22
require "-test-/struct"
3-
require_relative '../../ruby/envutil'
43

54
class Bug::Struct::Test_Member < Test::Unit::TestCase
65
S = Bug::Struct.new(:a)

0 commit comments

Comments
 (0)