# New Ticket Created by  "Martin Berends" 
# Please include the string:  [perl #65548]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=65548 >


Declaring constants and using them in the same file works, but moving the
constant declarations into bar.pm and then 'use bar;' does not. Adding 'is
export' also does not help, but should be required only if the constants
are defined inside a package, module or class, afaiu.

current constant test script: t/spec/S04-declarations/constant.t

Suggest adding a file constant_module.pm:
constant foo_from_module_unexported = 20;
constant foo_from_module_exported is export = 21;
class foo {
    constant bar_from_class_unexported = 22;
    constant bar_from_class_exported is export = 23;
}

Then these additions to constant.t:
use constant_module;
...
$ok = foo_from_module == 20;
ok $ok, "constant from module unexported works";

$ok = foo_from_module_exported == 21;
ok $ok, "constant from module exported works";

eval_dies_ok 'foo_from_class_exported == 22',
   "constant from class unexported works";

$ok = foo_from_class_exported == 23;
ok $ok, "constant from class exported works";

Untried code, hopefully fair start for troubleshooting.

Reply via email to