You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I porting this test to rust... I found an accidental inconsistency that because of javascript being a bit screwy
well it accidentally does the right thing...
I still consider it bug as someone modifying/maintaining the java script may not see the bug until too late..
this test
tape("delaunay.voronoi() for one point returns the bounding rectangle", test => {
let voronoi = Delaunay.from([[0, 0]]).voronoi([-1, -1, 2, 2]);
test.equal(voronoi.renderCell(0), "M2,-1L2,2L-1,2L-1,-1Z");
test.equal(voronoi.render(), null);
});
When I watch the code below run in a debugger.
(delaunay.js)
// degenerate case: 1 or 2 (distinct) points
if (hull.length <= 2 && hull.length > 0) {
this.triangles = new Int32Array(3).fill(-1);
this.halfedges = new Int32Array(3).fill(-1);
this.triangles[0] = hull[0];
this.triangles[1] = hull[1]; /* index out of bounds */
this.triangles[2] = hull[1]; /* index out of bounds */
inedges[hull[0]] = 1;
if (hull.length === 2) inedges[hull[1]] = 0; /* move statements here */
}
hull has a length of 1 with the contents of [0];
initially this.triangles is set to [-1, -1, -1]
hull[1] is formally undefined
and because Javascript is screwy
this.triangles[1] = undefined is a noop ... well after this.triangles[1] is still -1
My proposal is to move the statements labelled "index out of bounds" down into the
existing if statements which covers this case...
it will have no effect.. just make the intent of the code clear.
(actually it does less work, but that is not the advantage I am talking about)
I am about to generate a PR.
The text was updated successfully, but these errors were encountered:
I porting this test to rust... I found an accidental inconsistency that because of javascript being a bit screwy
well it accidentally does the right thing...
I still consider it bug as someone modifying/maintaining the java script may not see the bug until too late..
this test
When I watch the code below run in a debugger.
(delaunay.js)
hull has a length of 1 with the contents of [0];
initially this.triangles is set to [-1, -1, -1]
hull[1] is formally undefined
and because Javascript is screwy
this.triangles[1] = undefined is a noop ... well after this.triangles[1] is still -1
My proposal is to move the statements labelled "index out of bounds" down into the
existing if statements which covers this case...
it will have no effect.. just make the intent of the code clear.
(actually it does less work, but that is not the advantage I am talking about)
I am about to generate a PR.
The text was updated successfully, but these errors were encountered: