From: Jesse Luehrs Date: Tue, 26 Apr 2011 14:45:01 +0000 (-0500) Subject: update tests for moose error message changes X-Git-Tag: 0.27~1 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Types-Structured.git;a=commitdiff_plain;h=ba2c5a1e309b35c14fba24021611d7bb1f4f8644 update tests for moose error message changes --- diff --git a/t/04-map.t b/t/04-map.t index a1f0a56..ebbf922 100644 --- a/t/04-map.t +++ b/t/04-map.t @@ -11,10 +11,10 @@ my $type = Map[ Int, Num ]; ok($type->assert_valid({ 10 => 10.5 }), "simple Int -> Num mapping"); like( exception { $type->assert_valid({ 10.5 => 10.5 }) }, - qr{value 10\.5}, "non-Int causes rejection on key"); + qr{value .*10\.5.*}, "non-Int causes rejection on key"); like( exception { $type->assert_valid({ 10 => "ten and a half" }) }, - qr{value ten and a half}, "non-Num value causes rejection on value"); + qr{value .*ten and a half.*}, "non-Num value causes rejection on value"); ok($type->assert_valid({ }), "empty hashref is a valid mapping of any sort"); diff --git a/t/12-error.t b/t/12-error.t index 2e099fe..0edf798 100644 --- a/t/12-error.t +++ b/t/12-error.t @@ -21,19 +21,19 @@ ok !$simple_dict->check({name=>$simple_dict,age=>'hello'}), "simple_dict fails: ## Let's check all the expected validation errors for tuple like $simple_tuple->validate({a=>1,b=>2}), - qr/Validation failed for 'simple_tuple' with value { a: 1, b: 2 }/, + qr/Validation failed for 'simple_tuple' with value .*{ a: 1, b: 2 }/, 'Wrong basic type'; like $simple_tuple->validate(['a','b']), - qr/failed for 'simple_tuple' with value \[ "a", "b" \]/, + qr/failed for 'simple_tuple' with value .*\[ "a", "b" \]/, 'Correctly failed due to "a" not an Int'; like $simple_tuple->validate([1,$simple_tuple]), - qr/Validation failed for 'simple_tuple' with value \[ 1, MooseX::Meta::TypeConstraint::Structured/, + qr/Validation failed for 'simple_tuple' with value .*\[ 1, MooseX::Meta::TypeConstraint::Structured/, 'Correctly failed due to object not a Str'; like $simple_tuple->validate([1]), - qr/Validation failed for 'Str' with value NULL/, + qr/Validation failed for 'Str' with value .*NULL/, 'Not enought values'; like $simple_tuple->validate([1,'hello','too many']), @@ -43,19 +43,19 @@ like $simple_tuple->validate([1,'hello','too many']), ## And the same thing for dicts [name=>Str,age=>Int] like $simple_dict->validate([1,2]), - qr/ with value \[ 1, 2 \]/, + qr/ with value .*\[ 1, 2 \]/, 'Wrong basic type'; -like $simple_dict->validate({name=>'John',age=>'a'}), - qr/failed for 'Int' with value a/, +like $simple_dict->validate({name=>'John',age=>'foobar'}), + qr/failed for 'Int' with value .*foobar/, 'Correctly failed due to age not an Int'; like $simple_dict->validate({name=>$simple_dict,age=>1}), - qr/with value { age: 1, name: MooseX:/, + qr/with value .*{ age: 1, name: MooseX:/, 'Correctly failed due to object not a Str'; like $simple_dict->validate({name=>'John'}), - qr/failed for 'Int' with value NULL/, + qr/failed for 'Int' with value .*NULL/, 'Not enought values'; like $simple_dict->validate({name=>'Vincent', age=>15,extra=>'morethanIneed'}), @@ -68,15 +68,15 @@ like $simple_dict->validate({name=>'Vincent', age=>15,extra=>'morethanIneed'}), my $optional_dict = subtype 'optional_dict', as Dict[name=>Str,age=>Optional[Int]]; like $optional_tuple->validate({a=>1,b=>2}), - qr/Validation failed for 'optional_tuple' with value { a: 1, b: 2 }/, + qr/Validation failed for 'optional_tuple' with value .*{ a: 1, b: 2 }/, 'Wrong basic type'; -like $optional_tuple->validate(['a','b']), - qr/failed for 'Int' with value a/, - 'Correctly failed due to "a" not an Int'; +like $optional_tuple->validate(['baz','b']), + qr/failed for 'Int' with value .*baz/, + 'Correctly failed due to "baz" not an Int'; like $optional_tuple->validate([1,$simple_tuple]), - qr/failed for 'Optional\[Str\]' with value MooseX/, + qr/failed for 'Optional\[Str\]' with value .*MooseX/, 'Correctly failed due to object not a Str'; like $optional_tuple->validate([1,'hello','too many']), @@ -84,15 +84,15 @@ like $optional_tuple->validate([1,'hello','too many']), 'Too Many values'; like $optional_dict->validate([1,2]), - qr/ with value \[ 1, 2 \]/, + qr/ with value .*\[ 1, 2 \]/, 'Wrong basic type'; -like $optional_dict->validate({name=>'John',age=>'a'}), - qr/Validation failed for 'Optional\[Int\]' with value a/, +like $optional_dict->validate({name=>'John',age=>'quux'}), + qr/Validation failed for 'Optional\[Int\]' with value .*quux/, 'Correctly failed due to age not an Int'; like $optional_dict->validate({name=>$simple_dict,age=>1}), - qr/with value { age: 1, name: MooseX:/, + qr/with value .*{ age: 1, name: MooseX:/, 'Correctly failed due to object not a Str'; like $optional_dict->validate({name=>'Vincent', age=>15,extra=>'morethanIneed'}), @@ -122,11 +122,11 @@ ok $deep_tuple->check([1,{a=>2},{name=>'Vincent',age=>15}]), } like $simple_tuple->validate(["aaa","bbb"]), - qr/'Int' with value aaa/, + qr/'Int' with value .*aaa/, 'correct deeper error'; like $deep_tuple->validate([1,{a=>2},{name=>'Vincent1',age=>'Hello1'}]), - qr/'Int' with value Hello1/, + qr/'Int' with value .*Hello1/, 'correct deeper error'; ## Success Tests...