davimiku / json_parser

Implementation of a parser for JSON data
1 stars 0 forks source link

Test Output of Tutorial does not align with presented Code #2

Open MyGodItsFull0fStars opened 6 days ago

MyGodItsFull0fStars commented 6 days ago

Hi David,

I am currently working through your JSON parser tutorial and I do enjoy it so far. As I did not find another way to contact you, I thought I will create an issue (but in reality its a small remark).

In the Writing Tests section, right after adding #[derive(Debug,...] to the Token enum within tokenize.rs, there is the test output for the following unit test:

#[test]
fn just_comma() {
    let input = String::from(",");
    let expected = [Token::Comma];

    let actual = tokenize(input);

    assert_eq!(actual, expected); <----- the issue is related to this line!
}

Your shown CLI output is:

assertion `left == right` failed
  left: [Comma]
 right: []

The issue with that is, that the Comma token should be on the right side (the expected variable). If I execute the test on my machine (because it runs there), the CLI output is as expected:

assertion `left == right` failed
  left: []
 right: [Comma]

Anyway, that is just a minor thing I have found so far, and I really enjoy your explanations of the different topics and I hope to see more of that from you in the future ;)

davimiku commented 6 days ago

Thank you! The best compliment I can receive is that people are reading the tutorial and are having fun with it šŸ˜„

Good catch, I think what happened is in my first draft, I was inconsistent across my tests of the order (actual,expected or expected,actual). I cleaned that up later, but didn't update the text of the CLI output.

Thanks! Fixed now in davimiku/blog.davimiku.com@82bfca6e5c40bc3657770b068885c04168f2dbd9

MyGodItsFull0fStars commented 5 days ago

Yes I do have fun with the tutorial! You did an amazing job explaining the concepts step by step šŸ˜„

Happens to the best, and it's just a minor thing, but I thought I will mention it if any beginner might stumble over it.

In case I find anything else, shall I post it here or create a separate issue?

davimiku commented 4 days ago

Please do! Feel free to post it here, that's fine