rubyx/test/parfait/test_sol_method.rb

33 lines
887 B
Ruby
Raw Normal View History

2019-07-22 14:21:16 +02:00
require_relative "helper"
module Sol
class TestSolMethod < MiniTest::Test
include SolCompile
2019-07-22 14:21:16 +02:00
def setup
Parfait.boot!(Parfait.default_test_options)
ruby_tree = Ruby::RubyCompiler.compile( as_main("a = 5") )
@clazz = ruby_tree.to_sol
2019-08-08 11:18:36 +02:00
end
def method
@clazz.body.first
2019-07-22 14:21:16 +02:00
end
def test_setup
assert_equal ClassExpression , @clazz.class
2019-08-08 11:18:36 +02:00
assert_equal Statements , @clazz.body.class
assert_equal MethodExpression , method.class
2019-08-08 11:18:36 +02:00
end
def test_class
assert_equal Parfait::Class , @clazz.to_parfait.class
2019-07-22 14:21:16 +02:00
end
2019-08-08 11:18:36 +02:00
def test_method
clazz = @clazz.to_parfait
assert_equal Parfait::SolMethod , clazz.get_instance_method(:main).class
2019-08-08 11:18:36 +02:00
end
def test_type_method
clazz = @clazz.to_parfait
assert_equal Parfait::CallableMethod , clazz.instance_type.get_method(:main).class
end
2019-07-22 14:21:16 +02:00
end
end