#!/opt/perl5/bin/perl use v5.34; use warnings; use Test::More; use Types qw( InvoiceType CreditType ); { subtest 'Type coercion' => sub { is InvoiceType->coerce('Invoice'), 'ACCREC', 'Can coerce a sales invoice'; is InvoiceType->coerce('SupplierInvoice'), 'ACCPAY', 'Can coerce a supplier invoice'; is CreditType->coerce('Credit'), 'ACCRECCREDIT', 'Can coerce a credit type'; is CreditType->coerce('SupplierCredit'), 'ACCPAYCREDIT', 'Can coerce a supplier credit type'; }; } { my $class = 'MyApp'; use_ok($class); subtest 'Class coercion' => sub { for my $t ( qw/Invoice SupplierInvoice Credit SupplierCredit / ) { note "Type=$t"; my $x = new_ok($class => [ type => $t ]); note "Now Type=".$x->type; } }; } done_testing;