-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce a new run operator expect
#1303
Conversation
// rollback to the previous state in any case | ||
this.recoverVars(savedVarsAfterAction) | ||
this.recoverNextVars(savedNextVarsAfterAction) | ||
this.resetTrace(just(rv.mkList(savedTraceAfterAction))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need the rollback if the effect is already preventing updates inside the expect argument? I found the "rollback" explanation in the documentation confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also not clear on why a rollback is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added clarifying comments about why we have to do that in the simulator
I think this should say |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Yeah, I keep typing |
Co-authored-by: Shon Feder <[email protected]>
Closes #1252. Following the discussion raised by @hvanz, I have implemented the operator
A.expect(P)
with the following semantics:A
:A
's result isfalse
, emit a runtime error.A
's result istrue
:P
:P
evaluates tofalse
, emit a runtime error (similar toassert
).P
evaluates totrue
, rollback to the previous state and returntrue
.Its semantics looks a bit complex, but this is basically what we want, if we do not want to have an extra stuttering step that calls
assert(P)
.Here are the examples from the unit tests:
CHANGELOG.md
for any new functionality