-
Notifications
You must be signed in to change notification settings - Fork 46
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
issue 47. tests for scala foldable blocks #75
Conversation
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.
Thanks.
expect(actual, matcher); | ||
}); | ||
|
||
test('Join intersecting blocks in list with two not intersecting blocks', |
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.
Do we need this test if we have the one after it?
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.
We do, because it's edge case. Two items are minimal available count for intersecting
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.
Does it work differently internally? If no, then my experience is that less tests on similar inputs is preferred. This is because if we change the API we will have to refactor tests which is more tedious than refactoring code.
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.
Fixed tests
expect(actual, matcher); | ||
}); | ||
|
||
test('Mixed blocks will join correctly', () { |
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.
This test mostly repeats the one above. You can add the last block from this test there, and the same inputs will be covered.
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'd like to test edge cases separately from another logic
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.
Fixed tests
lib/src/folding/foldable_block.dart
Outdated
for (int i = 1; i < length; i++) { | ||
final currentBlock = this[i]; | ||
final previousBlock = this[i - 1]; | ||
if (currentBlock.intersects(previousBlock)) { |
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.
intersects(other)
is not needed at all. Just check if previous.endLine >= current.startLine && previous.endLine < current.endLine
or maybe make a method that encapsulates this (but I am struggling to come up with a name, maybe intersectsWithEnd(int)
)
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.
This logic falls on this test:
_Example(
'Python. Nested highlight blocks',
code: '''
a = [[
5
]
]''',
expected: [
_FB(startLine: 0, endLine: 2, type: _T.brackets),
_FB(startLine: 0, endLine: 3, type: _T.brackets),
],
),
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.
Let's disallow two blocks to start on the same line because we can only have one folding button per line. Only the outer block of the two should survive.
FB(startLine: 6, endLine: 12, type: FBT.braces), | ||
FB(startLine: 7, endLine: 9, type: FBT.parentheses), | ||
FB(startLine: 10, endLine: 11, type: FBT.parentheses), | ||
FB(startLine: 0, endLine: 6, type: FBT.braces), // 0 |
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.
Align the digits please.
No description provided.