fixing the ruby creation tests

This commit is contained in:
Torsten Ruger 2018-07-19 16:30:36 +03:00
parent f728725b1a
commit 77be0d3f73
16 changed files with 28 additions and 40 deletions

View File

@ -8,16 +8,10 @@ module Ruby
@clazz = clazz
end
def to_vool
MethodStatement.new( @name , @args , @body.normalize)
end
def has_yield?
each{|statement| return true if statement.is_a?(YieldStatement)}
return false
end
def to_s(depth = 0)
arg_str = @args.collect{|a| a.to_s}.join(', ')
at_depth(depth , "def #{name}(#{arg_str})" , @body.to_s(depth + 1) , "end")

0
test/ruby/test_ Normal file
View File

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Ruby
class TestBasicValuesX < MiniTest::Test
class TestBasicValues < MiniTest::Test
include RubyTests
def test_self
@ -47,7 +47,7 @@ module Ruby
assert_equal 1 , lst.statements.first.value
end
end
class TestBasicTypesX < MiniTest::Test
class TestBasicTypes < MiniTest::Test
include RubyTests
def setup
@ -55,26 +55,26 @@ module Ruby
end
def compile_ct( input )
lst = compile( input )
lst.ct_type
lst.ct_type.class_name
end
def test_integer
assert_equal "Integer_Type" , compile_ct( "123").name
assert_equal :Integer , compile_ct( "123")
end
def test_string
assert_equal "Word_Type" , compile_ct( "'string'").name
assert_equal :Word , compile_ct( "'string'")
end
def test_sym
assert_equal "Word_Type" , compile_ct( ":symbol").name
assert_equal :Word , compile_ct( ":symbol")
end
# classes fot these are not implemented in parfait yet
def pest_nil
assert_equal "Nil_Type" , compile_ct( "nil").name
assert_equal :Nil , compile_ct( "nil")
end
def pest_false
assert_equal "False_Type" , compile_ct( "false").name
assert_equal :False , compile_ct( "false")
end
def pest_true
assert_equal "True_Type" , compile_ct( "true").name
assert_equal :True , compile_ct( "true")
end
end
end

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Ruby
class TestEmptyClassStatementX < MiniTest::Test
class TestEmptyClassStatement < MiniTest::Test
include RubyTests
def setup
@ -26,7 +26,7 @@ module Ruby
end
end
class TestBasicClassStatementX < MiniTest::Test
class TestBasicClassStatement < MiniTest::Test
include ScopeHelper
include RubyTests

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Ruby
class HashArrayX < MiniTest::Test
class HashArray < MiniTest::Test
include RubyTests
def test_empty

View File

@ -1,7 +1,7 @@
require_relative 'helper'
module Ruby
class TestIfStatementX < MiniTest::Test
class TestIfStatement < MiniTest::Test
include RubyTests
def basic_if

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Ruby
class TestIvarAssignmentX < MiniTest::Test
class TestIvarAssignment < MiniTest::Test
include RubyTests
def test_local

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Ruby
class TestLocalAssignmentX < MiniTest::Test
class TestLocalAssignment < MiniTest::Test
include RubyTests
def test_local

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Ruby
class TestLogicalX < MiniTest::Test
class TestLogical < MiniTest::Test
include RubyTests
def simple

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Ruby
class TestMethodStatementX < MiniTest::Test
class TestMethodStatement < MiniTest::Test
include RubyTests
def basic_setup()

View File

@ -18,7 +18,7 @@ module Ruby
assert_equal 5 , @lst.value.arguments.first.value
end
end
class TestLocalOpAssignX < MiniTest::Test
class TestLocalOpAssign < MiniTest::Test
include OpAss
include RubyTests
def setup
@ -28,7 +28,7 @@ module Ruby
assert_equal LocalAssignment , @lst.class
end
end
class TestIvarOpAssignX < MiniTest::Test
class TestIvarOpAssign < MiniTest::Test
include OpAss
include RubyTests
def setup

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Ruby
class TestReturnStatementX < MiniTest::Test
class TestReturnStatement < MiniTest::Test
include RubyTests
def test_return_const

View File

@ -1,7 +1,7 @@
require_relative "helper"
module Ruby
class TestSendX < MiniTest::Test
class TestSend < MiniTest::Test
include RubyTests
def test_simple

View File

@ -1,11 +1,11 @@
require_relative "helper"
module Ruby
class TestVariablesX < MiniTest::Test
class TestVariables < MiniTest::Test
include RubyTests
# "free standing" local can not be tested as it will result in send
# in other words ther is no way of knowing if a name is variable or method
# in other words there is no way of knowing if a name is variable or method
# one needs an assignemnt first, to "tell" the parser it's a local
def test_local_basic
lst = compile( "foo = 1 ; foo")

View File

@ -1,7 +1,7 @@
require_relative 'helper'
module Ruby
class TestWhileStatementX < MiniTest::Test
class TestWhileStatement < MiniTest::Test
include RubyTests
def basic_while

View File

@ -1,24 +1,18 @@
require_relative "helper"
module Ruby
class TestYieldStatementX < MiniTest::Test
class TestYieldStatement < MiniTest::Test
include RubyTests
def setup()
input = "def plus_one; yield(0) ; end "
input = "yield(0) "
@lst = compile( input )
end
def test_method
assert_equal MethodStatement , @lst.class
end
def test_block
assert_equal YieldStatement , @lst.body.class
assert_equal YieldStatement , @lst.class
end
def test_block_args
assert_equal IntegerConstant , @lst.body.arguments.first.class
end
def test_method_yield?
assert_equal true , @lst.has_yield?
assert_equal IntegerConstant , @lst.arguments.first.class
end
end
end