2018-07-01 10:59:52 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Mom
|
2018-07-01 20:26:45 +02:00
|
|
|
class TestMomCompiler < MiniTest::Test
|
2018-07-01 10:59:52 +02:00
|
|
|
include MomCompile
|
|
|
|
|
|
|
|
def setup
|
2019-02-08 22:03:23 +01:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2018-07-03 09:12:22 +02:00
|
|
|
@comp = compile_mom( "class Test ; def main(); return 'Hi'; end; end;")
|
2018-07-01 10:59:52 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def test_class
|
2018-07-01 20:26:45 +02:00
|
|
|
assert_equal MomCompiler , @comp.class
|
2018-07-01 10:59:52 +02:00
|
|
|
end
|
|
|
|
def test_compilers
|
2018-11-02 23:54:30 +01:00
|
|
|
assert_equal 23 , @comp.compilers.length
|
|
|
|
end
|
|
|
|
def test_boot_compilers
|
|
|
|
assert_equal 22 , @comp.boot_compilers.length
|
2018-07-01 10:59:52 +02:00
|
|
|
end
|
2018-07-04 07:28:05 +02:00
|
|
|
def test_compilers_bare
|
2018-11-02 23:54:30 +01:00
|
|
|
assert_equal 22 , MomCompiler.new.compilers.length
|
2018-07-04 07:28:05 +02:00
|
|
|
end
|
2018-07-03 09:12:22 +02:00
|
|
|
def test_returns_constants
|
|
|
|
assert_equal Array , @comp.constants.class
|
|
|
|
end
|
|
|
|
def test_has_constant
|
2018-08-29 20:06:29 +02:00
|
|
|
assert_equal "Hi" , @comp.constants[1].to_string
|
2018-07-03 09:12:22 +02:00
|
|
|
end
|
2018-07-01 10:59:52 +02:00
|
|
|
def test_has_translate
|
|
|
|
assert @comp.translate(:interpreter)
|
|
|
|
end
|
2018-11-02 23:54:30 +01:00
|
|
|
def test_append_class
|
|
|
|
assert_equal MomCompiler, (@comp.append @comp).class
|
|
|
|
end
|
|
|
|
def test_append_length
|
|
|
|
assert_equal 2 , @comp.append(@comp).method_compilers.length
|
|
|
|
end
|
2018-07-01 13:12:42 +02:00
|
|
|
end
|
2018-07-01 10:59:52 +02:00
|
|
|
end
|