Skip to content
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

Merged
merged 7 commits into from
Oct 10, 2022

Conversation

Malarg
Copy link
Collaborator

@Malarg Malarg commented Sep 30, 2022

No description provided.

Copy link
Contributor

@alexeyinkin alexeyinkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

test/src/folding/parsers/highlight_parser_test.dart Outdated Show resolved Hide resolved
test/src/folding/parsers/highlight_parser_test.dart Outdated Show resolved Hide resolved
test/src/folding/parsers/highlight_parser_test.dart Outdated Show resolved Hide resolved
test/src/folding/parsers/highlight_parser_test.dart Outdated Show resolved Hide resolved
test/src/folding/parsers/highlight_parser_test.dart Outdated Show resolved Hide resolved
lib/src/folding/foldable_block.dart Outdated Show resolved Hide resolved
lib/src/folding/foldable_block.dart Outdated Show resolved Hide resolved
test/src/folding/foldable_block_test.dart Outdated Show resolved Hide resolved
test/src/folding/foldable_block_test.dart Outdated Show resolved Hide resolved
test/src/folding/foldable_block_test.dart Outdated Show resolved Hide resolved
test/src/folding/foldable_block_test.dart Outdated Show resolved Hide resolved
expect(actual, matcher);
});

test('Join intersecting blocks in list with two not intersecting blocks',
Copy link
Contributor

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?

Copy link
Collaborator Author

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

Copy link
Contributor

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.

Copy link
Collaborator Author

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', () {
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed tests

test/src/folding/foldable_block_test.dart Outdated Show resolved Hide resolved
test/src/folding/foldable_block_test.dart Outdated Show resolved Hide resolved
for (int i = 1; i < length; i++) {
final currentBlock = this[i];
final previousBlock = this[i - 1];
if (currentBlock.intersects(previousBlock)) {
Copy link
Contributor

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))

Copy link
Collaborator Author

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),
          ],
        ),

Copy link
Contributor

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.

test/src/folding/foldable_block_test.dart Show resolved Hide resolved
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Align the digits please.

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.

None yet

2 participants