require "helper" require "jit_buffer" class JITBufferTest < Minitest::Test def test_make_writeable jit = JITBuffer.new 4096 jit.writeable! jit.putc 46 end def test_putc jit = JITBuffer.new 4096 jit.writeable! assert_equal 0, jit.pos jit.putc 46 assert_equal 1, jit.pos jit.seek 0 assert_equal 46, jit.getc end def test_seek_too_far jit = JITBuffer.new 4096 assert_raises do jit.seek 4097 end end def test_write_too_far jit = JITBuffer.new 4096 jit.writeable! jit.seek 4095 jit.putc 46 assert_raises do jit.putc 46 end end def test_read_too_far jit = JITBuffer.new 4096 jit.seek 4095 jit.getc assert_raises do jit.getc end end def test_execute jit = JITBuffer.new 4096 insns = [ movz(0, 42), ret ].pack("L