2015-10-14 12:48:42 +02:00
|
|
|
require_relative "../helper"
|
2014-08-21 21:57:20 +02:00
|
|
|
|
|
|
|
class HelloTest < MiniTest::Test
|
2016-12-08 18:39:16 +01:00
|
|
|
include AST::Sexp
|
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
|
2016-12-08 18:39:16 +01:00
|
|
|
Typed.compile( @input )
|
2015-10-18 18:27:02 +02:00
|
|
|
machine.collect
|
2015-10-24 10:42:36 +02:00
|
|
|
machine.translate_arm
|
2015-11-12 19:02:44 +01:00
|
|
|
writer = Elf::ObjectWriter.new
|
2014-08-30 13:17:00 +02:00
|
|
|
writer.save "hello.o"
|
2014-08-21 21:57:20 +02:00
|
|
|
end
|
|
|
|
|
2015-10-24 10:42:36 +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()
|
2015-11-15 21:03:06 +01:00
|
|
|
return "Hello again\n".putstring()
|
2015-10-05 23:27:13 +02:00
|
|
|
end
|
|
|
|
end
|
2014-08-21 21:57:20 +02:00
|
|
|
HERE
|
2016-12-08 18:39:16 +01:00
|
|
|
@input = s(:statements,
|
|
|
|
s(:class, :Object,
|
|
|
|
s(:derives, nil),
|
|
|
|
s(:statements,
|
|
|
|
s(:function, :Integer,
|
|
|
|
s(:name, :main),
|
|
|
|
s(:parameters),
|
|
|
|
s(:statements,
|
|
|
|
s(:return,
|
|
|
|
s(:call,
|
|
|
|
s(:name, :putstring),
|
|
|
|
s(:arguments),
|
|
|
|
s(:receiver,
|
|
|
|
s(:string, "Hello again\\n")))))))))
|
2014-08-21 21:57:20 +02:00
|
|
|
check
|
|
|
|
end
|
2015-05-16 11:53:10 +02:00
|
|
|
end
|