Skip to content

Conversation

@alexdowad
Copy link
Collaborator

When working on optimization of Range#line, I looked at what tests we have for ranges emitted by the lexer and was surprised to discover that the test suite hardly checks anything at all as re: correctness of the lexed ranges.

Perhaps unsurprisingly, when I tightened the test suite up to check the begin and end of each emitted range, it led me to discover a (relatively minor) bug.

@whitequark, see if you like the way the ranges are tested here or if you would prefer something else.

There are some cases where the lexer will see a number with a suffix, like this:

    42r

...But will determine that the apparent suffix is not actually part of the
number, and will back up so as not to consume it. In such cases, the emitted
range should not include this bogus suffix.
@whitequark
Copy link
Owner

Can we just test those in the parser tests? Lexer tests aren't even close to exhaustive anyway.

@alexdowad
Copy link
Collaborator Author

Can we just test those in the parser tests?

Oh, I see... you have those things like ^^ begin and ~~~~~ expression and so on.

I think the value of checking in the lexer tests as well is shown by the bug which I discovered this way. But it's up to you.

@whitequark
Copy link
Owner

Hrm, this is actually not possible to test in test_parser.rb because none of those result in valid parsetrees. Conversely, does it matter a lot then?..

@whitequark
Copy link
Owner

Well, I guess it doesn't hurt.

whitequark added a commit that referenced this pull request Feb 1, 2016
@whitequark whitequark merged commit d3b6699 into whitequark:master Feb 1, 2016
@alexdowad alexdowad deleted the test_emitted_ranges branch February 2, 2016 06:52
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.

2 participants