mirror of
https://github.com/oh-my-fish/oh-my-fish.git
synced 2025-01-23 21:04:16 +08:00
Improve assertion error messages
This commit is contained in:
parent
148ce423ea
commit
58daae022b
|
@ -6,26 +6,26 @@ function assert.error_message
|
||||||
switch $number_of_arguments
|
switch $number_of_arguments
|
||||||
case 3
|
case 3
|
||||||
set operator (assert.expand_operator $argv[2])
|
set operator (assert.expand_operator $argv[2])
|
||||||
set expected $argv[3]
|
set actual $argv[3]
|
||||||
echo "Expected $expected to not be $operator"
|
echo "Expected result to not be $operator but it was $actual"
|
||||||
case 4
|
case 4
|
||||||
set expected $argv[2]
|
set expected $argv[2]
|
||||||
set operator "not" (assert.expand_operator $argv[3])
|
set operator "not" (assert.expand_operator $argv[3])
|
||||||
set actual $argv[4]
|
set actual $argv[4]
|
||||||
echo "Expected $expected to $operator $actual"
|
echo "Expected result to $operator $expected but it was $actual"
|
||||||
case \*
|
case \*
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
case \-\*
|
case \-\*
|
||||||
test $number_of_arguments != 2; and return 1
|
test $number_of_arguments != 2; and return 1
|
||||||
set operator (assert.expand_operator $argv[1])
|
set operator (assert.expand_operator $argv[1])
|
||||||
set expected $argv[2]
|
set actual $argv[2]
|
||||||
echo "Expected $expected to be $operator"
|
echo "Expected result to be $operator but it was $actual"
|
||||||
case \*
|
case \*
|
||||||
test $number_of_arguments != 3; and return 1
|
test $number_of_arguments != 3; and return 1
|
||||||
set expected $argv[1]
|
set expected $argv[1]
|
||||||
set operator (assert.expand_operator $argv[2])
|
set operator (assert.expand_operator $argv[2])
|
||||||
set actual $argv[3]
|
set actual $argv[3]
|
||||||
echo "Expected $expected to $operator $actual"
|
echo "Expected result to $operator $expected but it was $actual"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,12 +17,12 @@ function describe_assert_error_message
|
||||||
end
|
end
|
||||||
|
|
||||||
function it_supports_unary_operators
|
function it_supports_unary_operators
|
||||||
assert -z "string"
|
assert -z "abc"
|
||||||
|
|
||||||
# Reset test status
|
# Reset test status
|
||||||
set -e __current_spec_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
|
end
|
||||||
|
|
||||||
function it_supports_binary_operators
|
function it_supports_binary_operators
|
||||||
|
@ -31,7 +31,7 @@ function describe_assert_error_message
|
||||||
# Reset test status
|
# Reset test status
|
||||||
set -e __current_spec_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
|
end
|
||||||
|
|
||||||
function it_supports_inversion_on_unary_operators
|
function it_supports_inversion_on_unary_operators
|
||||||
|
@ -40,7 +40,7 @@ function describe_assert_error_message
|
||||||
# Reset test status
|
# Reset test status
|
||||||
set -e __current_spec_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
|
end
|
||||||
|
|
||||||
function it_supports_inversion_on_binary_operators
|
function it_supports_inversion_on_binary_operators
|
||||||
|
@ -49,6 +49,6 @@ function describe_assert_error_message
|
||||||
# Reset test status
|
# Reset test status
|
||||||
set -e __current_spec_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
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user