fixing the ruby creation tests
This commit is contained in:
parent
f728725b1a
commit
77be0d3f73
@ -8,16 +8,10 @@ module Ruby
|
|||||||
@clazz = clazz
|
@clazz = clazz
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def to_vool
|
def to_vool
|
||||||
MethodStatement.new( @name , @args , @body.normalize)
|
MethodStatement.new( @name , @args , @body.normalize)
|
||||||
end
|
end
|
||||||
|
|
||||||
def has_yield?
|
|
||||||
each{|statement| return true if statement.is_a?(YieldStatement)}
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
def to_s(depth = 0)
|
def to_s(depth = 0)
|
||||||
arg_str = @args.collect{|a| a.to_s}.join(', ')
|
arg_str = @args.collect{|a| a.to_s}.join(', ')
|
||||||
at_depth(depth , "def #{name}(#{arg_str})" , @body.to_s(depth + 1) , "end")
|
at_depth(depth , "def #{name}(#{arg_str})" , @body.to_s(depth + 1) , "end")
|
||||||
|
0
test/ruby/test_
Normal file
0
test/ruby/test_
Normal file
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestBasicValuesX < MiniTest::Test
|
class TestBasicValues < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def test_self
|
def test_self
|
||||||
@ -47,7 +47,7 @@ module Ruby
|
|||||||
assert_equal 1 , lst.statements.first.value
|
assert_equal 1 , lst.statements.first.value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestBasicTypesX < MiniTest::Test
|
class TestBasicTypes < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -55,26 +55,26 @@ module Ruby
|
|||||||
end
|
end
|
||||||
def compile_ct( input )
|
def compile_ct( input )
|
||||||
lst = compile( input )
|
lst = compile( input )
|
||||||
lst.ct_type
|
lst.ct_type.class_name
|
||||||
end
|
end
|
||||||
def test_integer
|
def test_integer
|
||||||
assert_equal "Integer_Type" , compile_ct( "123").name
|
assert_equal :Integer , compile_ct( "123")
|
||||||
end
|
end
|
||||||
def test_string
|
def test_string
|
||||||
assert_equal "Word_Type" , compile_ct( "'string'").name
|
assert_equal :Word , compile_ct( "'string'")
|
||||||
end
|
end
|
||||||
def test_sym
|
def test_sym
|
||||||
assert_equal "Word_Type" , compile_ct( ":symbol").name
|
assert_equal :Word , compile_ct( ":symbol")
|
||||||
end
|
end
|
||||||
# classes fot these are not implemented in parfait yet
|
# classes fot these are not implemented in parfait yet
|
||||||
def pest_nil
|
def pest_nil
|
||||||
assert_equal "Nil_Type" , compile_ct( "nil").name
|
assert_equal :Nil , compile_ct( "nil")
|
||||||
end
|
end
|
||||||
def pest_false
|
def pest_false
|
||||||
assert_equal "False_Type" , compile_ct( "false").name
|
assert_equal :False , compile_ct( "false")
|
||||||
end
|
end
|
||||||
def pest_true
|
def pest_true
|
||||||
assert_equal "True_Type" , compile_ct( "true").name
|
assert_equal :True , compile_ct( "true")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestEmptyClassStatementX < MiniTest::Test
|
class TestEmptyClassStatement < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
@ -26,7 +26,7 @@ module Ruby
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
class TestBasicClassStatementX < MiniTest::Test
|
class TestBasicClassStatement < MiniTest::Test
|
||||||
include ScopeHelper
|
include ScopeHelper
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class HashArrayX < MiniTest::Test
|
class HashArray < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def test_empty
|
def test_empty
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestIfStatementX < MiniTest::Test
|
class TestIfStatement < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def basic_if
|
def basic_if
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestIvarAssignmentX < MiniTest::Test
|
class TestIvarAssignment < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def test_local
|
def test_local
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestLocalAssignmentX < MiniTest::Test
|
class TestLocalAssignment < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def test_local
|
def test_local
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestLogicalX < MiniTest::Test
|
class TestLogical < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def simple
|
def simple
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestMethodStatementX < MiniTest::Test
|
class TestMethodStatement < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def basic_setup()
|
def basic_setup()
|
||||||
|
@ -18,7 +18,7 @@ module Ruby
|
|||||||
assert_equal 5 , @lst.value.arguments.first.value
|
assert_equal 5 , @lst.value.arguments.first.value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestLocalOpAssignX < MiniTest::Test
|
class TestLocalOpAssign < MiniTest::Test
|
||||||
include OpAss
|
include OpAss
|
||||||
include RubyTests
|
include RubyTests
|
||||||
def setup
|
def setup
|
||||||
@ -28,7 +28,7 @@ module Ruby
|
|||||||
assert_equal LocalAssignment , @lst.class
|
assert_equal LocalAssignment , @lst.class
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class TestIvarOpAssignX < MiniTest::Test
|
class TestIvarOpAssign < MiniTest::Test
|
||||||
include OpAss
|
include OpAss
|
||||||
include RubyTests
|
include RubyTests
|
||||||
def setup
|
def setup
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestReturnStatementX < MiniTest::Test
|
class TestReturnStatement < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def test_return_const
|
def test_return_const
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestSendX < MiniTest::Test
|
class TestSend < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def test_simple
|
def test_simple
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestVariablesX < MiniTest::Test
|
class TestVariables < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
# "free standing" local can not be tested as it will result in send
|
# "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
|
# one needs an assignemnt first, to "tell" the parser it's a local
|
||||||
def test_local_basic
|
def test_local_basic
|
||||||
lst = compile( "foo = 1 ; foo")
|
lst = compile( "foo = 1 ; foo")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
require_relative 'helper'
|
require_relative 'helper'
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestWhileStatementX < MiniTest::Test
|
class TestWhileStatement < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def basic_while
|
def basic_while
|
||||||
|
@ -1,24 +1,18 @@
|
|||||||
require_relative "helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module Ruby
|
module Ruby
|
||||||
class TestYieldStatementX < MiniTest::Test
|
class TestYieldStatement < MiniTest::Test
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def setup()
|
def setup()
|
||||||
input = "def plus_one; yield(0) ; end "
|
input = "yield(0) "
|
||||||
@lst = compile( input )
|
@lst = compile( input )
|
||||||
end
|
end
|
||||||
def test_method
|
|
||||||
assert_equal MethodStatement , @lst.class
|
|
||||||
end
|
|
||||||
def test_block
|
def test_block
|
||||||
assert_equal YieldStatement , @lst.body.class
|
assert_equal YieldStatement , @lst.class
|
||||||
end
|
end
|
||||||
def test_block_args
|
def test_block_args
|
||||||
assert_equal IntegerConstant , @lst.body.arguments.first.class
|
assert_equal IntegerConstant , @lst.arguments.first.class
|
||||||
end
|
|
||||||
def test_method_yield?
|
|
||||||
assert_equal true , @lst.has_yield?
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user