File: reserved_names.t

package info (click to toggle)
libtest-base-perl 0.89-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 676 kB
  • sloc: perl: 936; makefile: 2
file content (56 lines) | stat: -rw-r--r-- 1,124 bytes parent folder | download | duplicates (4)
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
45
46
47
48
49
50
51
52
53
54
55
56
use Test::Base tests => 18;

for my $word (qw(
                 BEGIN
                 DESTROY
                 EXPORT
                 ISA
                 block_accessor
                 blocks_object
                 description
                 is_filtered
                 name
                 new
                 run_filters
                 seq_num
                 set_value
             )) {
    my $blocks = my_blocks($word);
    eval {$blocks->blocks};
    like $@, qr{'$word' is a reserved name},
         "$word is a bad name";
}

for my $word (qw(
                 field
                 const
                 stub
                 super
             )) {
    my $blocks = my_blocks($word);
    my @blocks = $blocks->blocks;
    eval {$blocks->blocks};
    is "$@", '',
       "$word is a good name";
}

sub my_blocks {
    my $word = shift;
    Test::Base->new->spec_string(<<"...");
=== Fail test
--- $word
This is a test
--- foo
This is a test
...
}

my $blocks = Test::Base->new->spec_string(<<'...');
=== Fail test
--- bar
This is a test
--- foo
This is a test
...
eval {$blocks->blocks};
is "$@", '';