2019-08-12 23:13:29 +02:00
|
|
|
require_relative "../helper"
|
2018-04-19 18:59:48 +02:00
|
|
|
|
2019-08-12 23:13:29 +02:00
|
|
|
module Risc
|
2019-09-11 19:17:43 +02:00
|
|
|
module Macro
|
2019-08-12 23:13:29 +02:00
|
|
|
class IntMath < Minitest::Test
|
2019-08-12 11:36:32 +02:00
|
|
|
include Ticker
|
|
|
|
def setup
|
|
|
|
end
|
2018-04-19 18:59:48 +02:00
|
|
|
|
|
|
|
def test_add
|
2019-09-24 20:20:12 +02:00
|
|
|
@preload = "Integer.plus"
|
2018-05-25 19:40:39 +02:00
|
|
|
run_main_return "5 + 5"
|
2018-06-19 17:55:47 +02:00
|
|
|
assert_equal 10 , get_return
|
2018-04-19 18:59:48 +02:00
|
|
|
end
|
2018-05-25 19:40:39 +02:00
|
|
|
def test_minus
|
2019-09-24 20:20:12 +02:00
|
|
|
@preload = "Integer.minus"
|
2018-05-25 19:40:39 +02:00
|
|
|
run_main_return "5 - 5"
|
2018-06-19 17:55:47 +02:00
|
|
|
assert_equal 0 , get_return
|
2018-04-19 18:59:48 +02:00
|
|
|
end
|
2018-05-25 19:40:39 +02:00
|
|
|
def test_minus_neg
|
2019-09-24 20:20:12 +02:00
|
|
|
@preload = "Integer.minus"
|
2018-05-25 19:40:39 +02:00
|
|
|
run_main_return "5 - 15"
|
2018-08-08 11:03:17 +02:00
|
|
|
assert_equal( -10 , get_return)
|
2018-04-19 18:59:48 +02:00
|
|
|
end
|
2018-05-25 19:40:39 +02:00
|
|
|
def test_rshift
|
2019-09-24 20:20:12 +02:00
|
|
|
@preload = "Integer.rs"
|
2018-05-25 19:40:39 +02:00
|
|
|
run_main_return "#{2**8} >> 3"
|
2018-06-19 17:55:47 +02:00
|
|
|
assert_equal 2**5 , get_return
|
2018-04-20 09:27:06 +02:00
|
|
|
end
|
2018-05-25 19:40:39 +02:00
|
|
|
def test_lshift
|
2019-09-24 20:20:12 +02:00
|
|
|
@preload = "Integer.ls"
|
2018-05-25 19:40:39 +02:00
|
|
|
run_main_return "#{2**8} << 3"
|
2018-06-19 17:55:47 +02:00
|
|
|
assert_equal 2**11 , get_return
|
2018-04-20 09:27:06 +02:00
|
|
|
end
|
2018-05-25 19:40:39 +02:00
|
|
|
def test_div10
|
2019-09-24 20:20:12 +02:00
|
|
|
@preload = "Integer.div10"
|
2018-05-25 19:40:39 +02:00
|
|
|
run_main_return "45.div10"
|
2018-06-19 17:55:47 +02:00
|
|
|
assert_equal 4 , get_return
|
2018-04-19 18:59:48 +02:00
|
|
|
end
|
2018-05-25 19:40:39 +02:00
|
|
|
def test_div4
|
2019-09-24 20:20:12 +02:00
|
|
|
@preload = "Integer.div4"
|
2018-05-25 19:40:39 +02:00
|
|
|
run_main_return "45.div4"
|
2018-06-19 17:55:47 +02:00
|
|
|
assert_equal 11 , get_return
|
2018-04-19 18:59:48 +02:00
|
|
|
end
|
2018-05-25 19:40:39 +02:00
|
|
|
def test_mult
|
2019-09-24 20:20:12 +02:00
|
|
|
@preload = "Integer.mul"
|
2018-05-25 19:40:39 +02:00
|
|
|
run_main_return "4 * 4"
|
2018-06-19 17:55:47 +02:00
|
|
|
assert_equal 16 , get_return
|
2018-04-19 18:59:48 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|