Descope Parfait in the compiler

Compiler now removes the module Parfait scope
and also the ::Parfait:: Scope in module names
Which means we can compile scoped code
and get unscoped code. for Parfait
Handy for tests too
This commit is contained in:
2019-09-06 13:59:33 +03:00
parent 7d92ee9e6a
commit f126aa52df
3 changed files with 51 additions and 2 deletions

View File

@ -0,0 +1,21 @@
require_relative "helper"
module Ruby
class ModuleNameTest < Minitest::Test
include RubyTests
def test_parfait_module
assert_equal [nil], compile("module Parfait ; end")
end
def test_parfait_module_const
assert_equal IntegerConstant, compile("module Parfait ; 1;end").first.class
end
def test_module_parfait_removed
exp = compile( "::Parfait::Object" )
assert_equal ModuleName , exp.class
assert_equal :Object , exp.name
end
end
end

View File

@ -4,17 +4,25 @@ module Ruby
class NotImplemented < Minitest::Test
include RubyTests
# random module names don't work, only global Parfait
def assert_handler_missing(input)
assert_raises(Ruby::ProcessError){ compile(input) }
end
def test_module
assert_handler_missing "module Name ; end"
assert_handler_missing( "module Mod ; end" )
end
def test_module_module_scoped
assert_handler_missing( "M::Module" )
end
def test_module_parfait_scoped
assert_handler_missing( "Parfait::Module" )
end
def test_module_parfait_scoped
assert_handler_missing( "module Mod ; end" )
end
end
end