Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Mocking isa under Test::Deep

by BrowserUk (Pope)
on May 01, 2016 at 19:40 UTC ( #1161988=note: print w/replies, xml ) Need Help??


in reply to Mocking isa under Test::Deep

Do I understand this correctly?

The authors of a test tool have unilaterally decided that you (nor any of their thousands of other users) are allowed to use a comparator function that they didn't provide, breaking your test suite in the bargin, and you are meditating on the way you bypassed their arrogant caprice?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^2: Mocking isa under Test::Deep (sentinel)
by tye (Sage) on May 02, 2016 at 23:31 UTC
    The authors of a test tool have unilaterally decided that you [...] are [not] allowed to use a comparator function that they didn't provide,

    A more accurate summary would be that a test tool uses a special class as a sentinel and complains if a sentinel value turns up in a place where it has no business being. Meanwhile, a sloppy hack to get around draconian type checking had the side effect of making a non-sentinel appear to be a sentinel. The solution was to make the hack slightly less sloppy.

    I would put more blame on the type checking that requires the hack than on the use of an internal class name as a way to create and detect sentinels.

    - tye        

      A more accurate summary would be ...

      I'll take your word on that. I just looked through it all again and I can see that my original conclusion was less than the full story.

      That said, the breaking change is to Test::Deeply; appears (to me) to be digging into the guts of perl (via Scalar::Util::blessed()) to prevent their users from using fairly ordinary OO techniques to bypass their checks; and breaking stuff that worked for their users, all for the sake of the unjustified* and nebulous goal of 'improvement' of their own code base.

      That's akin to Stanley embossing a weak point on the shafts of their screwdrivers to prevent users from using them as levers.

      (*As in, not explained anywhere I could find.)


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
      In the absence of evidence, opinion is indistinguishable from prejudice.
        appears (to me) to be digging into the guts of perl (via Scalar::Util::blessed()) to prevent their users from using fairly ordinary OO techniques to bypass their checks

        Actually not. You could remove the use of Scalar::Util::blessed() and the code would function identically. Test::Deep is using isa() to enable users to extend the Test::Deep::Cmp functionality using ordinary OO techniques.

        If they had actually used blessed() in a way that prevents such extending then the "breaking change" would have been avoided. Replace the new code:

        if (! $Expects and Scalar::Util::blessed($d1) and $d1->isa("Test::Deep +::Cmp"))

        with code that looks too closely under the covers:

        if (! $Expects and Scalar::Util::blessed($d1) eq "Test::Deep::Cmp")

        and the fact that isa() was intentionally broken in order to do a sloppy hack to subvert draconian type checking would not have mattered.

        - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2019-10-18 18:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?