rubyx/test/sol/test_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

54 lines
1.4 KiB
Ruby

require_relative "helper"
module Sol
class TestMethodExpression < MiniTest::Test
include SolCompile
def setup
Parfait.boot!(Parfait.default_test_options)
ruby_tree = Ruby::RubyCompiler.compile( as_main("a = 5") )
@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 MethodExpression , method.class
end
def test_fail
assert_raises{ method.to_parfait }
end
def test_method
assert_equal Parfait::Class , @clazz.to_parfait.class
end
def test_creates_instance_method
main = @clazz.to_parfait.get_instance_method(:main)
assert_equal Parfait::SolMethod , main.class
assert_equal :main , main.name
end
def test_creates_type_method
clazz = @clazz.to_parfait
m = clazz.instance_type.get_method(:main)
assert m , "no type method :main"
end
end
class TestMethodExpressionDoubleDef < MiniTest::Test
include SolCompile
def setup
Parfait.boot!(Parfait.default_test_options)
ruby_tree = Ruby::RubyCompiler.compile( as_main("a = 5") + ";" + as_main("a = 5") )
@clazz = ruby_tree.to_sol
end
def method
@clazz.body.first
end
def test_no_double
assert_raises {@clazz.to_parfait}
end
end
end