X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=t%2Fnative_traits%2Ftrait_array.t;h=f1f7b0ceeabb04d03d2e41208c4033759f1cab01;hb=ef2f720ebb1e5fdc5f5aeebfbc00e8346b2d4a4e;hp=086b1430aeec5f845d888c27da4b3a5cf9ba1874;hpb=229a897aa9932b2b856249632c63145edcc9502d;p=gitmo%2FMoose.git diff --git a/t/native_traits/trait_array.t b/t/native_traits/trait_array.t index 086b143..f1f7b0c 100644 --- a/t/native_traits/trait_array.t +++ b/t/native_traits/trait_array.t @@ -108,6 +108,19 @@ use Test::Moose; } { + package OverloadStr; + use overload + q{""} => sub { ${ $_[0] } }, + fallback => 1; + + sub new { + my $class = shift; + my $str = shift; + return bless \$str, $class; + } +} + +{ run_tests(build_class); run_tests( build_class( lazy => 1, default => sub { [ 42, 84 ] } ) ); run_tests( build_class( trigger => sub { } ) ); @@ -563,6 +576,11 @@ sub run_tests { 'join returns expected result when joining with empty string' ); + is( + $obj->join( OverloadStr->new(q{}) ), '1234', + 'join returns expected result when joining with empty string' + ); + like( exception { $obj->join }, qr/Cannot call join without at least 1 argument/, 'throws an error when passing no arguments to join' ); like( exception { $obj->join( '-', 2 ) }, qr/Cannot call join with more than 1 argument/, 'throws an error when passing two arguments to join' );