diff options
Diffstat (limited to 'runtime/doc/testing.txt')
-rw-r--r-- | runtime/doc/testing.txt | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/runtime/doc/testing.txt b/runtime/doc/testing.txt index ef5e179c86..2c1c77a51d 100644 --- a/runtime/doc/testing.txt +++ b/runtime/doc/testing.txt @@ -54,13 +54,14 @@ assert_beeps({cmd}) *assert_beeps()* assert_equal({expected}, {actual} [, {msg}]) When {expected} and {actual} are not equal an error message is added to |v:errors| and 1 is returned. Otherwise zero is - returned |assert-return|. + returned. |assert-return| + The error is in the form "Expected {expected} but got + {actual}". When {msg} is present it is prefixed to that. + There is no automatic conversion, the String "4" is different from the Number 4. And the number 4 is different from the Float 4.0. The value of 'ignorecase' is not used here, case always matters. - When {msg} is omitted an error in the form "Expected - {expected} but got {actual}" is produced. Example: > assert_equal('foo', 'bar') < Will result in a string to be added to |v:errors|: @@ -134,11 +135,12 @@ assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]]) assert_false({actual} [, {msg}]) *assert_false()* When {actual} is not false an error message is added to |v:errors|, like with |assert_equal()|. + The error is in the form "Expected False but got {actual}". + When {msg} is present it is prepended to that. Also see |assert-return|. + A value is false when it is zero. When {actual} is not a number the assert fails. - When {msg} is omitted an error in the form - "Expected False but got {actual}" is produced. Can also be used as a |method|: > GetResult()->assert_false() @@ -147,14 +149,16 @@ assert_inrange({lower}, {upper}, {actual} [, {msg}]) *assert_inrange()* This asserts number and |Float| values. When {actual} is lower than {lower} or higher than {upper} an error message is added to |v:errors|. Also see |assert-return|. - When {msg} is omitted an error in the form - "Expected range {lower} - {upper}, but got {actual}" is - produced. + The error is in the form "Expected range {lower} - {upper}, + but got {actual}". When {msg} is present it is prefixed to + that. *assert_match()* assert_match({pattern}, {actual} [, {msg}]) When {pattern} does not match {actual} an error message is added to |v:errors|. Also see |assert-return|. + The error is in the form "Pattern {pattern} does not match + {actual}". When {msg} is present it is prefixed to that. {pattern} is used as with |expr-=~|: The matching is always done like 'magic' was set and 'cpoptions' is empty, no matter what @@ -164,8 +168,6 @@ assert_match({pattern}, {actual} [, {msg}]) Use "^" and "$" to match with the start and end of the text. Use both to match the whole text. - When {msg} is omitted an error in the form - "Pattern {pattern} does not match {actual}" is produced. Example: > assert_match('^f.*o$', 'foobar') < Will result in a string to be added to |v:errors|: @@ -215,8 +217,7 @@ assert_true({actual} [, {msg}]) *assert_true()* Also see |assert-return|. A value is |TRUE| when it is a non-zero number or |v:true|. When {actual} is not a number or |v:true| the assert fails. - When {msg} is omitted an error in the form "Expected True but - got {actual}" is produced. + When {msg} is given it precedes the default message. Can also be used as a |method|: > GetResult()->assert_true() |