2015-10-14 13:48:42 +03:00
|
|
|
require_relative "../helper"
|
2014-08-21 22:57:20 +03:00
|
|
|
|
|
|
|
class HelloTest < MiniTest::Test
|
2016-12-08 19:39:16 +02:00
|
|
|
include AST::Sexp
|
2015-05-16 12:53:10 +03:00
|
|
|
|
2014-08-21 22:57:20 +03:00
|
|
|
def check
|
2015-10-22 18:16:29 +03:00
|
|
|
machine = Register.machine.boot
|
2016-12-08 19:39:16 +02:00
|
|
|
Typed.compile( @input )
|
2015-10-18 19:27:02 +03:00
|
|
|
machine.collect
|
2015-10-24 11:42:36 +03:00
|
|
|
machine.translate_arm
|
2015-11-12 20:02:44 +02:00
|
|
|
writer = Elf::ObjectWriter.new
|
2014-08-30 14:17:00 +03:00
|
|
|
writer.save "hello.o"
|
2014-08-21 22:57:20 +03:00
|
|
|
end
|
|
|
|
|
2015-10-24 11:42:36 +03:00
|
|
|
def test_string_put
|
2014-08-22 10:21:12 +03:00
|
|
|
@string_input = <<HERE
|
2015-10-06 00:27:13 +03:00
|
|
|
class Object
|
|
|
|
int main()
|
2015-11-15 22:03:06 +02:00
|
|
|
return "Hello again\n".putstring()
|
2015-10-06 00:27:13 +03:00
|
|
|
end
|
|
|
|
end
|
2014-08-21 22:57:20 +03:00
|
|
|
HERE
|
2016-12-08 19:39:16 +02: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 22:57:20 +03:00
|
|
|
check
|
|
|
|
end
|
2015-05-16 12:53:10 +03:00
|
|
|
end
|