Code Monkey home page Code Monkey logo

Comments (6)

nex3 avatar nex3 commented on August 24, 2024

I'm of two minds about this. I see where you're coming from, but I also appreciate the aesthetic value of letting matchers read like sentences where possible—"expect foo is true" reads better than "expect foo true".

If we do decide to do this, I'd want to first improve the output of equals() so that we don't have angle brackets for objects like booleans whose string output we know to be reasonable.

from matcher.

natebosch avatar natebosch commented on August 24, 2024

Added to 1.0.0 milestone so we can either decide not to deprecate, or have them removed before the version bump.

This has come up on mailing lists as a source of confusion, IMO having 1 way to solve this problem outweighs the aesthetics of the call.

It definitely can't hurt to have nicer output from equals() in any case 😄

from matcher.

matanlurey avatar matanlurey commented on August 24, 2024

One advantage of isTrue and isFalse is we could do better static analysis, i.e.:

expect/*Inferred: <bool>*/(someFlag, isTrue);

That means if you accidentally type:

expect('clearlyNotTrue', isTrue);

We could potentially lint this. Just an idea.

from matcher.

natebosch avatar natebosch commented on August 24, 2024

Hmm, yeah with #37 these could potentially have more utility.

Though if we work out the T|Matcher<T> problem that would exist with expect anyway would we also be able to get the same for expect('notABool', true)?

Do we see a world where we start requiring equals() so we can limit the second argument to Matcher?

from matcher.

nex3 avatar nex3 commented on August 24, 2024

Do we see a world where we start requiring equals() so we can limit the second argument to Matcher?

I personally use equals() a lot, but I'm in the substantial minority there—people really like using bare values, and I'd hate to take that away from them. Also, even I use bare values for operators where it helps the match read like a sentence, such as expect(foo, isNot(12)). I'd rather just wait for union types.

from matcher.

jamesderlin avatar jamesderlin commented on August 24, 2024

I'm of two minds about this. I see where you're coming from, but I also appreciate the aesthetic value of letting matchers read like sentences where possible—"expect foo is true" reads better than "expect foo true".

I think that's more about implicit vs. explicit use of equals(). That's orthogonal to isTrue vs. equals(true), which I think is what this issue is really about.

If we do decide to do this, I'd want to first improve the output of equals() so that we don't have angle brackets for objects like booleans whose string output we know to be reasonable.

FWIW, I much prefer the existing output from equals(). I've been confused by the failure output from isTrue/isFalse/isNull where the expected value is printed without angle brackets but the actual value is printed with them. I then spend time wondering why they're formatted differently (e.g. is the actual value a different type?).

from matcher.

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.