adds modules to vool
This commit is contained in:
parent
5f70067fa0
commit
73964aeb6e
@ -101,6 +101,14 @@ module Vool
|
||||
ClassVariable.new(expression.children.first.to_s[2 .. -1].to_sym)
|
||||
end
|
||||
|
||||
def on_const expression
|
||||
scope = expression.children.first
|
||||
if scope
|
||||
raise "Only unscoped Names implemented #{scope}" unless scope.type == :cbase
|
||||
end
|
||||
ModuleName.new(expression.children[1])
|
||||
end
|
||||
|
||||
def on_lvasgn expression
|
||||
name = expression.children[0]
|
||||
value = process(expression.children[1])
|
||||
|
@ -18,4 +18,7 @@ module Vool
|
||||
include Named
|
||||
end
|
||||
|
||||
class ModuleName < Statement
|
||||
include Named
|
||||
end
|
||||
end
|
||||
|
@ -31,5 +31,20 @@ module Vool
|
||||
lst = Compiler.compile( "return @@var" )
|
||||
assert_equal ClassVariable , lst.return_value.class
|
||||
end
|
||||
|
||||
def test_module_basic
|
||||
lst = Compiler.compile( "Module" )
|
||||
assert_equal ModuleName , lst.class
|
||||
assert_equal :Module , lst.name
|
||||
end
|
||||
|
||||
def test_module_base_scoped
|
||||
lst = Compiler.compile( "::Module" )
|
||||
assert_equal ModuleName , lst.class
|
||||
assert_equal :Module , lst.name
|
||||
end
|
||||
def test_module_module_scoped
|
||||
assert_raises {Compiler.compile( "M::Module" ) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user