2014-05-24 10:18:54 +03:00
|
|
|
require_relative 'helper'
|
|
|
|
|
|
|
|
class TestIf < MiniTest::Test
|
|
|
|
include Fragments
|
|
|
|
|
2015-11-05 17:00:41 +02:00
|
|
|
def test_if_plus
|
2015-07-18 15:28:57 +03:00
|
|
|
@string_input = <<HERE
|
2015-10-06 00:27:13 +03:00
|
|
|
class Object
|
|
|
|
int main()
|
2015-10-07 10:04:55 +03:00
|
|
|
int n = 10
|
2015-10-19 15:31:48 +03:00
|
|
|
if_plus( n - 12)
|
2015-10-09 18:06:00 +03:00
|
|
|
return 3
|
2015-10-06 00:27:13 +03:00
|
|
|
else
|
2015-10-09 18:06:00 +03:00
|
|
|
return 4
|
2015-10-06 00:27:13 +03:00
|
|
|
end
|
|
|
|
end
|
2015-07-18 15:28:57 +03:00
|
|
|
end
|
|
|
|
HERE
|
2015-11-05 17:00:41 +02:00
|
|
|
@length = 28
|
|
|
|
check_return 4
|
2015-07-18 15:28:57 +03:00
|
|
|
end
|
|
|
|
|
2015-11-05 17:00:41 +02:00
|
|
|
def test_if_zero
|
2015-07-19 13:03:21 +03:00
|
|
|
@string_input = <<HERE
|
2015-10-06 00:27:13 +03:00
|
|
|
class Object
|
|
|
|
int main()
|
2015-10-19 14:46:12 +03:00
|
|
|
int n = 10
|
2015-10-22 14:51:20 +03:00
|
|
|
if_zero(n - 10 )
|
2015-10-19 14:46:12 +03:00
|
|
|
"10".putstring()
|
|
|
|
end
|
2015-10-06 00:27:13 +03:00
|
|
|
end
|
|
|
|
end
|
2015-07-19 13:03:21 +03:00
|
|
|
HERE
|
2015-11-03 11:23:58 +02:00
|
|
|
@length = 49
|
2015-10-19 14:46:12 +03:00
|
|
|
@stdout = "10"
|
2015-07-19 13:03:21 +03:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2015-11-05 17:00:41 +02:00
|
|
|
def test_if_minus
|
2014-05-24 10:18:54 +03:00
|
|
|
@string_input = <<HERE
|
2015-10-06 00:27:13 +03:00
|
|
|
class Object
|
|
|
|
int itest(int n)
|
2015-11-05 17:00:41 +02:00
|
|
|
if_minus( n - 12)
|
2015-10-06 00:27:13 +03:00
|
|
|
"then".putstring()
|
|
|
|
else
|
|
|
|
"else".putstring()
|
|
|
|
end
|
2015-07-19 11:15:38 +03:00
|
|
|
end
|
2014-05-30 10:42:43 +03:00
|
|
|
|
2015-10-06 00:27:13 +03:00
|
|
|
int main()
|
|
|
|
itest(20)
|
|
|
|
end
|
|
|
|
end
|
2014-05-24 10:18:54 +03:00
|
|
|
HERE
|
2015-11-03 11:23:58 +02:00
|
|
|
@length = 64
|
2015-10-19 14:46:12 +03:00
|
|
|
@stdout = "else"
|
2015-07-18 15:28:57 +03:00
|
|
|
check
|
2014-05-24 10:18:54 +03:00
|
|
|
end
|
|
|
|
end
|