Skip to content

Conversation

@wadealexc
Copy link
Collaborator

No description provided.

@wadealexc wadealexc changed the title [WIP] Test refactoring Test refactoring Jun 16, 2019
@wadealexc wadealexc requested a review from jalextowle June 16, 2019 11:42
@wadealexc
Copy link
Collaborator Author

Requesting a review! @jalextowle

Copy link
Member

@jalextowle jalextowle left a 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);
Copy link
Member

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) {
Copy link
Member

@jalextowle jalextowle Jun 16, 2019

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) {
Copy link
Member

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) {
Copy link
Member

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

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