more block tests

This commit is contained in:
Torsten Ruger 2018-07-21 12:51:20 +03:00
parent f620f0fd74
commit 84a6fb1aba
5 changed files with 29 additions and 6 deletions

View File

@ -6,7 +6,6 @@ module VoolBlocks
def setup def setup
Parfait.boot! Parfait.boot!
Risc::Builtin.boot_functions
@ins = compile_first_block( "local = 5") @ins = compile_first_block( "local = 5")
end end
@ -72,12 +71,12 @@ module VoolBlocks
Parfait.boot! Parfait.boot!
end end
def test_assigns_const def test_assigns_const
@ins = compile_first_method( "@a = 5") @ins = compile_first_block( "@a = 5")
assert_equal Mom::SlotLoad , @ins.class , @ins assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins assert_equal Mom::IntegerConstant , @ins.right.known_object.class , @ins
end end
def test_assigns_move def test_assigns_move
@ins = compile_first_method( "@a = arg") @ins = compile_first_block( "@a = arg")
assert_equal Mom::SlotLoad , @ins.class , @ins assert_equal Mom::SlotLoad , @ins.class , @ins
assert_equal Mom::SlotDefinition , @ins.right.class , @ins assert_equal Mom::SlotDefinition , @ins.right.class , @ins
end end

View File

@ -1,7 +1,7 @@
require_relative "helper" require_relative "helper"
module VoolBlocks module VoolBlocks
class TestConditionIfMom #< MiniTest::Test class TestConditionIfMom < MiniTest::Test
include MomCompile include MomCompile
include Mom include Mom

View File

@ -0,0 +1,26 @@
require_relative "helper"
module VoolBlocks
class TestSimpleWhileMom < MiniTest::Test
include MomCompile
include Mom
def setup
Parfait.boot!
@ins = compile_first_block( "while(@a) ; @a = 5 ; end")
end
def test_compiles_as_while
assert_equal Label , @ins.class , @ins
end
def test_condition_compiles_to_check
assert_equal TruthCheck , @ins.next.class , @ins
end
def test_condition_is_slot
assert_equal SlotDefinition , @ins.next.condition.class , @ins
end
def test_array
check_array [Label, TruthCheck, SlotLoad, Jump, Label], @ins
end
end
end

View File

@ -6,7 +6,6 @@ module Vool
def setup def setup
Parfait.boot! Parfait.boot!
Risc::Builtin.boot_functions
@ins = compile_first_method( "local = 5") @ins = compile_first_method( "local = 5")
end end

View File

@ -1,4 +1,3 @@
require_relative "helper" require_relative "helper"
module Vool module Vool