Coder Social home page Coder Social logo

What to do about isnt() about test2-suite HOT 3 OPEN

test-more avatar test-more commented on August 16, 2024
What to do about isnt()

from test2-suite.

Comments (3)

1nickt avatar 1nickt commented on August 16, 2024 1

I use isnt in TODO tests quite often, when I don't care about what is returned so long as it isn't 'bar'.

TODO: {
    local $TODO = 'Question for Answer to the Ultimate Question of Life, The Universe, and Everything not known yet';
    isnt( question_for(42), 'How many roads must a man walk down?', 'The secret is out!' );
};

One of the main reasons I like it is the very clear error message:

not ok 1 - The secret is out! # TODO Question for Answer to the Ultimate Question of Life, The Universe, and Everything not known yet
#   Failed (TODO) test 'The secret is out!'
#   at foo.pl line 6.
#          got: 'How many roads must a man walk down?'
#     expected: anything else
...

from test2-suite.

schwern avatar schwern commented on August 16, 2024

How do we currently support something like:

my $id = $obj->next_id;
my $nextid = $obj->next_id;

isnt $nextid, $id, "next_id() returned a new id";

! only works for defined checks. Maybe what we need is not { ... }.

is $nextid, not { $id };

from test2-suite.

petdance avatar petdance commented on August 16, 2024

It simply passes if $left does not match $right in any way.

This is very useful. There are 156 uses of isnt in my codebase. Here are some examples:

my $custnum_district = get_test_district();
my $custnum_school = get_test_school();
isnt($custnum_district, $custnum_school, 'school and district are different customers');

or

isnt( price_for_flrid( $oldTitle->flrid() ), $newTitle->{price},
   'Old price is not equal to the updated payload price before renumber.' );

or

isnt( $list->total_price_local($kwd_ratesheet), $list->total_price_local($usd_ratesheet),
    'KWD is not same as explicit USD' );

or

isnt( $portrait->page_width(), $landscape->page_width(), 'page dimensions are different' );

I would be perfectly fine with the removal of the fake isn::t package and function so that you can no longer write isn't() calls.

from test2-suite.

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.