File: 55croak-params.t

package info (click to toggle)
libobject-pad-perl 0.821-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 936 kB
  • sloc: ansic: 3,361; perl: 3,328; pascal: 28; makefile: 3
file content (46 lines) | stat: -rw-r--r-- 1,046 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/perl

use v5.18;
use warnings;

use Test2::V0;

use Object::Pad 0.800 ':experimental(adjust_params)';

{
   ok( !eval <<'EOPERL',
      class AClass {
         field $x :param(foo);
         field $y :param(foo);
      }
EOPERL
      'Clashing :param names fails' );
   like( $@, qr/^Already have a named constructor parameter called 'foo' at /,
      'message from clashing :param names' );
}

{
   ok( !eval <<'EOPERL',
      class BClass {
         field $x :param(foo);
         ADJUST :params ( :$foo ) { }
      }
EOPERL
      'Clashing :param/ADJUST names fails' );
   like( $@, qr/^Already have a named constructor parameter called 'foo' at /,
      'message from clashing :param/ADJUST names' );
}

{
   ok( !eval <<'EOPERL',
      class CClass {
         ADJUST :params ( :$foo ) { }
         field $x :param(foo);
      }
EOPERL
      'Clashing ADJUST/:param names fails' );
   like( $@, qr/^Already have a named constructor parameter called 'foo' at /,
      'message from clashing ADJUST/:param names' );
}

done_testing;