Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
test the allomorphness of ENV
  • Loading branch information
FROGGS committed Mar 13, 2016
1 parent f87e7b4 commit 9cf4992
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion S02-literals/allomorphic.t
Expand Up @@ -2,10 +2,12 @@

use v6;
use Test;
use lib 't/spec/packages';
use Test::Util;

# L<S02/Allomorphic value semantics>

plan 99;
plan 101;

## Sanity tests (if your compiler fails these, there's not much hope for the
## rest of the test)
Expand Down Expand Up @@ -183,3 +185,15 @@ lives-ok {val("foo")}, "val() exists";
lives-ok { want-str(val('42')) }, 'val("42") can be passed to native str parameter';
lives-ok { want-str(val('4e2')) }, 'val("4e2") can be passed to native str parameter';
}

# Environment variables produce allomorphic types, too.
{
%*ENV<FOO> = '42';
is_run 'print %*ENV<FOO>.^name', { status => 0, out => 'IntStr', err => '' },
'int/string "42" is an IntStr when passed via ENV';

# This test would break without allomorphs because the string "0" is trueish.
%*ENV<FOO> = '0';
is_run 'print so %*ENV<FOO>', { status => 0, out => 'False', err => '' },
'int/string "0" is falsish when passed via ENV';
}

0 comments on commit 9cf4992

Please sign in to comment.