rubyx/test/sol/test_class_method_expression.rb
Torsten Rüger d1f8733623 Rename Vool to Sol
Simple is really the descriptive name for the layer
Sure, it is "virtual" but that is not as important as the fact that it is simple (or simplified)
Also objct (based really) is better, since orientated implies it is a little like that, but only orientated, not really it. Sol only has objects, nothing else
Just cause i was renaming anyway
2019-10-04 00:38:47 +03:00

49 lines
1.4 KiB
Ruby

require_relative "helper"
module Sol
class TestClassMethodExpression < MiniTest::Test
include SolCompile
def class_code
"class Space;def self.meth; return meth(22 + 22) ; end;end"
end
def setup
Parfait.boot!(Parfait.default_test_options)
ruby_tree = Ruby::RubyCompiler.compile( class_code )
@clazz = ruby_tree.to_sol
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_creates_class_method
clazz = @clazz.to_parfait
m = clazz.single_class.get_instance_method(:meth)
assert m , "no method :meth"
end
def test_creates_type_method
clazz = @clazz.to_parfait
m = clazz.single_class.instance_type.get_method(:meth)
assert m , "no type method :meth"
end
def as_slot
@clazz.to_parfait
@clazz.to_slot(nil)
end
def test_slot
assert_equal :meth , as_slot.method_compilers.callable.name
end
def test_slot_frame
callable = as_slot.method_compilers.callable
assert callable.frame_type.names.last.to_s.start_with?("tmp_") , "no tmp_ variable #{callable.frame_type.names}"
end
end
end