rubyx/test/risc/interpreter/test_mult.rb

41 lines
964 B
Ruby
Raw Normal View History

require_relative "helper"
module Risc
2017-01-03 21:42:40 +01:00
class MultTest < MiniTest::Test
include Ticker
include AST::Sexp
2017-01-03 21:42:40 +01:00
def setup
@string_input = <<HERE
class Space
int main()
return #{2**31} * #{2**31}
end
end
HERE
2017-01-03 21:42:40 +01:00
@input = s(:statements, s(:return, s(:operator_value, :*, s(:int, 2147483648), s(:int, 2147483648))))
super
end
def pest_mult
2017-01-03 21:42:40 +01:00
#show_ticks # get output of what is
check_chain [Branch, Label, LoadConstant, SlotToReg, RegToSlot,
LoadConstant, RegToSlot, FunctionCall, Label, LoadConstant,
LoadConstant, OperatorInstruction, RegToSlot, LoadConstant, SlotToReg,
RegToSlot, Label, FunctionReturn, RiscTransfer, Syscall,
NilClass]
2017-01-03 21:42:40 +01:00
check_return 0
end
def pest_overflow
2017-01-03 21:42:40 +01:00
ticks( 12 )
assert @interpreter.flags[:overflow]
end
def pest_zero
2017-01-03 21:42:40 +01:00
ticks( 12 )
assert @interpreter.flags[:zero]
end
2017-01-03 21:42:40 +01:00
end
end