Skip to content

Instantly share code, notes, and snippets.

Created December 12, 2012 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/4270506 to your computer and use it in GitHub Desktop.
Save anonymous/4270506 to your computer and use it in GitHub Desktop.
#!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