2014-07-14 10:29:38 +02:00
|
|
|
require_relative "virtual_helper"
|
|
|
|
|
2014-07-14 23:00:00 +02:00
|
|
|
class TestMethods < MiniTest::Test
|
2014-07-14 10:29:38 +02:00
|
|
|
include VirtualHelper
|
2015-07-02 09:26:48 +02:00
|
|
|
#TODO need to rethink this approach
|
|
|
|
# Sof working as well as it is will serialize the whole space as everythink is reachable from a
|
|
|
|
# method. Even ignoring the size and readability issues, it make sthe test to fragile:
|
|
|
|
# any small object change anywhere in parfait will cause a different output
|
|
|
|
def ttest_simplest_function
|
2014-07-14 10:29:38 +02:00
|
|
|
@string_input = <<HERE
|
2015-05-06 07:38:29 +02:00
|
|
|
def foo(x)
|
2014-07-14 10:29:38 +02:00
|
|
|
5
|
|
|
|
end
|
|
|
|
HERE
|
2015-07-02 09:26:48 +02:00
|
|
|
@output = nil
|
2014-08-20 16:14:52 +02:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-07-02 09:26:48 +02:00
|
|
|
def ttest_puts_string
|
2014-08-20 16:14:52 +02:00
|
|
|
@string_input = <<HERE
|
|
|
|
def foo()
|
|
|
|
puts("Hello")
|
|
|
|
end
|
|
|
|
foo()
|
|
|
|
HERE
|
2015-07-02 09:26:48 +02:00
|
|
|
@output = nil
|
2014-07-14 10:29:38 +02:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-07-02 09:26:48 +02:00
|
|
|
def ttest_class_function
|
2014-07-14 10:29:38 +02:00
|
|
|
@string_input = <<HERE
|
|
|
|
def String.length(x)
|
|
|
|
@length
|
|
|
|
end
|
|
|
|
HERE
|
2015-05-16 19:16:49 +02:00
|
|
|
@output = nil
|
2014-07-14 13:06:09 +02:00
|
|
|
check
|
2014-07-14 10:29:38 +02:00
|
|
|
end
|
|
|
|
|
2015-07-02 09:26:48 +02:00
|
|
|
def ttest_function_ops
|
2014-07-14 10:29:38 +02:00
|
|
|
@string_input = <<HERE
|
2015-05-06 07:38:29 +02:00
|
|
|
def foo(x)
|
|
|
|
abba = 5
|
2014-07-14 10:29:38 +02:00
|
|
|
2 + 5
|
|
|
|
end
|
|
|
|
HERE
|
2015-07-02 09:26:48 +02:00
|
|
|
@output = nil
|
2014-07-15 17:27:13 +02:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-07-02 09:26:48 +02:00
|
|
|
def ttest_function_ops_simple
|
2014-07-15 17:27:13 +02:00
|
|
|
@string_input = <<HERE
|
|
|
|
def foo()
|
|
|
|
2 + 5
|
|
|
|
end
|
|
|
|
HERE
|
2015-07-02 09:26:48 +02:00
|
|
|
@output = nil
|
2014-07-14 15:19:47 +02:00
|
|
|
check
|
2014-07-14 10:29:38 +02:00
|
|
|
end
|
|
|
|
|
2015-07-02 09:26:48 +02:00
|
|
|
def ttest_function_if
|
2014-07-14 10:29:38 +02:00
|
|
|
@string_input = <<HERE
|
|
|
|
def ofthen(n)
|
|
|
|
if(0)
|
|
|
|
isit = 42
|
|
|
|
else
|
|
|
|
maybenot = 667
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
2015-07-02 09:26:48 +02:00
|
|
|
@output = nil
|
2015-05-06 14:15:53 +02:00
|
|
|
check
|
2014-07-14 10:29:38 +02:00
|
|
|
end
|
|
|
|
|
2015-07-02 09:26:48 +02:00
|
|
|
def ttest_function_while
|
2014-07-17 15:46:17 +02:00
|
|
|
@string_input = <<HERE
|
|
|
|
def fibonaccit(n)
|
|
|
|
a = 0
|
|
|
|
while (n) do
|
|
|
|
some = 43
|
|
|
|
other = some * 4
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
2015-07-02 09:26:48 +02:00
|
|
|
@output = nil
|
2014-07-17 15:46:17 +02:00
|
|
|
check
|
|
|
|
end
|
|
|
|
|
2015-05-06 14:15:53 +02:00
|
|
|
def pest_function_return
|
2014-07-14 10:29:38 +02:00
|
|
|
@string_input = <<HERE
|
|
|
|
def retvar(n)
|
|
|
|
i = 5
|
2015-05-06 07:38:29 +02:00
|
|
|
return i
|
2014-07-14 10:29:38 +02:00
|
|
|
end
|
|
|
|
HERE
|
2014-08-13 10:59:51 +02:00
|
|
|
@output = ""
|
2014-07-14 15:19:47 +02:00
|
|
|
check
|
2014-07-14 10:29:38 +02:00
|
|
|
end
|
|
|
|
|
2015-05-06 14:15:53 +02:00
|
|
|
def pest_function_return_if
|
2014-07-14 10:29:38 +02:00
|
|
|
@string_input = <<HERE
|
|
|
|
def retvar(n)
|
|
|
|
if( n > 5)
|
|
|
|
return 10
|
|
|
|
else
|
|
|
|
return 20
|
2015-05-06 07:38:29 +02:00
|
|
|
end
|
2014-07-14 10:29:38 +02:00
|
|
|
end
|
|
|
|
HERE
|
2014-08-13 10:59:51 +02:00
|
|
|
@output = ""
|
2014-07-14 15:19:47 +02:00
|
|
|
check
|
2014-07-14 10:29:38 +02:00
|
|
|
end
|
|
|
|
|
2015-05-06 14:15:53 +02:00
|
|
|
def est_function_return_while
|
2014-07-14 10:29:38 +02:00
|
|
|
@string_input = <<HERE
|
|
|
|
def retvar(n)
|
|
|
|
while( n > 5) do
|
|
|
|
n = n + 1
|
|
|
|
return n
|
2015-05-06 07:38:29 +02:00
|
|
|
end
|
2014-07-14 10:29:38 +02:00
|
|
|
end
|
|
|
|
HERE
|
2014-08-13 10:59:51 +02:00
|
|
|
@output = ""
|
2014-07-14 15:19:47 +02:00
|
|
|
check
|
2014-07-14 10:29:38 +02:00
|
|
|
end
|
|
|
|
|
2015-05-06 14:15:53 +02:00
|
|
|
def pest_function_big_while
|
2014-07-14 10:29:38 +02:00
|
|
|
@string_input = <<HERE
|
|
|
|
def fibonaccit(n)
|
2015-05-06 07:38:29 +02:00
|
|
|
a = 0
|
2014-07-14 10:29:38 +02:00
|
|
|
b = 1
|
|
|
|
while( n > 1 ) do
|
|
|
|
tmp = a
|
|
|
|
a = b
|
|
|
|
b = tmp + b
|
|
|
|
puts(b)
|
|
|
|
n = n - 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
HERE
|
2014-08-13 10:59:51 +02:00
|
|
|
@output = ""
|
2014-07-14 15:19:47 +02:00
|
|
|
check
|
2015-05-06 07:38:29 +02:00
|
|
|
end
|
|
|
|
end
|