in reply to Re^3: Checking two scalars in Test::More $expected. It works, but is it proper?
in thread Checking two scalars in Test::More $expected. It works, but is it proper?

Before one of the answers above I would not have known that (3 and 4) were in list context. I didn't really think about scalar or list context as I was trying to understand how the test was working.

I don't think I had enough understanding to intend much. Since it was my first test and all previous were failing I was trying to get anything to work and then try to understand after that why it worked. What I thought was happening was that Test::Simple was looking at each value and comparing it to the return values but I couldn't really see how it was doing that.

I'm not sure I've answered your questions yet. I wonder if you're trying to teach me something and I haven't gotten it yet or my use was so out of whack your incredulous?

  • Comment on Re^4: Checking two scalars in Test::More $expected. It works, but is it proper?
  • Download Code

Replies are listed 'Best First'.
Re^5: Checking two scalars in Test::More $expected. It works, but is it proper?
by chromatic (Archbishop) on Mar 30, 2009 at 01:53 UTC
    I wonder if you're trying to teach me something and I haven't gotten it yet or my use was so out of whack your incredulous?

    (3 and 4) means 4, in scalar context. It's not an array. The parentheses only group the single expression (if 3 is true, then 4) so that the precedence and associativity of any preceding operators doesn't inadvertently consume the 3.

    I suppose I'm asking "What suggested to you that that syntax would do what you want?" and "What did you want to accomplish?" I don't mean this to sound like a lecture by any means. I have a deep interest in how people learn Perl, and you've done something here I've never seen before. That's fascinating to me.

      chromatic> I suppose I'm asking "What suggested to you that that syntax would do what you want?"
      The process went something like this.
      1. Tried a bunch of things that failed.
      2. What else can I try?
      3. Hmm, I'm returning "x" and "y" from my subroutine, why not see what happens with "x" and "y" on the right side of the expression.
      4. Tried a few more things to find some common working scenarios. Didn't find any.
      5. It works but it doesn't look right, can't seem to find a direct example of subroutine testing.
        chromatic> "What did you want to accomplish?"
        Not a whole of deep thought, just wanted to compare the return values of my subroutine.
        chromatic> and you've done something here I've never seen before. That's fascinating to me.
        Yes, probably in a WTF kind of way. I'm saying this to be humorous with a smile on my face.