#!/usr/bin/env perl # # This file is part of MooX-Options # # This software is copyright (c) 2011 by Geistteufel . # # This is free software; you can redistribute it and/or modify it under # the same terms as the Perl 5 programming language system itself. # use strict; use warnings; use Test::More; BEGIN { use Module::Load::Conditional qw/check_install/; plan skip_all => 'Need Moo for this test' unless check_install( module => 'Moo' ); } for my $meth ( qw/creation_chain_method creation_method_name option_chain_method option_method_name/ ) { eval < undef; 1; EOF ; like $@, qr/^missing\soption\s$meth,\scheck\sdoc\sto\sdefine\sone/x, "$meth parameters should be defined"; } for my $meth (qw/creation_chain_method option_chain_method/) { eval < 'missing_method'; EOF ; like $@, qr/^method\smissing_method\sis\snot\sdefined,\scheck\sdoc\sto\suse\sanother\sname/x, "$meth point to a missing method"; } for my $meth (qw/creation_method_name option_method_name/) { eval < 'has'; EOF ; like $@, qr/^method\shas\salready\sdefined,\scheck\sdoc\sto\suse\sanother\sname/x, "$meth point to a defined method"; } eval < ( is => 'rw', negativable => 1, format => 'i', ); 1; EOF ; like $@, qr/^Negativable\sparams\sis\snot\susable\swith\snon\sboolean\svalue,\sdon't\spass\sformat\sto\suse\sit\s\!/x, "negativable and format are incompatible"; eval < ( is => 'rw', ); EOF ; like $@, qr/^Can't\suse\soption\swith\shelp,\sit\sis\simplied\sby\sMooX::Options/x, "help method can't be defined"; eval < ( is => 'rw', ); EOF ; like $@, qr/^Can't\suse\soption\swith\soption_usage,\sit\sis\simplied\sby\sMooX::Options/x, "usage is already autogenerated"; eval < 'failure'; option t => ( is => 'rw', ); 1; package main; FailureOptionChainMethod->new_with_options; EOF ; like $@, qr/^attribute\st\sisn't\sdefined.\sYou\shave\ssomething\swrong\sin\syour\soption_chain_method\s'failure'./x, "option_chain_method do nothing to create attribute with the same name"; done_testing;