2018-04-19 19:59:48 +03:00
|
|
|
|
2020-03-28 12:25:53 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Mains
|
|
|
|
class MathsTester < MiniTest::Test
|
|
|
|
include MainsHelper
|
2018-04-19 19:59:48 +03:00
|
|
|
|
|
|
|
def test_add
|
2019-09-24 21:20:12 +03:00
|
|
|
@preload = "Integer.plus"
|
2018-05-25 20:40:39 +03:00
|
|
|
run_main_return "5 + 5"
|
2020-03-28 12:25:53 +02:00
|
|
|
assert_result 10 , ""
|
2018-04-19 19:59:48 +03:00
|
|
|
end
|
2018-05-25 20:40:39 +03:00
|
|
|
def test_minus
|
2019-09-24 21:20:12 +03:00
|
|
|
@preload = "Integer.minus"
|
2018-05-25 20:40:39 +03:00
|
|
|
run_main_return "5 - 5"
|
2020-03-28 12:25:53 +02:00
|
|
|
assert_result 0 , ""
|
2018-04-19 19:59:48 +03:00
|
|
|
end
|
2018-05-25 20:40:39 +03:00
|
|
|
def test_minus_neg
|
2019-09-24 21:20:12 +03:00
|
|
|
@preload = "Integer.minus"
|
2018-05-25 20:40:39 +03:00
|
|
|
run_main_return "5 - 15"
|
2020-03-28 19:46:07 +02:00
|
|
|
assert_result( 246 , "")
|
2018-04-19 19:59:48 +03:00
|
|
|
end
|
2018-05-25 20:40:39 +03:00
|
|
|
def test_rshift
|
2019-09-24 21:20:12 +03:00
|
|
|
@preload = "Integer.rs"
|
2018-05-25 20:40:39 +03:00
|
|
|
run_main_return "#{2**8} >> 3"
|
2020-03-28 12:25:53 +02:00
|
|
|
assert_result 2**5 , ""
|
2018-04-20 10:27:06 +03:00
|
|
|
end
|
2018-05-25 20:40:39 +03:00
|
|
|
def test_lshift
|
2019-09-24 21:20:12 +03:00
|
|
|
@preload = "Integer.ls"
|
2018-05-25 20:40:39 +03:00
|
|
|
run_main_return "#{2**8} << 3"
|
2020-03-28 19:46:07 +02:00
|
|
|
assert_result 0 , ""
|
2018-04-20 10:27:06 +03:00
|
|
|
end
|
2018-05-25 20:40:39 +03:00
|
|
|
def test_div10
|
2019-09-24 21:20:12 +03:00
|
|
|
@preload = "Integer.div10"
|
2018-05-25 20:40:39 +03:00
|
|
|
run_main_return "45.div10"
|
2020-03-28 12:25:53 +02:00
|
|
|
assert_result 4 , ""
|
2018-04-19 19:59:48 +03:00
|
|
|
end
|
2018-05-25 20:40:39 +03:00
|
|
|
def test_div4
|
2019-09-24 21:20:12 +03:00
|
|
|
@preload = "Integer.div4"
|
2018-05-25 20:40:39 +03:00
|
|
|
run_main_return "45.div4"
|
2020-03-28 12:25:53 +02:00
|
|
|
assert_result 11 , ""
|
2018-04-19 19:59:48 +03:00
|
|
|
end
|
2018-05-25 20:40:39 +03:00
|
|
|
def test_mult
|
2019-09-24 21:20:12 +03:00
|
|
|
@preload = "Integer.mul"
|
2018-05-25 20:40:39 +03:00
|
|
|
run_main_return "4 * 4"
|
2020-03-28 12:25:53 +02:00
|
|
|
assert_result 16 , ""
|
2018-04-19 19:59:48 +03:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|