improve fragment checks
This commit is contained in:
parent
024e6cb389
commit
530537de1a
@ -1,6 +1,7 @@
|
||||
module CodeChecker
|
||||
def check
|
||||
Virtual.machine.boot.parse_and_compile @string_input
|
||||
machine = Virtual.machine.boot
|
||||
machine.parse_and_compile @string_input
|
||||
produced = Virtual.machine.space.get_main.source
|
||||
assert @output , "No output given"
|
||||
assert_equal @output.length , produced.blocks.length , "Block length"
|
||||
|
@ -7,13 +7,19 @@ require_relative '../helper'
|
||||
module Fragments
|
||||
|
||||
def check
|
||||
statements = Virtual.machine.boot.parse_and_compile @string_input
|
||||
@expect.each_with_index do | should , i |
|
||||
exp_i = statements[i]
|
||||
assert exp_i.is_a?(Virtual::Slot) , "compiles should return #{should}, not #{exp_i}"
|
||||
assert_equal should , exp_i.class
|
||||
machine = Virtual.machine.boot
|
||||
machine.parse_and_compile @string_input
|
||||
produced = Virtual.machine.space.get_main.source
|
||||
assert @expect , "No output given"
|
||||
assert_equal @expect.length , produced.blocks.length , "Block length"
|
||||
produced.blocks.each_with_index do |b,i|
|
||||
codes = @expect[i]
|
||||
assert codes , "No codes for block #{i}"
|
||||
assert_equal b.codes.length , codes.length , "Code length for block #{i+1}"
|
||||
b.codes.each_with_index do |c , ii |
|
||||
assert_equal codes[ii] , c.class , "Block #{i+1} , code #{ii+1}"
|
||||
end
|
||||
end
|
||||
# Virtual.machine.run_passes
|
||||
end
|
||||
|
||||
# helper to write the file
|
||||
|
@ -11,7 +11,7 @@ class Bar
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [ Virtual::Return ]
|
||||
@expect = [ [Virtual::MethodEnter] ,[Virtual::MethodReturn]]
|
||||
check
|
||||
end
|
||||
|
||||
|
@ -16,7 +16,8 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [ Virtual::Return ]
|
||||
@expect = [ [Virtual::MethodEnter,Virtual::NewMessage,Virtual::Set,Virtual::Set,
|
||||
Virtual::Set,Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
|
||||
check
|
||||
end
|
||||
|
||||
|
@ -35,7 +35,8 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Virtual::Return ]
|
||||
@expect = [[Virtual::MethodEnter,Virtual::NewMessage,Virtual::Set,Virtual::Set,Virtual::MethodCall] ,
|
||||
[Virtual::MethodReturn]]
|
||||
check
|
||||
|
||||
end
|
||||
|
@ -11,7 +11,8 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = []
|
||||
@expect = [[Virtual::MethodEnter,Virtual::Set,Virtual::NewMessage,Virtual::Set,
|
||||
Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn]]
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -16,7 +16,9 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Virtual::Return ]
|
||||
@expect = [[Virtual::MethodEnter,Virtual::Set,Virtual::Set,Register::GetSlot,
|
||||
Register::GetSlot,Register::OperatorInstruction,Register::IsZeroBranch] ,
|
||||
[Virtual::Set,Register::AlwaysBranch] ,[Virtual::Set] ,[] ,[Virtual::MethodReturn] ]
|
||||
check
|
||||
end
|
||||
|
||||
@ -28,7 +30,7 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Virtual::Return ]
|
||||
@expect = [[Virtual::MethodEnter,Virtual::Set] , [Virtual::MethodReturn]]
|
||||
check
|
||||
end
|
||||
|
||||
@ -49,7 +51,8 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Virtual::Return ]
|
||||
@expect = [ [Virtual::MethodEnter,Virtual::NewMessage,Virtual::Set,Virtual::Set,
|
||||
Virtual::Set,Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -11,7 +11,8 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = []
|
||||
@expect = [ [Virtual::MethodEnter,Virtual::Set,Virtual::NewMessage,Virtual::Set,
|
||||
Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -27,7 +27,8 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Virtual::Return ]
|
||||
@expect = [[Virtual::MethodEnter,Virtual::NewMessage,Virtual::Set,Virtual::Set,
|
||||
Virtual::Set,Virtual::Set,Virtual::MethodCall] , [Virtual::MethodReturn]]
|
||||
check
|
||||
end
|
||||
end
|
||||
|
@ -24,7 +24,8 @@ class Object
|
||||
end
|
||||
end
|
||||
HERE
|
||||
@expect = [Virtual::Return ]
|
||||
@expect = [ [Virtual::MethodEnter,Virtual::NewMessage,Virtual::Set,Virtual::Set,
|
||||
Virtual::Set,Virtual::Set,Virtual::MethodCall] ,[Virtual::MethodReturn] ]
|
||||
check
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user