2014-08-21 21:57:20 +02:00
|
|
|
require_relative "virtual_helper"
|
|
|
|
|
|
|
|
class HelloTest < MiniTest::Test
|
|
|
|
include VirtualHelper
|
2015-05-16 11:53:10 +02:00
|
|
|
|
2014-08-21 21:57:20 +02:00
|
|
|
def check
|
|
|
|
machine = Virtual::Machine.boot
|
|
|
|
expressions = machine.compile_main @string_input
|
2014-08-30 13:17:00 +02:00
|
|
|
|
2015-05-16 11:53:10 +02:00
|
|
|
writer = Elf::ObjectWriter.new(machine)
|
2014-08-30 13:17:00 +02:00
|
|
|
writer.save "hello.o"
|
|
|
|
# puts Sof::Writer.write(expressions)
|
2015-05-16 11:53:10 +02:00
|
|
|
puts Sof::Writer.write(machine.space)
|
2014-08-21 21:57:20 +02:00
|
|
|
end
|
|
|
|
|
2014-08-22 08:21:59 +02:00
|
|
|
def qtest_simplest_function
|
2014-08-21 21:57:20 +02:00
|
|
|
@string_input = <<HERE
|
2015-05-16 11:53:10 +02:00
|
|
|
def foo(x)
|
2014-08-21 21:57:20 +02:00
|
|
|
5
|
|
|
|
end
|
|
|
|
HERE
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-05-24 12:31:33 +02:00
|
|
|
def test_puts_string
|
2014-08-21 21:57:20 +02:00
|
|
|
@string_input = <<HERE
|
|
|
|
def foo()
|
|
|
|
puts("Hello")
|
|
|
|
end
|
|
|
|
foo()
|
2014-08-22 09:21:12 +02:00
|
|
|
HERE
|
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-05-24 12:31:33 +02:00
|
|
|
def ttest_string_put
|
2014-08-22 09:21:12 +02:00
|
|
|
@string_input = <<HERE
|
|
|
|
def foo()
|
|
|
|
"Hello".puts()
|
|
|
|
end
|
2014-08-21 21:57:20 +02:00
|
|
|
HERE
|
|
|
|
check
|
|
|
|
end
|
2015-05-16 11:53:10 +02:00
|
|
|
end
|