2015-10-14 12:48:42 +02:00
|
|
|
require_relative "../helper"
|
2014-08-21 21:57:20 +02:00
|
|
|
|
|
|
|
class HelloTest < MiniTest::Test
|
2015-05-16 11:53:10 +02:00
|
|
|
|
2014-08-21 21:57:20 +02:00
|
|
|
def check
|
2015-10-22 17:16:29 +02:00
|
|
|
machine = Register.machine.boot
|
2015-08-06 17:55:08 +02:00
|
|
|
Parfait::Space.object_space.get_class_by_name(:Integer).remove_instance_method :plus
|
|
|
|
#TODO remove this hack: write proper aliases
|
2015-10-09 16:51:14 +02:00
|
|
|
statements = machine.parse_and_compile @string_input
|
2015-06-22 21:48:42 +02:00
|
|
|
output_at = "Register::CallImplementation"
|
2015-06-20 23:21:42 +02:00
|
|
|
#{}"Register::CallImplementation"
|
2015-10-18 18:27:02 +02:00
|
|
|
machine.collect
|
2015-06-20 23:21:42 +02:00
|
|
|
machine.run_before output_at
|
2015-06-30 09:22:54 +02:00
|
|
|
#puts Sof.write(machine.space)
|
2015-06-20 23:21:42 +02:00
|
|
|
machine.run_after output_at
|
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"
|
2014-08-21 21:57:20 +02:00
|
|
|
end
|
|
|
|
|
2015-07-21 18:41:30 +02:00
|
|
|
def test_string_put
|
2014-08-22 09:21:12 +02:00
|
|
|
@string_input = <<HERE
|
2015-10-05 23:27:13 +02:00
|
|
|
class Object
|
|
|
|
int main()
|
|
|
|
"Hello again\n".putstring()
|
|
|
|
end
|
|
|
|
end
|
2014-08-21 21:57:20 +02:00
|
|
|
HERE
|
|
|
|
check
|
|
|
|
end
|
2015-05-16 11:53:10 +02:00
|
|
|
end
|