Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^4: Inverting test conditions in Test::More ?

by LanX (Saint)
on Jul 24, 2020 at 13:08 UTC ( [id://11119753]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Inverting test conditions in Test::More ?
in thread Inverting test conditions in Test::More ?

> What part of "instead of checking whether there is any difference, check for a specific difference" is specific to is_deeply and not general test logic?

well you spoke specifically about is_deeply

> > > You won't need is_deeply

I think my demo of a workaround shows what I wanted, since all tests are returning a boolean result.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Re^4: Inverting test conditions in Test::More ?

Replies are listed 'Best First'.
Re^5: Inverting test conditions in Test::More ?
by Corion (Patriarch) on Jul 24, 2020 at 13:24 UTC

    I only mention is_deeply in this sentence:

    You won't need is_deeply since you don't need to check all elements.

    In what way is "You won't need is_deeply" specifically about is_deeply? The approach of testing for a specific known difference in your prepared data is a general approach that works for your cases, or at least you haven't shown a counterexample.

      The test data is generated, finding the difference manually isn't easy.

      Furthermore, the idea of having Boolean logic for tests is straightforward and makes the code elegant and readable.

      Most importantly it's generic, I can't tell which other test besides is_deeply doesn't provide a negation.

      And I learned a lot about the test suite, especially Test::Builder in the course of this thread, just by asking this "silly question".

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

        I can't tell which other test besides is_deeply doesn't provide a negation.

        From Test::More I would offer:

        • use_ok
        • require_ok
        • isa_ok
        • can_ok

        none of which have a negative. Technically ok doesn't have a negative either but the trivial workaround of negating the argument should be sufficient for that one.


        🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11119753]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-19 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found