Tests for numerical values

Issue #5 new
Håvard Berland
created an issue

I would like to propose extending (glob) or (re) into something that easily can handle numerical values with a specified tolerance.

I am trying to use cram for testing numerical codes, which could for example output




on two different computers, both answers should in this case be regarded as a passed test.

Comments (5)

  1. Brodie Rao repo owner
    • changed status to new

    ndiff looks interesting. I think we might be able to do something similar. Maybe the syntax could look something like this:

    $ echo 0.51234235
    0.5 (n=tolerance)

    Where tolerance is some value in some format I haven't decided. Maybe we can just copy ndiff.

    It could extract all float/decimal-looking portions of text and handle them appropriately when diffing.

    I think we could also easily support (glob n=tolerance) but I'm not sure about (re n=tolerance). It'd have to be aware that 0\.123 is a number to handle specially.

  2. Håvard Berland reporter

    Here is an example of what I use as of now:

       472.996 9.34102e-05 -144.893 
       4.804.*\s*549.996 -0.00250519\s* (re)
       -144.894 -2.53723e-05 254.094 

    (a 3x3 matrix)

    where I exchange digits with .* and (re) as I see other hardware give differing results. In

  3. Log in to comment