-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
tests: add check_output test helper #1458
Conversation
Maybe it would be good to allow the execution of intermediate instructions between tests. That way we could cleanup some tests like: let mut context = Context::new();
let init = r#"
var iterator = [1, 2, 3].keys();
var next = iterator.next();
"#;
forward(&mut context, init);
assert_eq!(forward(&mut context, "next.value"), "0");
assert_eq!(forward(&mut context, "next.done"), "false");
forward(&mut context, "next = iterator.next()");
assert_eq!(forward(&mut context, "next.value"), "1");
assert_eq!(forward(&mut context, "next.done"), "false"); I'd suggest creating a let init = r#"
var iterator = [1, 2, 3].keys();
var next = iterator.next();
"#;
check_output(
&[
TestAction::Execute(init),
TestAction::TestEq(("next.value", "0")),
TestAction::TestEq(("next.done", "false")),
TestAction::Execute("next = iterator.next()"),
TestAction::TestEq(("next.value", "1")),
TestAction::TestEq(("next.done", "false")),
]
) Notice how we don't need the |
Co-authored-by: jedel1043 <jedel0124@gmail.com>
Sure, I can rework it to your suggestion |
@jedel1043 I applied your suggestion, please let me know if this is satisfactory. Once everyone's happy with this helper I can migrate more cases to use it (maybe across several PRs as there are ~1500 occurrences). |
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.
This looks really good! We can merge this as is and refactor more in future PRs
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.
Just a small nitpick about the test counter. Everything else is pretty good! We should be able to extend TestAction
in case we find more common use cases.
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.
Looks great to me!
Towards #803