Created
December 12, 2012 18:54
-
-
Save anonymous/4270506 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
use Test::More; | |
sub r_explicit { return 0; } | |
sub r_bare { return; } | |
# Probably not what you expected | |
my %hash = ( | |
first => r_bare, | |
second => r_explicit, | |
); | |
ok( exists $hash{'first'}, "'first' exists" ); | |
ok(! exists $hash{'second'}, "'second' unset" ); | |
# Not list context, as it happens | |
ok(! r_explicit, "r_explicit is false" ); # Passes | |
# Works like you'd hope | |
if ( r_explicit ) { | |
fail("r_explicit is false"); | |
} else { | |
pass("r_explicit is false"); | |
} | |
# Jumping through some real hoops here... | |
my $wrong_answer =()= r_explicit; | |
ok( $wrong_answer, "I blame the =()= operator" ); | |
my @wrong_answer = r_explicit; | |
if ( @wrong_answer ) { | |
pass("Who evaluates a list for truth, anyway?"); | |
} else { | |
fail("Who evaluates a list for truth, anyway?"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment