testing to_s on Code

This commit is contained in:
Torsten Ruger 2016-12-28 13:59:02 +02:00
parent a8f3d5a634
commit 266764be06
3 changed files with 5 additions and 2 deletions

View File

@ -21,7 +21,7 @@ module Typed
end end
class FalseExpression < Expression class FalseExpression < Expression
def to_s def to_s
false "false"
end end
end end
class NilExpression < Expression class NilExpression < Expression

View File

@ -6,6 +6,7 @@ module ExpressionHelper
Register.machine.boot unless Register.machine.booted Register.machine.boot unless Register.machine.booted
compiler = Typed::MethodCompiler.new Register.machine.space.get_main compiler = Typed::MethodCompiler.new Register.machine.space.get_main
code = Typed.ast_to_code @input code = Typed.ast_to_code @input
assert code.to_s , @input
produced = compiler.process( code ) produced = compiler.process( code )
assert @output , "No output given" assert @output , "No output given"
assert_equal produced.class , @output , "Wrong class" assert_equal produced.class , @output , "Wrong class"

View File

@ -13,7 +13,9 @@ module Statements
def check def check
assert @expect , "No output given" assert @expect , "No output given"
compiler = Typed::MethodCompiler.new compiler = Typed::MethodCompiler.new
produced = compiler.process( Typed.ast_to_code( @input) ) code = Typed.ast_to_code( @input )
assert code.to_s , @input
produced = compiler.process( code )
produced = Register.machine.space.get_main.instructions produced = Register.machine.space.get_main.instructions
compare_instructions produced , @expect compare_instructions produced , @expect
produced produced