bit of renaming and a string test
This commit is contained in:
5
test/risc/builtin/README.md
Normal file
5
test/risc/builtin/README.md
Normal file
@ -0,0 +1,5 @@
|
||||
# Builtin Testing
|
||||
|
||||
Basically test builtin methods by their output.
|
||||
|
||||
Currently through Interpreter only
|
@ -5,52 +5,52 @@ module Risc
|
||||
class IntCmp < BuiltinTest
|
||||
|
||||
def test_smaller_true
|
||||
run_input "4 < 5"
|
||||
run_main "4 < 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_smaller_false
|
||||
run_input "6 < 5"
|
||||
run_main "6 < 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_smaller_false_same
|
||||
run_input "5 < 5"
|
||||
run_main "5 < 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_larger_true
|
||||
run_input "5 > 4"
|
||||
run_main "5 > 4"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_larger_false
|
||||
run_input "5 > 6"
|
||||
run_main "5 > 6"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_larger_false_same
|
||||
run_input "5 > 5"
|
||||
run_main "5 > 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
|
||||
def test_smaller_or_true
|
||||
run_input "4 <= 5"
|
||||
run_main "4 <= 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_smaller_or_false
|
||||
run_input "6 <= 5"
|
||||
run_main "6 <= 5"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_smaller_or_same
|
||||
run_input "5 <= 5"
|
||||
run_main "5 <= 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_larger_or_true
|
||||
run_input "5 >= 4"
|
||||
run_main "5 >= 4"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
def test_larger_or_false
|
||||
run_input "5 >= 6"
|
||||
run_main "5 >= 6"
|
||||
assert_equal Parfait::FalseClass , get_return.class
|
||||
end
|
||||
def test_larger_or_same
|
||||
run_input "5 >= 5"
|
||||
run_main "5 >= 5"
|
||||
assert_equal Parfait::TrueClass , get_return.class
|
||||
end
|
||||
end
|
||||
|
@ -5,36 +5,36 @@ module Risc
|
||||
class IntMath < BuiltinTest
|
||||
|
||||
def test_add
|
||||
run_input "5 + 5"
|
||||
run_main "5 + 5"
|
||||
assert_equal Parfait::Integer , get_return.class
|
||||
assert_equal 10 , get_return.value
|
||||
end
|
||||
def test_minus
|
||||
run_input "5 - 5"
|
||||
run_main "5 - 5"
|
||||
assert_equal 0 , get_return.value
|
||||
end
|
||||
def test_minus_neg
|
||||
run_input "5 - 15"
|
||||
run_main "5 - 15"
|
||||
assert_equal -10 , get_return.value
|
||||
end
|
||||
def test_rshift
|
||||
run_input "#{2**8} >> 3"
|
||||
run_main "#{2**8} >> 3"
|
||||
assert_equal 2**5 , get_return.value
|
||||
end
|
||||
def test_lshift
|
||||
run_input "#{2**8} << 3"
|
||||
run_main "#{2**8} << 3"
|
||||
assert_equal 2**11 , get_return.value
|
||||
end
|
||||
def test_div10
|
||||
run_input "45.div10"
|
||||
run_main "45.div10"
|
||||
assert_equal 4 , get_return.value
|
||||
end
|
||||
def test_div4
|
||||
run_input "45.div4"
|
||||
run_main "45.div4"
|
||||
assert_equal 11 , get_return.value
|
||||
end
|
||||
def test_mult
|
||||
run_input "4 * 4"
|
||||
run_main "4 * 4"
|
||||
assert_equal 16 , get_return.value
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user