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