Skip to content

Commit

Permalink
Update to release MRI 2.2 tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
headius committed Dec 27, 2014
1 parent be55f79 commit 7b90ff4
Show file tree
Hide file tree
Showing 239 changed files with 4,314 additions and 1,506 deletions.
1 change: 0 additions & 1 deletion test/mri/-ext-/bug_reporter/test_bug_reporter.rb
@@ -1,6 +1,5 @@
require 'test/unit'
require 'tmpdir'
require_relative "../../ruby/envutil"

class TestBugReporter < Test::Unit::TestCase
def test_bug_reporter_add
Expand Down
1 change: 0 additions & 1 deletion test/mri/-ext-/exception/test_data_error.rb
@@ -1,5 +1,4 @@
require 'test/unit'
require_relative '../../ruby/envutil'

module Bug
class TestException < Test::Unit::TestCase
Expand Down
1 change: 0 additions & 1 deletion test/mri/-ext-/exception/test_ensured.rb
@@ -1,5 +1,4 @@
require 'test/unit'
require_relative '../../ruby/envutil'

module Bug
class Bug7802 < RuntimeError
Expand Down
95 changes: 95 additions & 0 deletions test/mri/-ext-/iseq_load/test_iseq_load.rb
@@ -0,0 +1,95 @@
require 'test/unit'

class TestIseqLoad < Test::Unit::TestCase
require '-test-/iseq_load/iseq_load'
ISeq = RubyVM::InstructionSequence

def test_bug8543
assert_iseq_roundtrip <<-'end;'
puts "tralivali"
def funct(a, b)
a**b
end
3.times { |i| puts "Hello, world#{funct(2,i)}!" }
end;
end

def test_case_when
assert_iseq_roundtrip <<-'end;'
def user_mask(target)
target.each_char.inject(0) do |mask, chr|
case chr
when "u"
mask | 04700
when "g"
mask | 02070
when "o"
mask | 01007
when "a"
mask | 07777
else
raise ArgumentError, "invalid `who' symbol in file mode: #{chr}"
end
end
end
end;
end

def test_splatsplat
assert_iseq_roundtrip('def splatsplat(**); end')
end

def test_hidden
assert_iseq_roundtrip('def x(a, (b, *c), d: false); end')
end

def assert_iseq_roundtrip(src)
a = ISeq.compile(src).to_a
b = ISeq.iseq_load(a).to_a
warn diff(a, b) if a != b
assert_equal a, b
assert_equal a, ISeq.iseq_load(b).to_a
end

def test_next_in_block_in_block
skip "failing due to stack_max mismatch"
assert_iseq_roundtrip <<-'end;'
3.times { 3.times { next } }
end;
end

def test_break_ensure
skip "failing due to exception entry sp mismatch"
assert_iseq_roundtrip <<-'end;'
def m
bad = true
while true
begin
break
ensure
bad = false
end
end
end
end;
end

# FIXME: still failing
def test_require_integration
skip "iseq loader require integration tests still failing"
f = File.expand_path(__FILE__)
# $(top_srcdir)/test/ruby/test_....rb
3.times { f = File.dirname(f) }
Dir[File.join(f, 'ruby', '*.rb')].each do |f|
iseq = ISeq.compile_file(f)
orig = iseq.to_a.freeze

loaded = ISeq.iseq_load(orig).to_a
if loaded != orig
warn f
warn diff(orig, loaded)
end
#assert_equal orig, loaded
end
end
end
1 change: 0 additions & 1 deletion test/mri/-ext-/marshal/test_usrmarshal.rb
@@ -1,5 +1,4 @@
require 'test/unit'
require_relative '../../ruby/envutil'
require '-test-/marshal/usr'

module Bug end
Expand Down
37 changes: 37 additions & 0 deletions test/mri/-ext-/proc/test_bmethod.rb
@@ -0,0 +1,37 @@
require 'test/unit'
require '-test-/proc'

class TestProc < Test::Unit::TestCase
class TestBMethod < Test::Unit::TestCase
end
end

class TestProc::TestBMethod
class Base
def foo(*a)
a
end
end

class Bound < Base
define_method(:foo, Bug::Proc.make_call_super(42))
define_method(:receiver, Bug::Proc.make_call_receiver(nil))
end

def test_super_in_bmethod
obj = Bound.new
assert_equal([1, 42], obj.foo(1))
end

def test_block_super
obj = Bound.new
result = nil
obj.foo(2) {|*a| result = a}
assert_equal([2, 42], result)
end

def test_receiver_in_bmethod
obj = Bound.new
assert_same(obj, obj.receiver)
end
end
63 changes: 60 additions & 3 deletions test/mri/-ext-/string/test_cstr.rb
Expand Up @@ -33,10 +33,67 @@ def test_wchar_long
len = str.size * n
WCHARS.each do |enc|
s = Bug::String.new(str.encode(enc))*n
assert_nothing_raised(ArgumentError) {s.cstr_term}
assert_nothing_raised(ArgumentError, enc.name) {s.cstr_term}
s.set_len(s.bytesize / 2)
assert_equal(len / 2, s.size)
assert_equal(0, s.cstr_term)
assert_equal(len / 2, s.size, enc.name)
assert_equal(0, s.cstr_term, enc.name)
end
end

def test_wchar_lstrip!
assert_wchars_term_char(" a") {|s| s.lstrip!}
end

def test_wchar_rstrip!
assert_wchars_term_char("a ") {|s| s.rstrip!}
end

def test_wchar_chop!
assert_wchars_term_char("a\n") {|s| s.chop!}
end

def test_wchar_chomp!
assert_wchars_term_char("a\n") {|s| s.chomp!}
end

def test_wchar_aset
assert_wchars_term_char("a"*30) {|s| s[29,1] = ""}
end

def test_wchar_sub!
assert_wchars_term_char("foobar") {|s| s.sub!(/#{"foo".encode(s.encoding)}/, "")}
end

def test_wchar_delete!
assert_wchars_term_char("foobar") {|s| s.delete!("ao".encode(s.encoding))}
end

def test_wchar_squeeze!
assert_wchars_term_char("foo!") {|s| s.squeeze!}
end

def test_wchar_tr!
assert_wchars_term_char("\u{3042}foobar") {|s|
enc = s.encoding
s.tr!("\u{3042}".encode(enc), "c".encode(enc))
}
end

def test_wchar_tr_s!
assert_wchars_term_char("\u{3042}foobar") {|s|
enc = s.encoding
s.tr_s!("\u{3042}".encode(enc), "c".encode(enc))
}
end

def assert_wchars_term_char(str)
result = {}
WCHARS.map do |enc|
s = Bug::String.new(str.encode(enc))
yield s
c = s.cstr_term_char
result[enc] = c if c
end
assert_empty(result)
end
end
1 change: 0 additions & 1 deletion test/mri/-ext-/string/test_modify_expand.rb
@@ -1,6 +1,5 @@
require 'test/unit'
require "-test-/string/string"
require_relative '../../ruby/envutil'

class Test_StringModifyExpand < Test::Unit::TestCase
def test_modify_expand_memory_leak
Expand Down
1 change: 0 additions & 1 deletion test/mri/-ext-/struct/test_member.rb
@@ -1,6 +1,5 @@
require 'test/unit'
require "-test-/struct"
require_relative '../../ruby/envutil'

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

0 comments on commit 7b90ff4

Please sign in to comment.