Commit 58daae02 authored by Bruno Pinto's avatar Bruno Pinto

Improve assertion error messages

parent 148ce423
......@@ -6,26 +6,26 @@ function assert.error_message
switch $number_of_arguments
case 3
set operator (assert.expand_operator $argv[2])
set expected $argv[3]
echo "Expected $expected to not be $operator"
set actual $argv[3]
echo "Expected result to not be $operator but it was $actual"
case 4
set expected $argv[2]
set operator "not" (assert.expand_operator $argv[3])
set actual $argv[4]
echo "Expected $expected to $operator $actual"
echo "Expected result to $operator $expected but it was $actual"
case \*
return 1
end
case \-\*
test $number_of_arguments != 2; and return 1
set operator (assert.expand_operator $argv[1])
set expected $argv[2]
echo "Expected $expected to be $operator"
set actual $argv[2]
echo "Expected result to be $operator but it was $actual"
case \*
test $number_of_arguments != 3; and return 1
set expected $argv[1]
set operator (assert.expand_operator $argv[2])
set actual $argv[3]
echo "Expected $expected to $operator $actual"
echo "Expected result to $operator $expected but it was $actual"
end
end
......@@ -17,12 +17,12 @@ function describe_assert_error_message
end
function it_supports_unary_operators
assert -z "string"
assert -z "abc"
# Reset test status
set -e __current_spec_status
assert 'Expected string to be empty' = "$__current_spec_output"
assert 'Expected result to be empty but it was abc' = "$__current_spec_output"
end
function it_supports_binary_operators
......@@ -31,7 +31,7 @@ function describe_assert_error_message
# Reset test status
set -e __current_spec_status
assert 'Expected 1 to equals 2' = "$__current_spec_output"
assert 'Expected result to equals 1 but it was 2' = "$__current_spec_output"
end
function it_supports_inversion_on_unary_operators
......@@ -40,7 +40,7 @@ function describe_assert_error_message
# Reset test status
set -e __current_spec_status
assert 'Expected to not be empty' = "$__current_spec_output"
assert 'Expected result to not be empty but it was ' = "$__current_spec_output"
end
function it_supports_inversion_on_binary_operators
......@@ -49,6 +49,6 @@ function describe_assert_error_message
# Reset test status
set -e __current_spec_status
assert 'Expected 1 to not equals 1' = "$__current_spec_output"
assert 'Expected result to not equals 1 but it was 1' = "$__current_spec_output"
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment