2014-05-25 08:43:07 +03:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
class TestFunctions < MiniTest::Test
|
|
|
|
include Fragments
|
|
|
|
|
2014-05-28 14:27:18 +03:00
|
|
|
def test_functions
|
2014-05-25 08:43:07 +03:00
|
|
|
@string_input = <<HERE
|
2015-11-30 16:20:39 +02:00
|
|
|
class Space
|
2015-09-20 16:30:07 +03:00
|
|
|
|
2015-10-06 00:27:13 +03:00
|
|
|
int times(int a, int b)
|
2015-11-17 02:28:47 +02:00
|
|
|
if_zero( b + 0)
|
2015-10-06 00:27:13 +03:00
|
|
|
a = 0
|
|
|
|
else
|
2015-10-27 11:00:48 +02:00
|
|
|
int m = b - 1
|
2015-10-06 00:27:13 +03:00
|
|
|
int t = times(a, m)
|
2015-10-27 11:00:48 +02:00
|
|
|
a = a + t
|
2015-10-06 00:27:13 +03:00
|
|
|
end
|
2015-10-27 11:00:48 +02:00
|
|
|
return a
|
2015-10-06 00:27:13 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
int t_seven()
|
2015-11-05 17:00:41 +02:00
|
|
|
int tim = times(8,10)
|
2015-10-06 00:27:13 +03:00
|
|
|
tim.putint()
|
2015-11-05 17:00:41 +02:00
|
|
|
return tim
|
2015-10-06 00:27:13 +03:00
|
|
|
end
|
2014-06-07 23:22:32 +03:00
|
|
|
|
2015-10-06 00:27:13 +03:00
|
|
|
int main()
|
2015-10-27 11:00:48 +02:00
|
|
|
return t_seven()
|
2015-10-06 00:27:13 +03:00
|
|
|
end
|
|
|
|
end
|
2014-05-25 08:43:07 +03:00
|
|
|
HERE
|
2015-11-17 02:28:47 +02:00
|
|
|
@length = 505
|
2015-11-18 13:04:57 +02:00
|
|
|
check 80
|
2014-05-25 08:43:07 +03:00
|
|
|
end
|
2015-11-07 00:13:57 +02:00
|
|
|
|
|
|
|
def test_class_method
|
|
|
|
@string_input = <<HERE
|
2015-11-30 16:20:39 +02:00
|
|
|
class Space
|
2015-11-07 00:13:57 +02:00
|
|
|
|
|
|
|
int self.some()
|
|
|
|
return 5
|
|
|
|
end
|
|
|
|
|
|
|
|
int main()
|
|
|
|
return Object.some()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
2015-11-07 22:20:21 +02:00
|
|
|
@length = 33
|
2015-11-18 13:04:57 +02:00
|
|
|
check 5
|
2015-11-07 00:13:57 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_class_method_fails
|
|
|
|
@string_input = <<HERE
|
2015-11-30 16:20:39 +02:00
|
|
|
class Space
|
2015-11-07 00:13:57 +02:00
|
|
|
int main()
|
|
|
|
return Object.som()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
|
|
|
assert_raises {check}
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2014-05-25 08:43:07 +03:00
|
|
|
end
|