adding integer compare tests and fixing returns
true, false and nll were not handled correctly as returns returns assume int, and reduce. The solution (hack?) is to add fake numbers into true,false and nil that get returned from from the arm syscall (and it works!, which means i can fix other tests now)
This commit is contained in:
60
test/mains/test_int_cmp.rb
Normal file
60
test/mains/test_int_cmp.rb
Normal file
@ -0,0 +1,60 @@
|
||||
require_relative "helper"
|
||||
|
||||
module Mains
|
||||
class CompareTester < MiniTest::Test
|
||||
include MainsHelper
|
||||
def setup
|
||||
super
|
||||
@preload = [:le,:ge,:gt,:lt].collect{|op| "Integer.#{op}"}.join(";")
|
||||
end
|
||||
|
||||
def test_smaller_true
|
||||
run_main_return "4 < 5"
|
||||
assert_result 1 , ""
|
||||
end
|
||||
def test_smaller_false
|
||||
run_main_return "6 < 5"
|
||||
assert_result 0 , ""
|
||||
end
|
||||
def test_smaller_false_same
|
||||
run_main_return "5 < 5"
|
||||
assert_result 0 , ""
|
||||
end
|
||||
def test_larger_true
|
||||
run_main_return "5 > 4"
|
||||
assert_result 1 , ""
|
||||
end
|
||||
def test_larger_false
|
||||
run_main_return "5 > 6"
|
||||
assert_result 0 , ""
|
||||
end
|
||||
def test_larger_false_same
|
||||
run_main_return "5 > 5"
|
||||
assert_result 0 , ""
|
||||
end
|
||||
def test_smaller_or_true
|
||||
run_main_return "4 <= 5"
|
||||
assert_result 1 , ""
|
||||
end
|
||||
def test_smaller_or_false
|
||||
run_main_return "6 <= 5"
|
||||
assert_result 0 , ""
|
||||
end
|
||||
def test_smaller_or_same
|
||||
run_main_return "5 <= 5"
|
||||
assert_result 1 , ""
|
||||
end
|
||||
def test_larger_or_true
|
||||
run_main_return "5 >= 4"
|
||||
assert_result 1 , ""
|
||||
end
|
||||
def test_larger_or_false
|
||||
run_main_return "5 >= 6"
|
||||
assert_result 0 , ""
|
||||
end
|
||||
def test_larger_or_same
|
||||
run_main_return "5 >= 5"
|
||||
assert_result 1 , ""
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user