2019-07-22 15:21:16 +03:00
|
|
|
require_relative "helper"
|
|
|
|
|
2019-10-04 00:36:49 +03:00
|
|
|
module Sol
|
|
|
|
class TestSolMethod < MiniTest::Test
|
|
|
|
include SolCompile
|
2019-07-22 15:21:16 +03:00
|
|
|
|
|
|
|
def setup
|
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2019-09-12 13:10:31 +03:00
|
|
|
ruby_tree = Ruby::RubyCompiler.compile( as_main("a = 5") )
|
2019-10-04 00:36:49 +03:00
|
|
|
@clazz = ruby_tree.to_sol
|
2019-08-08 12:18:36 +03:00
|
|
|
end
|
|
|
|
def method
|
|
|
|
@clazz.body.first
|
2019-07-22 15:21:16 +03:00
|
|
|
end
|
|
|
|
def test_setup
|
2019-08-19 15:23:57 +03:00
|
|
|
assert_equal ClassExpression , @clazz.class
|
2019-08-08 12:18:36 +03:00
|
|
|
assert_equal Statements , @clazz.body.class
|
2019-08-19 15:23:57 +03:00
|
|
|
assert_equal MethodExpression , method.class
|
2019-08-08 12:18:36 +03:00
|
|
|
end
|
|
|
|
def test_class
|
2019-09-24 15:44:33 +03:00
|
|
|
assert_equal Parfait::Class , @clazz.to_parfait.class
|
2019-07-22 15:21:16 +03:00
|
|
|
end
|
2019-08-08 12:18:36 +03:00
|
|
|
def test_method
|
2019-09-24 15:44:33 +03:00
|
|
|
clazz = @clazz.to_parfait
|
2019-10-04 00:36:49 +03:00
|
|
|
assert_equal Parfait::SolMethod , clazz.get_instance_method(:main).class
|
2019-08-08 12:18:36 +03:00
|
|
|
end
|
2019-09-29 22:37:28 +03:00
|
|
|
def test_type_method
|
|
|
|
clazz = @clazz.to_parfait
|
|
|
|
assert_equal Parfait::CallableMethod , clazz.instance_type.get_method(:main).class
|
|
|
|
end
|
2019-07-22 15:21:16 +03:00
|
|
|
end
|
|
|
|
end
|