forked from Raku/roast
/
strict.t
44 lines (35 loc) · 1.1 KB
/
strict.t
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
33
34
35
36
37
38
39
40
41
42
43
44
use v6;
no strict;
use Test;
plan 7;
# L<S02/"Names"/"When \"strict\" is in effect (which is the default except for one-liners)">
$baz = 'lax';
is $baz, 'lax', 'variable gets auto-declared when strict is turned off';
class Foo {
$foo = 42;
is $foo, 42, 'variable gets auto-declared in packages';
}
is $Foo::foo, 42, 'lax declared variable is package scoped';
{
use strict;
throws-like '$foo = 10;', X::Undeclared, suggestions => 'Foo';
}
#?rakudo 1 skip 'lax mode does not propagate into EVAL yet RT #124912'
{
is EVAL('$bar'), Any, 'lax mode propagates into EVAL blocks'
}
# RT #123696
{
lives-ok { EVAL '(6;)' },
'"6;" no longer means "no strict;" and "(6;)" no longer results in a compile time error';
}
# RT #125398
subtest '`no strict` does not cause autovivification container issues' => {
plan 4;
no strict;
%h<a> = 42;
lives-ok { temp %h<b> = 8 }, '`temp` on Hash key';
lives-ok { let %h<c> = 9 }, '`let` on Hash key';
lives-ok { %h<d><e> }, 'postcircumfix {} on Hash key'; # RT #125183
isa-ok %h<non-existent>, Any, 'non-existent keys are `Any`';
}