fix interpreter overflow issue
flag set for bigness, result reduced tests for + and * fixed fibs tests
This commit is contained in:
@ -21,6 +21,11 @@ module Ticker
|
||||
end
|
||||
end
|
||||
|
||||
def check_return val
|
||||
assert_equal Parfait::Message , @interpreter.get_register(:r0).class
|
||||
assert_equal val , @interpreter.get_register(:r0).return_value
|
||||
end
|
||||
|
||||
def ticks num
|
||||
last = nil
|
||||
num.times do
|
||||
|
@ -1,4 +1,5 @@
|
||||
require_relative "test_add"
|
||||
require_relative "test_if"
|
||||
require_relative "test_puts"
|
||||
require_relative "test_ops"
|
||||
require_relative "test_plus"
|
||||
require_relative "test_mult"
|
||||
|
@ -1,6 +1,6 @@
|
||||
require_relative "helper"
|
||||
|
||||
class AddTest < MiniTest::Test
|
||||
class IfTest < MiniTest::Test
|
||||
include Ticker
|
||||
|
||||
def setup
|
||||
|
@ -1,6 +1,6 @@
|
||||
require_relative "helper"
|
||||
|
||||
class AddTest < MiniTest::Test
|
||||
class MultTest < MiniTest::Test
|
||||
include Ticker
|
||||
include AST::Sexp
|
||||
|
||||
@ -8,35 +8,29 @@ class AddTest < MiniTest::Test
|
||||
@string_input = <<HERE
|
||||
class Object
|
||||
int main()
|
||||
return 5 + 10
|
||||
return #{2**31} * #{2**31}
|
||||
end
|
||||
end
|
||||
HERE
|
||||
super
|
||||
end
|
||||
|
||||
def test_add
|
||||
#show_ticks # get output of what is
|
||||
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
|
||||
"LoadConstant","SetSlot","FunctionCall","Label","LoadConstant",
|
||||
"LoadConstant","OperatorInstruction","SetSlot","Label","FunctionReturn",
|
||||
"RegisterTransfer","Syscall","NilClass"]
|
||||
end
|
||||
|
||||
def test_mult
|
||||
@string_input = <<HERE
|
||||
class Object
|
||||
int main()
|
||||
return 5 * 10
|
||||
end
|
||||
end
|
||||
HERE
|
||||
setup
|
||||
#show_ticks # get output of what is
|
||||
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
|
||||
"LoadConstant","SetSlot","FunctionCall","Label","LoadConstant",
|
||||
"LoadConstant","OperatorInstruction","SetSlot","Label","FunctionReturn",
|
||||
"RegisterTransfer","Syscall","NilClass"]
|
||||
check_return 0
|
||||
end
|
||||
def test_overflow
|
||||
ticks( 12 )
|
||||
assert @interpreter.flags[:overflow]
|
||||
end
|
||||
|
||||
def test_zero
|
||||
ticks( 12 )
|
||||
assert @interpreter.flags[:zero]
|
||||
end
|
||||
|
||||
end
|
35
test/interpreter/test_plus.rb
Normal file
35
test/interpreter/test_plus.rb
Normal file
@ -0,0 +1,35 @@
|
||||
require_relative "helper"
|
||||
|
||||
class PlusTest < MiniTest::Test
|
||||
include Ticker
|
||||
|
||||
def setup
|
||||
@string_input = <<HERE
|
||||
class Object
|
||||
int main()
|
||||
return #{2**62 - 1} + 1
|
||||
end
|
||||
end
|
||||
HERE
|
||||
super
|
||||
end
|
||||
|
||||
def test_add
|
||||
#show_ticks # get output of what is
|
||||
check_chain ["Branch","Label","LoadConstant","GetSlot","SetSlot",
|
||||
"LoadConstant","SetSlot","FunctionCall","Label","LoadConstant",
|
||||
"LoadConstant","OperatorInstruction","SetSlot","Label","FunctionReturn",
|
||||
"RegisterTransfer","Syscall","NilClass"]
|
||||
check_return 0
|
||||
end
|
||||
|
||||
def test_overflow
|
||||
ticks( 12 )
|
||||
assert @interpreter.flags[:overflow]
|
||||
end
|
||||
|
||||
def test_zero
|
||||
ticks( 12 )
|
||||
assert @interpreter.flags[:zero]
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user