Skip to content
This repository was archived by the owner on Oct 9, 2019. It is now read-only.
This repository was archived by the owner on Oct 9, 2019. It is now read-only.

Should Expect.equal fail on floats? #230

Open
@rtfeldman

Description

@rtfeldman

We have Expect.within for comparing floats, but people don't necessarily know it's there. They may use Expect.equal on floats, not realizing that they should use Expect.within instead.

It occurs to me that we could have Expect.equal fail the test when given two floats, with an error message pointing the caller to Expect.within instead.

Here's how we could implement it:

  1. Have Expect.equal start by calling toString on both arguments
  2. Convert them both to floats using String.toFloat
  3. If that worked, truncate both floats and compare them with ==. If the truncation changed either of them, they were non-integers and should have been compared with Expect.within.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions