🚀 benchmark
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { snakeSelfCollide } from "../snake";
|
||||
import { snakeSelfCollide, snakeWillSelfCollide } from "../snake";
|
||||
|
||||
test.each([
|
||||
[[{ x: 0, y: 0 }], false],
|
||||
@@ -22,3 +22,41 @@ test.each([
|
||||
])("should report snake collision", (snake, collide) => {
|
||||
expect(snakeSelfCollide(snake)).toBe(collide);
|
||||
});
|
||||
|
||||
test.each([
|
||||
[
|
||||
[
|
||||
{ x: 1, y: 7 },
|
||||
{ x: 0, y: 7 },
|
||||
{ x: 0, y: 8 },
|
||||
{ x: 0, y: 9 },
|
||||
{ x: 1, y: 9 },
|
||||
],
|
||||
{ x: 1, y: 7 },
|
||||
true,
|
||||
],
|
||||
[
|
||||
[
|
||||
{ x: 1, y: 7 },
|
||||
{ x: 0, y: 7 },
|
||||
{ x: 0, y: 8 },
|
||||
{ x: 0, y: 9 },
|
||||
{ x: 1, y: 9 },
|
||||
],
|
||||
{ x: 1, y: 8 },
|
||||
false,
|
||||
],
|
||||
[
|
||||
[
|
||||
{ x: 1, y: 7 },
|
||||
{ x: 0, y: 7 },
|
||||
{ x: 0, y: 8 },
|
||||
{ x: 0, y: 9 },
|
||||
{ x: 1, y: 9 },
|
||||
],
|
||||
{ x: 1, y: 8 },
|
||||
false,
|
||||
],
|
||||
])("should report snake collision next", (snake, { x, y }, collide) => {
|
||||
expect(snakeWillSelfCollide(snake, x, y)).toBe(collide);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user