mains tests can include any code
not wrapping as main anymore (must still include mains) first part of #11
This commit is contained in:
parent
233b83510f
commit
80264c5322
@ -1 +1,5 @@
|
||||
return 2 +2
|
||||
class Space
|
||||
def main(arg)
|
||||
return 2 +2
|
||||
end
|
||||
end
|
||||
|
@ -1,7 +1,11 @@
|
||||
a = 0
|
||||
b = 20
|
||||
while( a < b )
|
||||
a = a + 1
|
||||
b = b - 1
|
||||
class Space
|
||||
def main(arg)
|
||||
a = 0
|
||||
b = 20
|
||||
while( a < b )
|
||||
a = a + 1
|
||||
b = b - 1
|
||||
end
|
||||
return a
|
||||
end
|
||||
end
|
||||
return a
|
||||
|
@ -1,11 +1,15 @@
|
||||
n = 6
|
||||
a = 0
|
||||
b = 1
|
||||
i = 1
|
||||
while( i < n )
|
||||
result = a + b
|
||||
a = b
|
||||
b = result
|
||||
i = i + 1
|
||||
class Space
|
||||
def main(arg)
|
||||
n = 6
|
||||
a = 0
|
||||
b = 1
|
||||
i = 1
|
||||
while( i < n )
|
||||
result = a + b
|
||||
a = b
|
||||
b = result
|
||||
i = i + 1
|
||||
end
|
||||
return result
|
||||
end
|
||||
end
|
||||
return result
|
||||
|
@ -1 +1,5 @@
|
||||
return "Hello-there".putstring
|
||||
class Space
|
||||
def main(arg)
|
||||
return "Hello-there".putstring
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,9 @@
|
||||
b = 10
|
||||
while( b >= 1 )
|
||||
b = b - 1
|
||||
class Space
|
||||
def main(arg)
|
||||
b = 10
|
||||
while( b >= 1 )
|
||||
b = b - 1
|
||||
end
|
||||
return b
|
||||
end
|
||||
end
|
||||
return b
|
||||
|
@ -16,7 +16,7 @@ module Mains
|
||||
tests << method_name
|
||||
input = File.read(file_name)
|
||||
self.send(:define_method, method_name ) do
|
||||
ticks = run_main(input)
|
||||
ticks = run_input(input)
|
||||
#puts "Ticks for #{method_name}=#{ticks}"
|
||||
assert_equal stdout , @interpreter.stdout , "Wrong stdout #{name}"
|
||||
assert_equal exit_code , get_return.to_s , "Wrong exit code #{name}"
|
||||
|
@ -92,8 +92,16 @@ module Risc
|
||||
def get_message_return
|
||||
@interpreter.get_register(:r8).return_value
|
||||
end
|
||||
|
||||
# wrap the input so it is a main, compile and run it
|
||||
def run_main(input)
|
||||
@string_input = as_main(input)
|
||||
run_input as_main(input)
|
||||
end
|
||||
|
||||
# use the input as it, compile and run it
|
||||
# input muts contain a Space.main, but may contain more classes and methods
|
||||
def run_input(input)
|
||||
@string_input = input
|
||||
do_setup
|
||||
run_all
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user