split rubyx tests
in vool and mom level
This commit is contained in:
parent
7006c8e3aa
commit
5b87133df2
@ -2,7 +2,7 @@ require_relative "helper"
|
|||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
class TestRiscCompiler < MiniTest::Test
|
class TestRiscCompiler < MiniTest::Test
|
||||||
include CompilerHelper
|
include ScopeHelper
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Risc.machine.boot
|
Risc.machine.boot
|
||||||
|
20
test/rubyx/helper.rb
Normal file
20
test/rubyx/helper.rb
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
require_relative "../helper"
|
||||||
|
|
||||||
|
module RubyX
|
||||||
|
module RubyXHelper
|
||||||
|
def setup
|
||||||
|
Risc.machine.boot
|
||||||
|
end
|
||||||
|
def ruby_to_vool(input)
|
||||||
|
RubyXCompiler.ruby_to_vool(input)
|
||||||
|
end
|
||||||
|
def compile_in_test input
|
||||||
|
vool = ruby_to_vool in_Test(input)
|
||||||
|
vool.to_mom(nil)
|
||||||
|
itest = Parfait.object_space.get_class_by_name(:Test)
|
||||||
|
assert itest
|
||||||
|
itest
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -27,7 +27,7 @@ module Vool
|
|||||||
|
|
||||||
end
|
end
|
||||||
class TestBasicClassStatement < MiniTest::Test
|
class TestBasicClassStatement < MiniTest::Test
|
||||||
include CompilerHelper
|
include ScopeHelper
|
||||||
include RubyTests
|
include RubyTests
|
||||||
|
|
||||||
def test_compile_one_method
|
def test_compile_one_method
|
||||||
|
@ -1,20 +1,9 @@
|
|||||||
require_relative "../helper"
|
require_relative "helper"
|
||||||
|
|
||||||
module RubyX
|
module RubyX
|
||||||
class TestClassCompiler < MiniTest::Test
|
class TestVoolCompiler < MiniTest::Test
|
||||||
include CompilerHelper
|
include ScopeHelper
|
||||||
|
include RubyXHelper
|
||||||
def setup
|
|
||||||
Risc.machine.boot
|
|
||||||
end
|
|
||||||
|
|
||||||
def compile_in_test input
|
|
||||||
vool = RubyXCompiler.ruby_to_vool in_Test(input)
|
|
||||||
vool.to_mom(nil)
|
|
||||||
itest = Parfait.object_space.get_class_by_name(:Test)
|
|
||||||
assert itest
|
|
||||||
itest
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_compile_class_one
|
def test_compile_class_one
|
||||||
itest = compile_in_test "def meth; @ivar = 5; end"
|
itest = compile_in_test "def meth; @ivar = 5; end"
|
||||||
@ -28,49 +17,26 @@ module RubyX
|
|||||||
|
|
||||||
def test_doesnt_create_existing_clas
|
def test_doesnt_create_existing_clas
|
||||||
space_class = Parfait.object_space.get_class_by_name(:Space)
|
space_class = Parfait.object_space.get_class_by_name(:Space)
|
||||||
RubyXCompiler.ruby_to_vool "class Space ; end"
|
ruby_to_vool "class Space ; end"
|
||||||
clazz = Parfait.object_space.get_class_by_name(:Space)
|
clazz = Parfait.object_space.get_class_by_name(:Space)
|
||||||
assert_equal clazz , space_class
|
assert_equal clazz , space_class
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_class_body_is_scope
|
def test_class_body_is_scope
|
||||||
clazz = RubyXCompiler.ruby_to_vool in_Test("def meth; @ivar = 5 ;end")
|
clazz = ruby_to_vool in_Test("def meth; @ivar = 5 ;end")
|
||||||
assert_equal Vool::MethodStatement , clazz.body.class
|
assert_equal Vool::MethodStatement , clazz.body.class
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_creates_class_without_deriviation
|
|
||||||
vool = RubyXCompiler.ruby_to_vool "class Testing ; end"
|
|
||||||
vool.to_mom(nil)
|
|
||||||
clazz = Parfait.object_space.get_class_by_name(:Testing)
|
|
||||||
assert clazz , "No classes created"
|
|
||||||
assert_equal :Object , clazz.super_class_name
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_creates_class_deriviation
|
|
||||||
vool = RubyXCompiler.ruby_to_vool "class Testing ; end"
|
|
||||||
mom = vool.to_mom(nil)
|
|
||||||
assert_equal Vool::ClassStatement , vool.class
|
|
||||||
#assert mom , "No classes created"
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_creates_class_with_deriviation
|
|
||||||
vool = RubyXCompiler.ruby_to_vool "class Test2 < List ;end"
|
|
||||||
vool.to_mom(nil)
|
|
||||||
clazz = Parfait.object_space.get_class_by_name(:Test2)
|
|
||||||
assert clazz, "No classes created"
|
|
||||||
assert_equal :List , clazz.super_class_name
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_space_is_unchanged_by_compile
|
def test_space_is_unchanged_by_compile
|
||||||
space1 = Parfait.object_space.get_class_by_name(:Space)
|
space1 = Parfait.object_space.get_class_by_name(:Space)
|
||||||
RubyXCompiler.ruby_to_vool "class Space ;end"
|
ruby_to_vool "class Space ;end"
|
||||||
space2 = Parfait.object_space.get_class_by_name(:Space)
|
space2 = Parfait.object_space.get_class_by_name(:Space)
|
||||||
assert_equal space1 , space2
|
assert_equal space1 , space2
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_space_type_is_unchanged_by_compile
|
def test_space_type_is_unchanged_by_compile
|
||||||
space1 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
space1 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
||||||
RubyXCompiler.ruby_to_vool "class Space ;end"
|
ruby_to_vool "class Space ;end"
|
||||||
space2 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
space2 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
||||||
assert_equal space1 , space2
|
assert_equal space1 , space2
|
||||||
end
|
end
|
||||||
|
45
test/rubyx/test_rubyx_compiler1.rb
Normal file
45
test/rubyx/test_rubyx_compiler1.rb
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
require_relative "../helper"
|
||||||
|
|
||||||
|
module RubyX
|
||||||
|
class TestVoolCompiler < MiniTest::Test
|
||||||
|
include ScopeHelper
|
||||||
|
|
||||||
|
def setup
|
||||||
|
Risc.machine.boot
|
||||||
|
end
|
||||||
|
def ruby_to_vool(input)
|
||||||
|
RubyXCompiler.ruby_to_vool(input)
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_creates_class_without_deriviation
|
||||||
|
vool = ruby_to_vool "class Testing ; end"
|
||||||
|
vool.to_mom(nil)
|
||||||
|
clazz = Parfait.object_space.get_class_by_name(:Testing)
|
||||||
|
assert clazz , "No classes created"
|
||||||
|
assert_equal :Object , clazz.super_class_name
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_creates_class_deriviation
|
||||||
|
vool = ruby_to_vool "class Testing ; end"
|
||||||
|
mom = vool.to_mom(nil)
|
||||||
|
assert_equal Vool::ClassStatement , vool.class
|
||||||
|
#assert mom , "No classes created"
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_creates_class_with_deriviation
|
||||||
|
vool = ruby_to_vool "class Test2 < List ;end"
|
||||||
|
vool.to_mom(nil)
|
||||||
|
clazz = Parfait.object_space.get_class_by_name(:Test2)
|
||||||
|
assert clazz, "No classes created"
|
||||||
|
assert_equal :List , clazz.super_class_name
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_space_type_is_unchanged_by_compile
|
||||||
|
space1 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
||||||
|
ruby_to_vool "class Space ;end"
|
||||||
|
space2 = Parfait.object_space.get_class_by_name(:Space).instance_type
|
||||||
|
assert_equal space1 , space2
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
module CompilerHelper
|
module ScopeHelper
|
||||||
|
|
||||||
def in_Test(statements)
|
def in_Test(statements)
|
||||||
"class Test ; #{statements} ; end"
|
"class Test ; #{statements} ; end"
|
||||||
@ -19,7 +19,7 @@ module CompilerHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
module MomCompile
|
module MomCompile
|
||||||
include CompilerHelper
|
include ScopeHelper
|
||||||
|
|
||||||
def compile_first_method( input )
|
def compile_first_method( input )
|
||||||
# works a lot like Vool.ruby_to_vool
|
# works a lot like Vool.ruby_to_vool
|
||||||
|
@ -4,7 +4,7 @@ require_relative "compiling"
|
|||||||
|
|
||||||
module Risc
|
module Risc
|
||||||
module Ticker
|
module Ticker
|
||||||
include CompilerHelper
|
include ScopeHelper
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
Risc.machine.boot
|
Risc.machine.boot
|
||||||
|
Loading…
Reference in New Issue
Block a user