check returns on tests

This commit is contained in:
Torsten Ruger 2015-11-05 17:00:41 +02:00
parent 4eb3d9029a
commit eae5cac4b5
6 changed files with 20 additions and 23 deletions

View File

@ -28,4 +28,9 @@ module Fragments
assert_equal @stdout , @interpreter.stdout assert_equal @stdout , @interpreter.stdout
end end
def check_return val
check
assert_equal Parfait::Message , @interpreter.get_register(:r1).class
assert_equal val , @interpreter.get_register(:r1).return_value
end
end end

View File

@ -19,8 +19,9 @@ class Object
end end
int t_seven() int t_seven()
int tim = times(5,3) int tim = times(8,10)
tim.putint() tim.putint()
return tim
end end
int main() int main()
@ -28,8 +29,7 @@ class Object
end end
end end
HERE HERE
@length = 203 @length = 486
check check_return 80
end end
end end

View File

@ -3,7 +3,7 @@ require_relative 'helper'
class TestIf < MiniTest::Test class TestIf < MiniTest::Test
include Fragments include Fragments
def test_if_basic def test_if_plus
@string_input = <<HERE @string_input = <<HERE
class Object class Object
int main() int main()
@ -16,11 +16,11 @@ class Object
end end
end end
HERE HERE
@length = 28 @length = 28
check check_return 4
end end
def test_if_small def test_if_zero
@string_input = <<HERE @string_input = <<HERE
class Object class Object
int main() int main()
@ -37,11 +37,11 @@ HERE
end end
def test_if_puts def test_if_minus
@string_input = <<HERE @string_input = <<HERE
class Object class Object
int itest(int n) int itest(int n)
if_zero( n - 12) if_minus( n - 12)
"then".putstring() "then".putstring()
else else
"else".putstring() "else".putstring()

View File

@ -21,15 +21,14 @@ class Object
int fib_print(int n) int fib_print(int n)
int fib = fibonaccir( n ) int fib = fibonaccir( n )
fib.putint() fib.putint()
return fib
end end
int main() int main()
fib_print(10) return fib_print(10)
end end
end end
HERE HERE
@length = 6594 @length = 6598
check check_return 55
assert_equal Parfait::Message , @interpreter.get_register(:r1).class
#TODO, works in the gui?? assert_equal 55 , @interpreter.get_register(:r1).return_value
end end
end end

View File

@ -3,11 +3,6 @@ require_relative 'helper'
class TestReturn < MiniTest::Test class TestReturn < MiniTest::Test
include Fragments include Fragments
def check_return val
check
assert_equal Parfait::Message , @interpreter.get_register(:r1).class
assert_equal val , @interpreter.get_register(:r1).return_value
end
def test_return1 def test_return1
@string_input = <<HERE @string_input = <<HERE
class Object class Object

View File

@ -26,9 +26,7 @@ class Object
end end
HERE HERE
@length = 278 @length = 278
check check_return 55
assert_equal Parfait::Message , @interpreter.get_register(:r1).class
assert_equal 55 , @interpreter.get_register(:r1).return_value
end end
end end