From: Shawn M Moore Date: Sun, 21 Oct 2007 04:17:49 +0000 (+0000) Subject: Test case specifically, test script cleanup X-Git-Tag: 0_27~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4ce56d043fb257303138e8283c357842b3b02eda;p=gitmo%2FMoose.git Test case specifically, test script cleanup Case now matters for enum. If anyone disagrees with this choice, please let me know. (Humorously, previous versions of enum accepted EVERYTHING as valid, because it was just returning a regex object, which is a true value, instead of performing a match) --- diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 156d4c6..95bbfd7 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -649,8 +649,8 @@ L. This will create a basic subtype for a given set of strings. The resulting constraint will be a subtype of C and -will match any of the items in C<@values>. See the L -for a simple example. +will match any of the items in C<@values>. It is case sensitive. +See the L for a simple example. B This is not a true proper enum type, it is simple a convient constraint builder. diff --git a/t/040_type_constraints/015_enum.t b/t/040_type_constraints/015_enum.t index 28e73d9..d2cb922 100644 --- a/t/040_type_constraints/015_enum.t +++ b/t/040_type_constraints/015_enum.t @@ -3,13 +3,11 @@ use strict; use warnings; -use Test::More tests => 97; +use Test::More; use Scalar::Util (); -BEGIN { - use_ok('Moose::Util::TypeConstraints'); -} +use Moose::Util::TypeConstraints; enum Letter => 'a'..'z', 'A'..'Z'; enum Language => 'Perl 5', 'Perl 6', 'PASM', 'PIR'; # any others? ;) @@ -22,13 +20,18 @@ push @invalid_letters, qw/0 4 9 ~ @ $ %/; push @invalid_letters, qw/l33t st3v4n 3num/; my @valid_languages = ('Perl 5', 'Perl 6', 'PASM', 'PIR'); -my @invalid_languages = ('Python', 'Ruby', 'Perl 666', 'PASM++'); +my @invalid_languages = ('perl 5', 'Python', 'Ruby', 'Perl 666', 'PASM++'); +# note that "perl 5" is invalid because case now matters my @valid_metacharacters = (qw/* + ? . | ( ) [ ] /, '\\'); my @invalid_metacharacters = qw/< > & % $ @ ! ~ `/; push @invalid_metacharacters, qw/.* fish(sticks)? atreides/; push @invalid_metacharacters, '^1?$|^(11+?)\1+$'; +plan tests => @valid_letters + @invalid_letters + + @valid_languages + @invalid_languages + + @valid_metacharacters + @invalid_metacharacters; + Moose::Util::TypeConstraints->export_type_constraints_as_functions(); ok(Letter($_), "'$_' is a letter") for @valid_letters;