much less test code (s-exps) needed because compiler defaults to main
but some compilation outside needed, hence clean_compile
This commit is contained in:
parent
5c34835ae3
commit
1a224f904b
@ -13,10 +13,8 @@ class HelloTest < MiniTest::Test
|
||||
end
|
||||
|
||||
def test_string_put
|
||||
@input = s(:statements, s(:class, :Space, 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")))))))))
|
||||
@input = s(:statements, s(:return, s(:call, s(:name, :putstring), s(:arguments),
|
||||
s(:receiver, s(:string, "Hello again\\n")))))
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -11,7 +11,7 @@ class Space
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@input = s(:statements, s(:class, :Space, s(:derives, nil), s(:statements, s(:function, :Integer, s(:name, :main), s(:parameters), s(:statements, s(:return, s(:operator_value, :+, s(:int, 5), s(:int, 7))))))))
|
||||
@input = s(:statements, s(:return, s(:operator_value, :+, s(:int, 5), s(:int, 7))))
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -4,7 +4,7 @@ class AddChange < MiniTest::Test
|
||||
include Ticker
|
||||
|
||||
def setup
|
||||
@input = s(:statements, s(:class, :Space, s(:derives, nil), s(:statements, s(:function, :Integer, s(:name, :main), s(:parameters), s(:statements, s(:return, s(:operator_value, :+, s(:int, 5), s(:int, 7))))))))
|
||||
@input = s(:statements, s(:return, s(:operator_value, :+, s(:int, 5), s(:int, 7))))
|
||||
@state_events = {}
|
||||
@instruction_events = []
|
||||
super
|
||||
|
@ -11,12 +11,10 @@ class Space
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@input = s(:statements, s(:class, :Space, s(:derives, nil), s(:statements,
|
||||
s(:function, :Integer, s(:name, :main), s(:parameters),
|
||||
s(:statements, s(:call,
|
||||
s(:name, :set_internal_byte),
|
||||
s(:arguments, s(:int, 1), s(:int, 104)),
|
||||
s(:receiver, s(:string, "Hello"))))))))
|
||||
@input = s(:statements, s(:call,
|
||||
s(:name, :set_internal_byte),
|
||||
s(:arguments, s(:int, 1), s(:int, 104)),
|
||||
s(:receiver, s(:string, "Hello"))))
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -2,6 +2,7 @@ require_relative "helper"
|
||||
|
||||
class IfTest < MiniTest::Test
|
||||
include Ticker
|
||||
include Compiling
|
||||
|
||||
def setup
|
||||
@string_input = <<HERE
|
||||
@ -19,10 +20,17 @@ class Space
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@input = s(:statements, s(:class, :Space, s(:derives, nil), s(:statements, s(:function, :Integer, s(:name, :itest), s(:parameters, s(:parameter, :Integer, :n)), s(:statements, s(:if_statement, :zero, s(:condition, s(:operator_value, :-, s(:name, :n), s(:int, 12))), s(:true_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "then")))), s(:false_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "else"))))))), s(:function, :Integer, s(:name, :main), s(:parameters), s(:statements, s(:call, s(:name, :itest), s(:arguments, s(:int, 20))))))))
|
||||
@input = s(:statements, s(:call, s(:name, :itest), s(:arguments, s(:int, 20))))
|
||||
super
|
||||
end
|
||||
|
||||
# must be after boot, but before main compile, to define method
|
||||
def do_clean_compile
|
||||
clean_compile :Space , :itest , {:n => :Integer} ,
|
||||
s(:statements, s(:if_statement, :zero, s(:condition, s(:operator_value, :-, s(:name, :n), s(:int, 12))),
|
||||
s(:true_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "then")))),
|
||||
s(:false_statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "else"))))))
|
||||
end
|
||||
def test_if
|
||||
#show_ticks # get output of what is
|
||||
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
|
||||
|
@ -13,7 +13,7 @@ class Space
|
||||
end
|
||||
|
||||
HERE
|
||||
@input = s(:statements, s(:class, :Space, s(:derives, nil), s(:statements, s(:function, :Integer, s(:name, :main), s(:parameters), s(:statements, s(:return, s(:operator_value, :*, s(:int, 2147483648), s(:int, 2147483648))))))))
|
||||
@input = s(:statements, s(:return, s(:operator_value, :*, s(:int, 2147483648), s(:int, 2147483648))))
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -11,7 +11,7 @@ class Space
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@input = s(:statements, s(:class, :Space, s(:derives, nil), s(:statements, s(:function, :Integer, s(:name, :main), s(:parameters), s(:statements, s(:return, s(:operator_value, :+, s(:int, 4611686018427387903), s(:int, 1))))))))
|
||||
@input = s(:statements, s(:return, s(:operator_value, :+, s(:int, 4611686018427387903), s(:int, 1))))
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -11,7 +11,7 @@ class Space
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@input = s(:statements, s(:class, :Space, s(:derives, nil), s(:statements, s(:function, :Integer, s(:name, :main), s(:parameters), s(:statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "Hello again"))))))))
|
||||
@input = s(:statements, s(:call, s(:name, :putstring), s(:arguments), s(:receiver, s(:string, "Hello again"))))
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -11,12 +11,10 @@ class Space
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@input = s(:statements, s(:class, :Space, s(:derives, nil), s(:statements,
|
||||
s(:function, :Integer, s(:name, :main), s(:parameters),
|
||||
s(:statements, s(:call,
|
||||
s(:name, :get_internal_byte),
|
||||
s(:arguments, s(:int, 1)),
|
||||
s(:receiver, s(:string, "Hello"))))))))
|
||||
@input = s(:statements, s(:call,
|
||||
s(:name, :get_internal_byte),
|
||||
s(:arguments, s(:int, 1)),
|
||||
s(:receiver, s(:string, "Hello"))))
|
||||
super
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user