The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
use Test::More tests => 4;

package Foo;
use base 't::Base';
use Class::Field 'const';

const 'this' => 'Charming Man';

package main;

ok defined(&Foo::const),
    'const is exported';

ok not(defined &Foo::field),
    'field is not exported';

my $foo = Foo->new;

is $foo->this, 'Charming Man',
    'const returns value';

$foo->this('is your life');

is $foo->this, 'Charming Man',
    'const remains constant';