Skip to content

Instantly share code, notes, and snippets.

@atoomic
Created January 8, 2020 16:14
Show Gist options
  • Save atoomic/98ee3a7af8e26989fb6bae6085c8e3ed to your computer and use it in GitHub Desktop.
Save atoomic/98ee3a7af8e26989fb6bae6085c8e3ed to your computer and use it in GitHub Desktop.
#!perl
use Test::More;
my %storage;
use constant SAMPLE_CONSTANT => defined eval { $storage{cache} = get_string('abcd') };
sub get_string {
my ( $str ) = @_;
return ":$str:";
}
is SAMPLE_CONSTANT, 1, "constant is set to true";
is $storage{cache}, ':abcd:', "cache is set at compile time";
done_testing;
@atoomic
Copy link
Author

atoomic commented Jan 8, 2020

extra/constant-eval.t ..
ok 1 - constant is set to true
ok 2 - cache is set at compile time
1..2
ok
All tests successful.
Files=1, Tests=2,  1 wallclock secs ( 0.03 usr  0.00 sys +  0.07 cusr  0.01 csys =  0.11 CPU)
Result: PASS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment