Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@myitcv
Copy link
Member

@myitcv myitcv commented Feb 12, 2020

No description provided.

@myitcv myitcv force-pushed the cmd_govim_must_func_include_error branch from ee7a8e9 to c6000d7 Compare February 13, 2020 11:29
@myitcv myitcv changed the title cmd/govim: make batch assertion signature Must(v, err) cmd/govim: refactor batch call/expr handling Feb 13, 2020
@myitcv myitcv requested a review from leitzler February 13, 2020 19:12
Copy link
Member

@leitzler leitzler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure, but it feels like we might want to at least log when a suppressed error occur. If so, we can add it in a future PR, this LGTM as a start.

To better express the fact that sometimes you want to handle when a
batch call fails (rather than asserting it must succeed), we split out
BatchEnd into two methods:

    BatchEnd() ([]json.RawMessage, error)
    MustBatchEnd() []json.RawMessage

MustBatchEnd retains the current semantics of panic-ing if an error is
returned by Vim in the course of evaluating the call/expression.

We extend the assertion capabillity of batch calls/expressions to
support ignoring of certain errors via s:mustBeErrorOrNil. This means
that the assertion functions within the VimScript shim need to be
parameterised. Hence the assertion functions defined in the VimScript
shim, e.g. s:mustBeZero, s:mustBeErrorOrNil and s:mustNoError, are
actually partial functions that return assertion functions.

As part of a related change, the assertion functions themselves now have
the following signature:

    func(v interface{}, err error) (bool, error)

(in Go terms). A non-type(v:none) error value is the caught value in
case an exception was thrown during the evaluation of the
call/expression. The value v is as before, the call return value or
expression result. This therefore allows the caller of a batch to assert
on both the error value and the return value.

Correspondingly, s:mustNothing becomes s:mustNoError, and we modify the
implementation of s:mustBeZero to assert no error value.
@myitcv myitcv force-pushed the cmd_govim_must_func_include_error branch from c6000d7 to ea9b2c4 Compare February 15, 2020 09:32
@myitcv
Copy link
Member Author

myitcv commented Feb 15, 2020

I added a ch_log statement. Easy to do; good catch. Thanks

@myitcv myitcv merged commit 4a614fd into master Feb 15, 2020
@myitcv myitcv deleted the cmd_govim_must_func_include_error branch February 15, 2020 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants