summaryrefslogtreecommitdiffstats
path: root/t/readonly.t
blob: f0b82ea2c4beb98f920780af73c4c86eac52d68d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;

use Fun;

my $thing = 1;

fun foo ($bar) { $bar = 1 }

ok(!eval { foo(); 1 });
ok(!eval { foo(1); 1 });
ok(!eval { foo($thing); 1 });
ok(!eval { foo($thing + 1); 1 });

fun bar ($baz) { $baz }

ok(eval { bar(); 1 });
ok(eval { bar(1); 1 });
ok(eval { bar($thing); 1 });
ok(eval { bar($thing + 1); 1 });

ok(eval { $thing = 2; 1 });
is($thing, 2);

fun baz ($quux) { $_[0] = 1 }

ok(eval { baz($thing); 1 });
is($thing, 1);

done_testing;