Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: Re: Tripwire tests and future-proofing

by zby (Vicar)
on May 25, 2004 at 09:40 UTC ( #356149=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Tripwire tests and future-proofing
in thread Tripwire tests and future-proofing

From Test::More:
ok($this eq $that, $test_name);
This simply evaluates any expression ($this eq $that is just a simple example) and uses that to determine if the test succeeded or failed. A true expression passes, a false one fails. Very simple.
So it's not exactly what you describe.

Additionally a list in scalar context returns it's last value not the number of it's elements. So your explanation of what happens after the keys function is not right.

Update:

$ perl -e '%h = (1, 1, 1, 1); print scalar keys %h, "\n"' 1
$ perl -e 'print scalar (1, "a"), "\n";' a

Replies are listed 'Best First'.
Re^4: Tripwire tests and future-proofing
by adrianh (Chancellor) on May 25, 2004 at 09:51 UTC
    So it's not exactly what you describe.

    As BUU said in his post this is the ok from Test, not the one from Test::More.

      Thanks. And what with the other question?

        Two questions:

        • How many items are in the hash in the example you gave?
        • Does keys actually returns a list in a scalar context?

        :-)

        keys in scalar context returns the number of elements in the resulting list. Whether this is magic in the keys function, or it's returning an "array" instead of a "list", I have no idea.

        >perl -e"%x=qw/foo bar 1 2 3 4 baz bar/; print scalar keys %x" 4

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://356149]
help
Chatterbox?
[ambrus]: As for TeX, I'm not trying to discourage anyone from writing carefully beautifully typeset documents, in maths or outside. But most people aren't willing to do that, and will spend only little time about the formatting,
[ambrus]: and try to leave everything else to automated systems without checking how what they write came out format-wise, and for those people, discounting the part about journals with a specific format above,
[ambrus]: just blindly recommending to use LaTeX is a bad idea now.
[Discipulus]: I havery limited needs in such field. Sometimes (for children party invitations) i draw something by hand and I scan it to include into an ms doc.
Discipulus havery can be a good neologism for: have very..;=)

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2017-09-26 11:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (293 votes). Check out past polls.

    Notices?