-
Notifications
You must be signed in to change notification settings - Fork 1
Test refactoring #23
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
base: master
Are you sure you want to change the base?
Test refactoring #23
Conversation
Implemented most tokens
…d refactored some tests to use utils
…th new as_tree and as_node_raw functions
…ser::expect_tree_eq
|
Requesting a review! @jalextowle |
jalextowle
left a comment
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.
Very nice job on this one. You're really shaping up to be our refactoring czar :)
src/utils.rs
Outdated
| * Fail a lexer test, given some expected and actual token. | ||
| */ | ||
| pub fn fail_test(expect: lex_4_25::Token, actual: lex_4_25::Token) { | ||
| panic!("Expected: {:?} | Actual: {:?}", expect, actual); |
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 think that this should use {#?} instead of {:?} so that we get pretty printing.
src/utils.rs
Outdated
| /** | ||
| * Fail a lexer test, given some expected and actual token. | ||
| */ | ||
| pub fn fail_test(expect: lex_4_25::Token, actual: lex_4_25::Token) { |
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.
Let's make this a generic function that takes T where T: Debug + PartialEq. This will allow us to use this function for every test we make.
src/utils.rs
Outdated
| * Advance cur in s using next_token, and check that the return matches | ||
| * the expected Token, t. If not, the test fails. | ||
| */ | ||
| pub fn expect_next_token(s: &Vec<char>, cur: &mut usize, t: lex_4_25::Token) { |
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.
If possible, let's try to avoid one-letter parameter names.
| * Given two ParseTrees, checks for equality. If unequal, | ||
| * panics and prints the prettified trees. | ||
| */ | ||
| pub fn expect_tree_eq(expect: parse_4_25::ParseTree, actual: parse_4_25::ParseTree) { |
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 like the formatting here. I'd say that we should adopt it in the fail_test function, and get rid of this function and expect_node_eq in favor of using the generic fail_test
No description provided.