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.
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.
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.
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.
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.
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.