finish typing variables

This commit is contained in:
Torsten Ruger
2015-09-27 16:06:48 +03:00
parent 26c6db17b1
commit 252c0ccdca
12 changed files with 81 additions and 40 deletions

View File

@ -34,8 +34,8 @@ class TestBasic < MiniTest::Test
check
end
def test_name
@string_input = 'foo '
def test_var
@string_input = 'int foo '
@output = "- Virtual::Return(:type => :int)"
check
end

View File

@ -5,7 +5,7 @@ module Virtual
class TestFoo < MiniTest::Test
include CodeChecker
def test_foo2
def test_foo3
@string_input = <<HERE
field int a
int foo(int x)

View File

@ -6,17 +6,18 @@ class TestRecursinveFibo < MiniTest::Test
def test_recursive_fibo
@string_input = <<HERE
int fib_print(int n)
fib = fibonaccir( n )
int fib = fibonaccir( n )
fib.putint()
end
int fibonaccir( int n )
if( n <= 1 )
return n
else
int tmp = n - 1
a = fibonaccir( tmp )
int tmp
tmp = n - 1
int a = fibonaccir( tmp )
tmp = n - 2
b = fibonaccir( tmp )
int b = fibonaccir( tmp )
return a + b
end
end

View File

@ -3,3 +3,4 @@ require_relative "test_object"
require_relative "test_list"
require_relative "test_word"
require_relative "test_dictionary"
require_relative "test_method"

View File

@ -0,0 +1,23 @@
require_relative "../helper"
class TestMethod < MiniTest::Test
def setup
obj = Virtual.machine.boot.space.get_class_by_name(:Object)
args = Virtual.new_list [ Parfait::Variable.new(:int , :bar )]
@method = ::Parfait::Method.new obj , :foo , args
end
def test_method_name
assert_equal :foo , @method.name
end
def test_arg1
assert_equal 1 , @method.arguments.get_length
assert_equal Parfait::Variable , @method.arguments.first.class
assert_equal :bar , @method.arguments.first.name
end
def test_has_arg
assert_equal 1 , @method.has_arg(:bar)
end
end