implement larger/smaller or equal
This commit is contained in:
58
test/risc/builtin/test_int_cmp.rb
Normal file
58
test/risc/builtin/test_int_cmp.rb
Normal file
@ -0,0 +1,58 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Risc
|
||||
module Builtin
|
||||
class IntCmp < BuiltinTest
|
||||
|
||||
def test_smaller_true
|
||||
run_input "4 < 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_smaller_false
|
||||
run_input "6 < 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_smaller_false_same
|
||||
run_input "5 < 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_larger_true
|
||||
run_input "5 > 4"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_larger_false
|
||||
run_input "5 > 6"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_larger_false_same
|
||||
run_input "5 > 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
|
||||
def test_smaller_or_true
|
||||
run_input "4 <= 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_smaller_or_false
|
||||
run_input "6 <= 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_smaller_or_same
|
||||
run_input "5 <= 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_larger_or_true
|
||||
run_input "5 >= 4"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_larger_or_false
|
||||
run_input "5 >= 6"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_larger_or_same
|
||||
run_input "5 >= 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -2,7 +2,7 @@ require_relative "helper"
|
||||
|
||||
module Risc
|
||||
module Builtin
|
||||
class SimpleInt < BuiltinTest
|
||||
class IntMath < BuiltinTest
|
||||
|
||||
def test_add
|
||||
run_input "5 + 5"
|
||||
@ -37,30 +37,6 @@ module Risc
|
||||
run_input "4 * 4"
|
||||
assert_equal 16 , get_return.value
|
||||
end
|
||||
def test_smaller_true
|
||||
run_input "4 < 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_smaller_false
|
||||
run_input "6 < 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_smaller_false_same
|
||||
run_input "5 < 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_larger_true
|
||||
run_input "5 > 4"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_larger_false
|
||||
run_input "5 > 6"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_larger_false_same
|
||||
run_input "5 > 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user