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