starts on local variable collection
500 tests (in under 2 seconds), yippie
This commit is contained in:
parent
ea41f9cae9
commit
b0e3978b15
@ -23,7 +23,6 @@ module Vool
|
||||
|
||||
def on_class( statement )
|
||||
name , sup , body = *statement
|
||||
puts "CLASS #{statement}"
|
||||
ClassStatement.new( get_name(name) , get_name(sup) , process(body) )
|
||||
end
|
||||
|
||||
|
@ -10,6 +10,10 @@ module Vool
|
||||
end
|
||||
end
|
||||
class LocalAssignment < Assignment
|
||||
# used to collect frame information
|
||||
def add_local( array )
|
||||
array << @name
|
||||
end
|
||||
end
|
||||
class InstanceAssignment < Assignment
|
||||
# used to collect type information
|
||||
|
3
test/vool/compilers/test_all.rb
Normal file
3
test/vool/compilers/test_all.rb
Normal file
@ -0,0 +1,3 @@
|
||||
require_relative "helper"
|
||||
require_relative "test_ivar_collect"
|
||||
require_relative "test_local_collect"
|
27
test/vool/compilers/test_local_collect.rb
Normal file
27
test/vool/compilers/test_local_collect.rb
Normal file
@ -0,0 +1,27 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Vool
|
||||
module Compilers
|
||||
class TestLocalCollect < MiniTest::Test
|
||||
|
||||
def compile(input)
|
||||
lst = VoolCompiler.compile( input )
|
||||
vars = []
|
||||
lst.collect([]).each do |node|
|
||||
node.add_local(vars)
|
||||
end
|
||||
vars
|
||||
end
|
||||
|
||||
def test_assign_collect
|
||||
vars = compile( "var = 5" )
|
||||
assert_equal :var , vars.first
|
||||
end
|
||||
|
||||
def test_return_collect
|
||||
vars = compile( "var = 5 ; return var" )
|
||||
assert_equal :var , vars.first
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -1,2 +1,4 @@
|
||||
require_relative "helper"
|
||||
require_relative "test_ruby_compiler"
|
||||
require_relative "statements/test_all"
|
||||
require_relative "compilers/test_all"
|
||||
require_relative "test_vool_compiler"
|
||||
|
@ -1 +0,0 @@
|
||||
require_relative "statements/test_all"
|
Loading…
Reference in New Issue
Block a user