rename singleton_class to single_class and misc
was clashing with real ruby method name also many superclass mismatch fixes some misc
This commit is contained in:
@ -19,7 +19,7 @@ module Vool
|
||||
end
|
||||
|
||||
def setup
|
||||
source = "class Integer;def +(other);X.int_operator(:+);end;end;" + class_main
|
||||
source = "class Integer<Data4;def +(other);X.int_operator(:+);end;end;" + class_main
|
||||
ret = RubyX::RubyXCompiler.new(RubyX.default_test_options).ruby_to_mom(source)
|
||||
@ins = ret.compilers.find{|c|c.callable.name==:main}.mom_instructions.next
|
||||
end
|
||||
|
@ -27,7 +27,7 @@ module Vool
|
||||
def test_class_inst
|
||||
space_class = Parfait.object_space.get_class
|
||||
assert_equal :Space , space_class.name
|
||||
names = space_class.singleton_class.instance_type.names
|
||||
names = space_class.single_class.instance_type.names
|
||||
assert names.index_of(:inst) , names
|
||||
end
|
||||
def test_compiler
|
||||
|
@ -7,7 +7,7 @@ module Vool
|
||||
|
||||
def class_main
|
||||
<<-eos
|
||||
class Object
|
||||
class Space
|
||||
def self.one_plus()
|
||||
return 1 + 1
|
||||
end
|
||||
|
@ -12,14 +12,16 @@ module VoolBlocks
|
||||
def test_block_not_compiles
|
||||
source = "main{|val| val = 0}"
|
||||
vool = Ruby::RubyCompiler.compile( as_class_method(source) ).to_vool
|
||||
vool.to_parfait
|
||||
begin
|
||||
vool.to_mom(nil)
|
||||
rescue => err
|
||||
rescue => err
|
||||
assert err.message.include?("Blocks") , err.message
|
||||
end
|
||||
end
|
||||
def test_assign_compiles
|
||||
vool = Ruby::RubyCompiler.compile( as_class_method("val = 0") ).to_vool
|
||||
vool.to_parfait
|
||||
assert_equal Mom::MomCollection , vool.to_mom(nil).class
|
||||
end
|
||||
end
|
||||
|
@ -2,7 +2,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestClassStatement #< MiniTest::Test
|
||||
class TestClassStatement < MiniTest::Test
|
||||
include ScopeHelper
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
@ -26,7 +26,7 @@ module Vool
|
||||
assert_equal :a , @vool.to_parfait.instance_type.names[1]
|
||||
end
|
||||
end
|
||||
class TestClassStatementTypeCreation #< MiniTest::Test
|
||||
class TestClassStatementTypeCreation < MiniTest::Test
|
||||
include ScopeHelper
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
|
39
test/vool/test_class_method_expression.rb
Normal file
39
test/vool/test_class_method_expression.rb
Normal file
@ -0,0 +1,39 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestClassMethodExpression < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def class_code
|
||||
"class Space;def self.meth;return 1 ; end;end"
|
||||
end
|
||||
def setup
|
||||
Parfait.boot!(Parfait.default_test_options)
|
||||
ruby_tree = Ruby::RubyCompiler.compile( class_code )
|
||||
@clazz = ruby_tree.to_vool
|
||||
end
|
||||
def method
|
||||
@clazz.body.first
|
||||
end
|
||||
def test_setup
|
||||
assert_equal ClassExpression , @clazz.class
|
||||
assert_equal Statements , @clazz.body.class
|
||||
assert_equal ClassMethodExpression , method.class
|
||||
end
|
||||
def test_fail
|
||||
assert_raises{ method.to_parfait }
|
||||
end
|
||||
def test_method
|
||||
clazz = @clazz.to_parfait
|
||||
assert_equal Parfait::Class , clazz.class
|
||||
meth = method.to_parfait(clazz)
|
||||
assert_equal Parfait::VoolMethod , meth.class
|
||||
assert_equal :meth , meth.name
|
||||
end
|
||||
def test_is_class_method
|
||||
clazz = @clazz.to_parfait
|
||||
m = clazz.single_class.get_instance_method(:meth)
|
||||
assert m , "no method :meth"
|
||||
end
|
||||
end
|
||||
end
|
@ -1,7 +1,7 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
class TestMethodStatement < MiniTest::Test
|
||||
class TestMethodExpression < MiniTest::Test
|
||||
include VoolCompile
|
||||
|
||||
def setup
|
||||
@ -23,7 +23,12 @@ module Vool
|
||||
def test_method
|
||||
clazz = @clazz.to_parfait
|
||||
assert_equal Parfait::Class , clazz.class
|
||||
assert_equal Parfait::VoolMethod , method.to_parfait(clazz).class
|
||||
meth = method.to_parfait(clazz)
|
||||
assert_equal Parfait::VoolMethod , meth.class
|
||||
assert_equal :main , meth.name
|
||||
end
|
||||
def test_is_instance_method
|
||||
assert main = @clazz.to_parfait.get_instance_method(:main)
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user