2014-08-21 22:57:20 +03:00
|
|
|
require_relative "virtual_helper"
|
|
|
|
|
|
|
|
class HelloTest < MiniTest::Test
|
|
|
|
include VirtualHelper
|
2015-05-16 12:53:10 +03:00
|
|
|
|
2014-08-21 22:57:20 +03:00
|
|
|
def check
|
|
|
|
machine = Virtual::Machine.boot
|
|
|
|
expressions = machine.compile_main @string_input
|
2015-06-22 22:48:42 +03:00
|
|
|
output_at = "Register::CallImplementation"
|
2015-06-21 00:21:42 +03:00
|
|
|
#{}"Register::CallImplementation"
|
|
|
|
machine.run_before output_at
|
2015-06-19 12:29:41 +03:00
|
|
|
puts Sof.write(machine.space)
|
2015-06-21 00:21:42 +03:00
|
|
|
machine.run_after output_at
|
2015-05-16 12:53:10 +03:00
|
|
|
writer = Elf::ObjectWriter.new(machine)
|
2014-08-30 14:17:00 +03:00
|
|
|
writer.save "hello.o"
|
2014-08-21 22:57:20 +03:00
|
|
|
end
|
|
|
|
|
2014-08-22 09:21:59 +03:00
|
|
|
def qtest_simplest_function
|
2014-08-21 22:57:20 +03:00
|
|
|
@string_input = <<HERE
|
2015-05-16 12:53:10 +03:00
|
|
|
def foo(x)
|
2014-08-21 22:57:20 +03:00
|
|
|
5
|
|
|
|
end
|
|
|
|
HERE
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-05-24 13:31:33 +03:00
|
|
|
def test_puts_string
|
2014-08-21 22:57:20 +03:00
|
|
|
@string_input = <<HERE
|
2015-05-30 14:49:10 +03:00
|
|
|
putstring("Hello")
|
2014-08-22 10:21:12 +03:00
|
|
|
HERE
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-05-24 13:31:33 +03:00
|
|
|
def ttest_string_put
|
2014-08-22 10:21:12 +03:00
|
|
|
@string_input = <<HERE
|
|
|
|
def foo()
|
|
|
|
"Hello".puts()
|
|
|
|
end
|
2014-08-21 22:57:20 +03:00
|
|
|
HERE
|
|
|
|
check
|
|
|
|
end
|
2015-05-16 12:53:10 +03:00
|
|
|
end
|