From: Dave Rolsky Date: Sat, 25 Sep 2010 20:08:26 +0000 (-0500) Subject: More tests for native traits to exercise all code paths X-Git-Tag: 1.15~83 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2c963694431d102ad3c15bbc51110060cb77c31f;p=gitmo%2FMoose.git More tests for native traits to exercise all code paths --- diff --git a/t/070_native_traits/020_trait_bool.t b/t/070_native_traits/020_trait_bool.t index 7587d57..151a16f 100644 --- a/t/070_native_traits/020_trait_bool.t +++ b/t/070_native_traits/020_trait_bool.t @@ -4,6 +4,7 @@ use strict; use warnings; use Moose (); +use Moose::Util::TypeConstraints; use Test::More; use Test::Exception; use Test::Moose; @@ -45,6 +46,15 @@ use Test::Moose; { run_tests(build_class); run_tests( build_class( lazy => 1 ) ); + + # Will force the inlining code to check the entire hashref when it is modified. + subtype 'MyBool', as 'Bool', where { 1 }; + + run_tests( build_class( isa => 'MyBool' ) ); + + coerce 'MyBool', from 'Bool', via { $_ }; + + run_tests( build_class( isa => 'MyBool', coerce => 1 ) ); } sub run_tests { diff --git a/t/070_native_traits/040_trait_counter.t b/t/070_native_traits/040_trait_counter.t index af44317..39fed71 100644 --- a/t/070_native_traits/040_trait_counter.t +++ b/t/070_native_traits/040_trait_counter.t @@ -4,6 +4,7 @@ use strict; use warnings; use Moose (); +use Moose::Util::TypeConstraints; use Test::Exception; use Test::More; use Test::Moose; @@ -48,6 +49,15 @@ use Test::Moose; { run_tests(build_class); run_tests( build_class( lazy => 1 ) ); + + # Will force the inlining code to check the entire hashref when it is modified. + subtype 'MyInt', as 'Int', where { 1 }; + + run_tests( build_class( isa => 'MyInt' ) ); + + coerce 'MyInt', from 'Int', via { $_ }; + + run_tests( build_class( isa => 'MyInt', coerce => 1 ) ); } sub run_tests { diff --git a/t/070_native_traits/060_trait_number.t b/t/070_native_traits/060_trait_number.t index 35d81c8..ddb8f4e 100644 --- a/t/070_native_traits/060_trait_number.t +++ b/t/070_native_traits/060_trait_number.t @@ -4,6 +4,7 @@ use strict; use warnings; use Moose (); +use Moose::Util::TypeConstraints; use Test::Exception; use Test::More; use Test::Moose; @@ -52,6 +53,15 @@ use Test::Moose; { run_tests(build_class); run_tests( build_class( lazy => 1 ) ); + + # Will force the inlining code to check the entire hashref when it is modified. + subtype 'MyInt', as 'Int', where { 1 }; + + run_tests( build_class( isa => 'MyInt' ) ); + + coerce 'MyInt', from 'Int', via { $_ }; + + run_tests( build_class( isa => 'MyInt', coerce => 1 ) ); } sub run_tests { diff --git a/t/070_native_traits/070_trait_string.t b/t/070_native_traits/070_trait_string.t index ebd2063..1f64eb2 100644 --- a/t/070_native_traits/070_trait_string.t +++ b/t/070_native_traits/070_trait_string.t @@ -4,6 +4,7 @@ use strict; use warnings; use Moose (); +use Moose::Util::TypeConstraints; use Test::More; use Test::Exception; use Test::Moose; @@ -58,6 +59,15 @@ use Test::Moose; { run_tests(build_class); run_tests( build_class( lazy => 1, default => q{} ) ); + + # Will force the inlining code to check the entire hashref when it is modified. + subtype 'MyStr', as 'Str', where { 1 }; + + run_tests( build_class( isa => 'MyStr' ) ); + + coerce 'MyStr', from 'Str', via { $_ }; + + run_tests( build_class( isa => 'MyStr', coerce => 1 ) ); } sub run_tests {