Home Explore Blog CI



neovim

5th chunk of `runtime/doc/vimfn.txt`
46eb561ddd2651b0310fc4afee45127fe9742f83d59c64be0000000100000fcc
               Parameters: ~
                  • {cmd} (`string`)
                  • {error} (`any?`)
                  • {msg} (`any?`)
                  • {lnum} (`integer?`)
                  • {context} (`any?`)

                Return: ~
                  (`0|1`)

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 prefixed to that, along with the
		location of the assert when run from a script.
		Also see |assert-return|.

		A value is false when it is zero. When {actual} is not a
		number the assert fails.

                Parameters: ~
                  • {actual} (`any`)
                  • {msg} (`any?`)

                Return: ~
                  (`0|1`)

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|.
		The error is in the form "Expected range {lower} - {upper},
		but got {actual}".  When {msg} is present it is prefixed to
		that.

                Parameters: ~
                  • {lower} (`number`)
                  • {upper} (`number`)
                  • {actual} (`number`)
                  • {msg} (`string?`)

                Return: ~
                  (`0|1`)

assert_match({pattern}, {actual} [, {msg}])                     *assert_match()*
		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,
		along with the location of the assert when run from a script.

		{pattern} is used as with |expr-=~|: The matching is always done
		like 'magic' was set and 'cpoptions' is empty, no matter what
		the actual value of 'magic' or 'cpoptions' is.

		{actual} is used as a string, automatic conversion applies.
		Use "^" and "$" to match with the start and end of the text.
		Use both to match the whole text.

		Example: >vim
			call assert_match('^f.*o$', 'foobar')
<		Will result in a string to be added to |v:errors|:
			test.vim line 12: Pattern '^f.*o$' does not match 'foobar' ~

                Parameters: ~
                  • {pattern} (`string`)
                  • {actual} (`string`)
                  • {msg} (`string?`)

                Return: ~
                  (`0|1`)

assert_nobeep({cmd})                                           *assert_nobeep()*
		Run {cmd} and add an error message to |v:errors| if it
		produces a beep or visual bell.
		Also see |assert_beeps()|.

                Parameters: ~
                  • {cmd} (`string`)

                Return: ~
                  (`0|1`)

assert_notequal({expected}, {actual} [, {msg}])              *assert_notequal()*
		The opposite of `assert_equal()`: add an error message to
		|v:errors| when {expected} and {actual} are equal.
		Also see |assert-return|.

                Parameters: ~
                  • {expected} (`any`)
                  • {actual} (`any`)
                  • {msg} (`any?`)

                Return: ~
                  (`0|1`)

assert_notmatch({pattern}, {actual} [, {msg}])               *assert_notmatch()*
		The opposite of `assert_match()`: add an error message to
		|v:errors| when {pattern} matches {actual}.
		Also see |assert-return|.

                Parameters: ~
                  • {pattern} (`string`)
                  • {actual} (`string`)
                  • {msg} (`string?`)

                Return: ~
                  (`0|1`)

assert_report({msg})                                           *assert_report()*
		Report a test failure directly, using String {msg}.
		Always returns one.

                Parameters: ~
                  • {msg}

Title: Vimscript Built-in Functions: `assert_false()`, `assert_inrange()`, `assert_match()`, `assert_nobeep()`, `assert_notequal()`, `assert_notmatch()`, and `assert_report()`
Summary
This section of the Vimscript documentation details the `assert_false()`, `assert_inrange()`, `assert_match()`, `assert_nobeep()`, `assert_notequal()`, `assert_notmatch()`, and `assert_report()` functions. Each function's syntax, parameters, and return values are provided. `assert_false()` checks if a value is false (zero). `assert_inrange()` verifies if a number falls within a specified range. `assert_match()` checks if a pattern matches a string. `assert_nobeep()` checks if a command produces a beep. `assert_notequal()` is the opposite of `assert_equal()`. `assert_notmatch()` is the opposite of `assert_match()`. `assert_report()` reports a test failure directly, using a string.