Coder Social home page Coder Social logo

Comments (4)

perlpunk avatar perlpunk commented on August 25, 2024

Thanks!

I actually want to compare via == and not eq ($def{data} could contain 300.00 for example).
I just didn't think of floating point arithmetic problems, although I should have known it ;-)

I fixed the test simply by avoiding rounding errors with sprintf in 9e907d1

Could you test it?

from yaml-pp-p5.

sisyphus avatar sisyphus commented on August 25, 2024

It seems that the first change where cmp_ok() is changed from performing an 'eq' test to an '==' might be the wrong thing.
It produces thousands of non-numeric warnings of the form:
Argument "*" isn't numeric in numeric eq (==) at (eval in cmp_ok) t/31.schema.t line 120.
where "*" is such things as "true", "y", "yes", "no", "null", "off", "on", "~", to name a few.

That's not causing any tests to fail, but for me the second change, where $data is replaced by sprintf("%0.2f",$data), is alone sufficient to allow all tests to pass.

However, I don't think I'm using the exact same version of 31.schema.t as is presented at 9e907d1 .
What seems to be line 128 of that file is actually line 120 on my copy of the file.

The interesting thing about that second change is that it fixes the failures by coercing the LHS of the '==' comparison to the same incorrect representation of 685230.15 as held by the RHS ($def{data}).
That approach is a little unusual and threw me initially - though it's a totally sane, valid and most practical solution.

Cheers,
Rob

from yaml-pp-p5.

perlpunk avatar perlpunk commented on August 25, 2024

Huh, weird.
It looks like the change got accidentally applied to the $type eq 'str' condition on your side. Then I get the same warnings as you.
Here's the direct link to the correct file (branch testfloat):
https://github.com/perlpunk/YAML-PP-p5/blob/testfloat/t/31.schema.t

Thanks!

from yaml-pp-p5.

sisyphus avatar sisyphus commented on August 25, 2024

Yep - https://github.com/perlpunk/YAML-PP-p5/blob/testfloat/t/31.schema.t is fine.

Cheers,
Rob

from yaml-pp-p5.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.