Skip to content

Commit

Permalink
test: Add test for the intersections test helper method (#2378)
Browse files Browse the repository at this point in the history
This is a cleanup identified on this issue: #2308
Using an amazing unused-code tooling
Now, since Flame is a public API, unused code might not be trivial - it might just mean untested code.

In this case, we have a test helper, which is a public function we expose to help people write better tests.
Which means that the function could be useful, it was just lacking a test -- so I added it.
That being said, if this method is deemed unnecessary for users, I can just remove it instead - lmk.
  • Loading branch information
luanpotter authored and st-pasha committed Mar 2, 2023
1 parent 34a1fd5 commit 62e45c7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/flame/test/collisions/collision_type_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,23 @@ void main() {
expect(blockA.activeCollisions.length, 1);
expect(blockB.activeCollisions.length, 1);
},
'intersections are returned': (game) async {
final blockA = TestBlock(
Vector2.zero(),
Vector2.all(10),
);
final blockB = TestBlock(
Vector2.all(1),
Vector2.all(10),
);
await game.ensureAddAll([blockA, blockB]);
game.update(0);

final points = blockA.intersections(blockB);
expect(points.length, 2);
expect(points, contains(Vector2(1, 10)));
expect(points, contains(Vector2(10, 1)));
},
'passives do not collide': (game) async {
final blockA = TestBlock(
Vector2.zero(),
Expand Down

0 comments on commit 62e45c7

Please sign in to comment.