Skip to content

Commit

Permalink
Add concave polygon contains specs
Browse files Browse the repository at this point in the history
  • Loading branch information
ericyd committed Feb 6, 2024
1 parent 29dd856 commit 6f39ba5
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion lib/components/polygon.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,33 @@ describe('Polygon', () => {
}
})

// TODO@v1: add concave polygon for tests
describe('bowtie', () => {
const poly = new Polygon({
points: [
vec2(0, 0),
vec2(5, 2),
vec2(10, 0),
vec2(10, 8),
vec2(5, 6),
vec2(0, 8),
],
})

const tests = [
[vec2(1, 1), true],
[vec2(1, 7), true],
[vec2(5, 5), true],
[vec2(9, 1), true],
[vec2(9, 7), true],
[vec2(5, 1), false],
[vec2(5, 7), false],
]

for (const [point, expected] of tests) {
it(`returns ${expected} for ${point}`, () => {
assert.strictEqual(poly.contains(point), expected)
})
}
})
})
})

0 comments on commit 6f39ba5

Please sign in to comment.