2012-01-14 07:56:46 -05:00
|
|
|
require 'test/unit'
|
|
|
|
require_relative 'envutil'
|
|
|
|
|
|
|
|
class TestISeq < Test::Unit::TestCase
|
|
|
|
ISeq = RubyVM::InstructionSequence
|
|
|
|
|
|
|
|
def test_no_linenum
|
|
|
|
bug5894 = '[ruby-dev:45130]'
|
|
|
|
assert_normal_exit('p RubyVM::InstructionSequence.compile("1", "mac", "", 0).to_a', bug5894)
|
|
|
|
end
|
2012-06-09 04:21:52 -04:00
|
|
|
|
|
|
|
def test_unsupport_type
|
|
|
|
ary = RubyVM::InstructionSequence.compile("p").to_a
|
|
|
|
ary[9] = :foobar
|
|
|
|
e = assert_raise(TypeError) {RubyVM::InstructionSequence.load(ary)}
|
|
|
|
assert_match(/:foobar/, e.message)
|
|
|
|
end if defined?(RubyVM::InstructionSequence.load)
|
2012-06-09 10:36:56 -04:00
|
|
|
|
|
|
|
def test_disasm_encoding
|
2012-08-21 18:30:43 -04:00
|
|
|
src = "\u{3042} = 1; \u{3042}"
|
2012-06-10 02:49:16 -04:00
|
|
|
enc, Encoding.default_internal = Encoding.default_internal, src.encoding
|
|
|
|
assert_equal(src.encoding, RubyVM::InstructionSequence.compile(src).disasm.encoding)
|
|
|
|
src.encode!(Encoding::Shift_JIS)
|
|
|
|
assert_equal(true, RubyVM::InstructionSequence.compile(src).disasm.ascii_only?)
|
|
|
|
ensure
|
|
|
|
Encoding.default_internal = enc
|
2012-06-09 10:36:56 -04:00
|
|
|
end
|
2012-01-14 07:56:46 -05:00
|
|
|
end
|