1
- *testing.txt* For Vim version 9.1. Last change: 2024 Jun 17
1
+ *testing.txt* For Vim version 9.1. Last change: 2024 Jul 18
2
2
3
3
4
4
VIM REFERENCE MANUAL by Bram Moolenaar
@@ -506,16 +506,17 @@ assert_equal({expected}, {actual} [, {msg}])
506
506
added to | v:errors | and 1 is returned. Otherwise zero is
507
507
returned. | assert-return |
508
508
The error is in the form "Expected {expected} but got
509
- {actual} ". When {msg} is present it is prefixed to that.
509
+ {actual} ". When {msg} is present it is prefixed to that,
510
+ along with the location of the assert when run from a script.
510
511
511
512
There is no automatic conversion, the String "4" is different
512
513
from the Number 4. And the number 4 is different from the
513
514
Float 4.0. The value of 'ignorecase' is not used here, case
514
515
always matters.
515
516
Example: >
516
- assert_equal('foo', 'bar')
517
- < Will result in a string to be added to | v:errors | :
518
- test.vim line 12: Expected 'foo' but got 'bar' ~
517
+ call assert_equal('foo', 'bar', 'baz ')
518
+ < Will add the following to | v:errors | :
519
+ test.vim line 12: baz : Expected 'foo' but got 'bar' ~
519
520
520
521
Can also be used as a | method | , the base is passed as the
521
522
second argument: >
@@ -561,19 +562,19 @@ assert_fails({cmd} [, {error} [, {msg} [, {lnum} [, {context}]]]])
561
562
When {error} is a string it must be found literally in the
562
563
first reported error. Most often this will be the error code,
563
564
including the colon, e.g. "E123:". >
564
- assert_fails('bad cmd', 'E987:')
565
+ call assert_fails('bad cmd', 'E987:')
565
566
<
566
567
When {error} is a | List | with one or two strings, these are
567
568
used as patterns. The first pattern is matched against the
568
569
first reported error: >
569
- assert_fails('cmd', ['E987:.*expected bool'])
570
+ call assert_fails('cmd', ['E987:.*expected bool'])
570
571
< The second pattern, if present, is matched against the last
571
572
reported error.
572
573
If there is only one error then both patterns must match. This
573
574
can be used to check that there is only one error.
574
575
To only match the last error use an empty string for the first
575
576
error: >
576
- assert_fails('cmd', ['', 'E987:'])
577
+ call assert_fails('cmd', ['', 'E987:'])
577
578
<
578
579
If {msg} is empty then it is not used. Do this to get the
579
580
default message when passing the {lnum} argument.
@@ -599,7 +600,8 @@ assert_false({actual} [, {msg}]) *assert_false()*
599
600
When {actual} is not false an error message is added to
600
601
| v:errors | , like with | assert_equal() | .
601
602
The error is in the form "Expected False but got {actual} ".
602
- When {msg} is present it is prepended to that.
603
+ When {msg} is present it is prefixed to that, along with the
604
+ location of the assert when run from a script.
603
605
Also see | assert-return | .
604
606
605
607
A value is false when it is zero. When {actual} is not a
@@ -625,7 +627,8 @@ assert_match({pattern}, {actual} [, {msg}])
625
627
When {pattern} does not match {actual} an error message is
626
628
added to | v:errors | . Also see | assert-return | .
627
629
The error is in the form "Pattern {pattern} does not match
628
- {actual} ". When {msg} is present it is prefixed to that.
630
+ {actual} ". When {msg} is present it is prefixed to that,
631
+ along with the location of the assert when run from a script.
629
632
630
633
{pattern} is used as with | =~ | : The matching is always done
631
634
like 'magic' was set and 'cpoptions' is empty, no matter what
@@ -636,9 +639,9 @@ assert_match({pattern}, {actual} [, {msg}])
636
639
Use both to match the whole text.
637
640
638
641
Example: >
639
- assert_match('^f.*o$', 'foobar')
642
+ call assert_match('^f.*o$', 'foobar')
640
643
< Will result in a string to be added to | v:errors | :
641
- test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
644
+ test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~
642
645
643
646
Can also be used as a | method | : >
644
647
getFile()->assert_match('foo.*')
@@ -693,7 +696,8 @@ assert_true({actual} [, {msg}]) *assert_true()*
693
696
Also see | assert-return | .
694
697
A value is TRUE when it is a non-zero number. When {actual}
695
698
is not a number the assert fails.
696
- When {msg} is given it precedes the default message.
699
+ When {msg} is given it is prefixed to the default message,
700
+ along with the location of the assert when run from a script.
697
701
698
702
Can also be used as a | method | : >
699
703
GetResult()->assert_true()
0 commit comments