d3-geo icon indicating copy to clipboard operation
d3-geo copied to clipboard

Missing test coverage in src/clip/circle.js

Open martinfrances107 opened this issue 5 years ago • 2 comments

I am slowly porting this module to rust...

The process has been made easy by the code qualify of this module.

  1. The tests are extensive.
  2. The design is good the code well laid out, modular and easy to read.

So please understand my next point is minor, and I do respect the overall quality.

When I have a issue I don't understand I insert console.log() statement to inspect variables...yes I use an IDE for complex debugging!!

but console.log() is good at showing which tests are covering the code under inspection.

my point is from the code below, no tests cover the tail of the file src/clip/circle.js... plenty of test cover the NULL that is return if the if statement takes no action but this complex if statement is not covered.

As I port my code .. I intend to push the new test upstream into this module.

But I am posting early just in case someone has a clear idea for a simple fix.

// Check that the first point is between a and b. if (meridian ? polar ? phi0 + phi1 > 0 ^ q[1] < (abs(q[0] - lambda0) < epsilon ? phi0 : phi1) : phi0 <= q[1] && q[1] <= phi1 : delta > pi ^ (lambda0 <= q[0] && q[0] <= lambda1)) { var q1 = cartesianScale(u, (-w + t) / uu); cartesianAddInPlace(q1, A); console.log("############################################### meridian output"); console.log([q, spherical(q1)]); console.log("############################################### meridian output"); debugger; return [q, spherical(q1)]; }

martinfrances107 avatar Aug 17 '20 09:08 martinfrances107

That part of the code is particularly difficult.

It was copied over from this commit in d3v3 and has since been left mostly untouched (except for variable names and formatting).

The reference issue was https://github.com/d3/d3/issues/1127

This might give us ideas to recreate meaningful tests (and maybe clarify the code).

Fil avatar Aug 17 '20 19:08 Fil

Thank you for adding the context - that was interesting to read.

when you say

(and maybe clarify the code).

Regarding src/clip/circle.js

For the point of view of a more type specific language like typescript of rust

The porting of code that passes uint8 code messages as the thrid/Z component of an otherwise 2D arrays of floats made me struggle yesterday.

So that will be a cleanup task I plan to work into the pull request I eventually generate.

martinfrances107 avatar Aug 18 '20 07:08 martinfrances107