modules/test: provide access to expect function

Allow `test.warnings` and `test.assertions` to be defined as either a
list, or a function coerced to a list.

When defined as a function, it is supplied an `expect` function which
provides some syntactic-sugar for defining simple expectations.

This is an alternative to the current approach of defining that `expect`
function on an ad-hoc basis.

I prefer this to adding `expect` to nixvim's lib because:
1. That would require having access to `lib`
2. IDK where in `lib` such a specialized function should live
This commit is contained in:
Matt Sturgeon 2025-01-17 01:34:52 +00:00
parent 16662760a9
commit ff29c97723
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
3 changed files with 47 additions and 12 deletions

View file

@ -1,8 +1,6 @@
let
expect = expect: value: { inherit expect value; };
# This plugin is deprecated
warnings = [
warnings = expect: [
(expect "count" 1)
(expect "any" "this plugin is obsolete and will be removed after 24.11.")
];

View file

@ -1,8 +1,6 @@
let
expect = expect: value: { inherit expect value; };
# This plugin is deprecated
warnings = [
warnings = expect: [
(expect "count" 1)
(expect "any" "The `rust-tools` project has been abandoned.")
];