rubyx/test/compiler/test_hello.rb
Torsten Ruger f4a4ccb98e several larger changes came together, bit of cleaning too
- all code must be in functions (which must be in classes).
— changes a fair few tests
— also changes api, as method is not recursive, not passed around
- all state in instance vars in compiler (no accessors)
- class is another such variable, surely more coming
all green again
2015-10-06 00:27:13 +03:00

46 lines
916 B
Ruby

require_relative "compiler_helper"
class HelloTest < MiniTest::Test
def check
machine = Virtual.machine.boot
Parfait::Space.object_space.get_class_by_name(:Integer).remove_instance_method :plus
#TODO remove this hack: write proper aliases
expressions = machine.parse_and_compile @string_input
output_at = "Register::CallImplementation"
#{}"Register::CallImplementation"
machine.run_before output_at
#puts Sof.write(machine.space)
machine.run_after output_at
writer = Elf::ObjectWriter.new(machine)
writer.save "hello.o"
end
def qtest_simplest_function
@string_input = <<HERE
def foo(x)
5
end
HERE
check
end
def ttest_puts_string
@string_input = <<HERE
putstring("Hello")
HERE
check
end
def test_string_put
@string_input = <<HERE
class Object
int main()
"Hello again\n".putstring()
end
end
HERE
check
end
end