Skip to content

Commit 5227904

Browse files
committed
test: tolerate float64 dust when asserting composed projection rotations
The composed d3 factory rotation can carry float64 dust depending on platform math (e.g. 96.00000000000001 on linux runners), so exact toEqual/toBe assertions are environment-dependent. Assert each axis with a tight 1e-9 tolerance instead.
1 parent 21f8497 commit 5227904

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

test/jasmine/tests/geo_test.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,14 +2890,19 @@ describe('Test geo projection D3 default rotation (#7949)', function() {
28902890
geo: { projection: { type: 'albers' } }
28912891
}).then(function() {
28922892
// d3-geo albers ships with rotation [96, 0, 0]; plotly's default
2893-
// projection.rotation attributes must not discard it
2894-
expect(subplot().projection.defaultRotation).toEqual([96, 0, 0]);
2895-
expect(subplot().projection.rotate()).toEqual([96, 0, 0]);
2893+
// projection.rotation attributes must not discard it.
2894+
// Compare with a tight numeric tolerance: the composed factory +
2895+
// user rotation can pick up float64 dust (e.g. 96.00000000000001
2896+
// on linux runners), so exact equality is environment-dependent.
2897+
[0, 1, 2].forEach(function(axis) {
2898+
expect(subplot().projection.defaultRotation[axis]).toBeCloseTo([96, 0, 0][axis], 9);
2899+
expect(subplot().projection.rotate()[axis]).toBeCloseTo([96, 0, 0][axis], 9);
2900+
});
28962901
}).then(function() {
28972902
return Plotly.relayout(gd, { 'geo.projection.rotation.lon': 10 });
28982903
}).then(function() {
28992904
// user rotation composes on top of the factory rotation
2900-
expect(subplot().projection.rotate()[0]).toBe(96 - 10);
2905+
expect(subplot().projection.rotate()[0]).toBeCloseTo(86, 9);
29012906
}).then(done, done.fail);
29022907
});
29032908

0 commit comments

Comments
 (0)