-
Notifications
You must be signed in to change notification settings - Fork 2
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
[#6] Add a switch for allowing comments #16
base: master
Are you sure you want to change the base?
Changes from all commits
9f49d2f
4b01213
3ed16dd
f2d05ab
2e2697f
6f9f4cc
26aedc6
fc4c8d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -297,6 +297,45 @@ test_DefaultInterpolator = testGroup "Default interpolator" | |
|
||
] | ||
|
||
---------------------------------- | ||
, testGroup "Commenting" | ||
|
||
[ testCase "Basic comments" do | ||
[int|tc|Abc -- this is a comment|] | ||
@?= "Abc " | ||
|
||
, testCase "Comments in arbitrary lines" do | ||
[int|tc| -- comments at the beginning | ||
My text -- comments in the middle | ||
-- comments at the end | ||
|] @?= " \nMy text \n\n" | ||
|
||
, testCase "Inline block comments" do | ||
[int|tc| My {- inline comment -} text | ||
Martoon-00 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|] @?= " My text\n" | ||
|
||
, testCase "Multiline block comments" do | ||
[int|tc| My text {- multiline block | ||
comments are fun, | ||
aren't they? | ||
-} | ||
|] @?= " My text\n" | ||
|
||
, testCase "Line comments do not affect the indentation" do | ||
[int|tc| | ||
The beginning | ||
-- some comments in the middle | ||
The end | ||
|] @?= " The beginning\n\n The end\n" | ||
|
||
, testCase "Block comments do not affect the indentation" do | ||
[int|tc| | ||
The beginning {- some clarifying | ||
comments in the middle -} | ||
The end | ||
|] @?= "The beginning\nThe end\n" | ||
] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also like tests on:
Behaviour in such cases should be fixed. And documented (no need to mention edge cases, just write the rule in one-two sentences so that it is unambiguous in regard to these edge cases). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
"My text (4 spaces) { - comments -} " -> do you mean that, in this case, the result should be "My text "? Do several spaces should get truncated to a single one? And, aside from that, please consider this one: {int|tc|
My text
-- comments
end
|] results in " My text\n\n end" - the indentation becomes two spaces, since the line comment has two leading empty spaces. Intuitively, one might expect the indentation to be totally stripped, and since we now support extra spaces removal for block comments, shouldn't we handle this case too? |
||
|
||
] | ||
|
||
] | ||
|
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 would rather write the clause with space removal as an extension of the "fast spacing" section above - to avoid extra rollbacks.
Generally, I find this approach good, you got the code grouped by the logic it is related to. But in our case performance matters (as we write a library), and the grammar is quite small, so we can afford some complication.
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.
Yup, totally agree