fixing the ruby creation tests
This commit is contained in:
parent
f728725b1a
commit
77be0d3f73
@ -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
0
test/ruby/test_
Normal 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
|
||||
|
@ -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
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Ruby
|
||||
class HashArrayX < MiniTest::Test
|
||||
class HashArray < MiniTest::Test
|
||||
include RubyTests
|
||||
|
||||
def test_empty
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative 'helper'
|
||||
|
||||
module Ruby
|
||||
class TestIfStatementX < MiniTest::Test
|
||||
class TestIfStatement < MiniTest::Test
|
||||
include RubyTests
|
||||
|
||||
def basic_if
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Ruby
|
||||
class TestIvarAssignmentX < MiniTest::Test
|
||||
class TestIvarAssignment < MiniTest::Test
|
||||
include RubyTests
|
||||
|
||||
def test_local
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Ruby
|
||||
class TestLocalAssignmentX < MiniTest::Test
|
||||
class TestLocalAssignment < MiniTest::Test
|
||||
include RubyTests
|
||||
|
||||
def test_local
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Ruby
|
||||
class TestLogicalX < MiniTest::Test
|
||||
class TestLogical < MiniTest::Test
|
||||
include RubyTests
|
||||
|
||||
def simple
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Ruby
|
||||
class TestMethodStatementX < MiniTest::Test
|
||||
class TestMethodStatement < MiniTest::Test
|
||||
include RubyTests
|
||||
|
||||
def basic_setup()
|
||||
|
@ -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
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Ruby
|
||||
class TestReturnStatementX < MiniTest::Test
|
||||
class TestReturnStatement < MiniTest::Test
|
||||
include RubyTests
|
||||
|
||||
def test_return_const
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Ruby
|
||||
class TestSendX < MiniTest::Test
|
||||
class TestSend < MiniTest::Test
|
||||
include RubyTests
|
||||
|
||||
def test_simple
|
||||
|
@ -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")
|
||||
|
@ -1,7 +1,7 @@
|
||||
require_relative 'helper'
|
||||
|
||||
module Ruby
|
||||
class TestWhileStatementX < MiniTest::Test
|
||||
class TestWhileStatement < MiniTest::Test
|
||||
include RubyTests
|
||||
|
||||
def basic_while
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user