File: 01_no_inline_redefine.t

package info (click to toggle)
libunconstant-perl 0.09-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 132 kB
  • sloc: perl: 224; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 628 bytes parent folder | download
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
use unconstant;
use Test::More tests => 5;

package Foo {
	use constant BAR => 7;
	sub baz { BAR }
}

BEGIN {
	is( Foo::baz, 7, 'Constant set right initially' );
}

BEGIN {
	*Foo::BAR = sub { 42 };
	is( Foo::baz, 42, 'Constant override: sub assign to glob wo/ prototype' );
}

BEGIN {
	no warnings 'redefine';
	*Foo::BAR = sub () { 0 };
	is( Foo::baz, 0, 'Constant override: sub assign to glob w/ prototype' );
}

BEGIN {
	use constant "Foo::BAR" => 9;
	is( Foo::baz, 9, 'Constant override: use constant <string>' );
}

BEGIN {
	use constant *Foo::BAR => 11;
	is( Foo::baz, 11, 'Constant override: use constant <glob>' );
}

1;