Why I'm skeptical of auto-formatting

H. S. Teoh hsteoh at quickfur.ath.cx
Thu May 2 22:44:51 UTC 2019


I know this is a minority opinion, and in fact even I myself would
regard the following as an exceptional case rather than the norm, but
the following unittest from one of my projects, quoted verbatim, is one
reason why I'm skeptical of applying code auto-formatting
indiscriminately:

------
    assert("i*10+j:i<>j=3".parseGridSpec.generateGrid[].map!(p => p.value)
           .equal(
    [
                      -30,
                 -21, -20, -19,
            -12, -11, -10,  -9, -8,
        -3,  -2,  -1,   0,   1,  2, 3,
              8,   9,  10,  11, 12,
                  19,  20,  21,
                       30
    ]));
------

The meaning of the first line is unimportant to the topic at hand
(though guesses are welcome :-P).  The main point here is that any
auto-formatting tool I know of would not only completely destroy the
elegance of the above test, but also pretty much remove all visual
traces of why exactly this particular case is being tested and why the
given values are the correct ones, as opposed to some arbitrary random
sequence of integers.


T

-- 
PNP = Plug 'N' Pray


More information about the Digitalmars-d mailing list