2 # This is automatically generated by author/import-moose-test.pl.
3 # DO NOT EDIT THIS FILE. ANY CHANGES WILL BE LOST!!!
4 use t::lib::MooseCompat;
10 $TODO = q{Mouse is not yet completed};
11 use Test::Mouse 'does_ok';
25 append_string => 'append',
26 prepend_string => 'prepend',
27 match_string => 'match',
28 replace_string => 'replace',
29 chop_string => 'chop',
30 chomp_string => 'chomp',
31 clear_string => 'clear',
32 length_string => 'length',
33 exclaim => [ append => '!' ],
34 capitalize_last => [ replace => qr/(.)$/, ($uc = sub { uc $1 }) ],
35 invalid_number => [ match => qr/\D/ ],
40 my $page = MyHomePage->new();
41 isa_ok( $page, 'MyHomePage' );
43 is( $page->string, '', '... got the default value' );
44 is( $page->length_string, 0,'... length is zero' );
47 is( $page->length_string, 1,'... new string has length of one' );
50 is( $page->string, 'b', '... got the incremented value' );
53 is( $page->string, 'c', '... got the incremented value (again)' );
55 $page->append_string("foo$/");
56 is( $page->string, "cfoo$/", 'appended to string' );
59 is( $page->string, "cfoo", 'chomped string' );
62 is( $page->string, "cfoo", 'chomped is noop' );
65 is( $page->string, "cfo", 'chopped string' );
67 $page->prepend_string("bar");
68 is( $page->string, 'barcfo', 'prepended to string' );
70 is_deeply( [ $page->match_string(qr/([ao])/) ], ["a"], "match" );
72 $page->replace_string( qr/([ao])/, sub { uc($1) } );
73 is( $page->string, 'bArcfo', "substitution" );
74 is( $page->length_string, 6, 'right length' );
77 is( $page->string, 'bArcfo!', 'exclaim!' );
79 $page->string('Moosex');
80 $page->capitalize_last;
81 is( $page->string, 'MooseX', 'capitalize last' );
83 $page->string('1234');
84 ok( !$page->invalid_number, 'string "isn\'t an invalid number' );
86 $page->string('one two three four');
87 ok( $page->invalid_number, 'string an invalid number' );
90 is( $page->string, '', "clear" );
94 my $string = $page->meta->get_attribute('string');
95 does_ok( $string, 'Mouse::Meta::Attribute::Native::Trait::String' );
98 $string->type_constraint->name, 'Str',
99 '... got the expected type constraint'
106 append_string => 'append',
107 prepend_string => 'prepend',
108 match_string => 'match',
109 replace_string => 'replace',
110 chop_string => 'chop',
111 chomp_string => 'chomp',
112 clear_string => 'clear',
113 length_string => 'length',
114 exclaim => [ append => '!' ],
115 capitalize_last => [ replace => qr/(.)$/, $uc ],
116 invalid_number => [ match => qr/\D/ ],
118 '... got the right handles methods'