# Copyright (c) 2001 bivio Software, Inc. All Rights reserved. # # Visit http://www.bivio.biz for more info. # # This library is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as # published by the Free Software Foundation; either version 2.1 of the # License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; If not, you may get a copy from: # http://www.opensource.org/licenses/lgpl-license.html # # $Id: Testee.pm,v 2.4 2007/05/21 22:50:09 nagler Exp $ package Bivio::t::Test::Testee; use strict; $Bivio::t::Test::Testee::VERSION = sprintf('%d.%02d', q$Revision: 2.4 $ =~ /\d+/g); $_ = $Bivio::t::Test::Testee::VERSION; =head1 NAME Bivio::t::Test::Testee - unit test testing class =head1 RELEASE SCOPE bOP =head1 SYNOPSIS use Bivio::t::Test::Testee; =cut use Bivio::UNIVERSAL; @Bivio::t::Test::Testee::ISA = ('Bivio::UNIVERSAL'); =head1 DESCRIPTION C used only for testing L. =cut #=IMPORTS use Bivio::DieCode; #=VARIABLES my($_IDI) = __PACKAGE__->instance_data_index; =head1 FACTORIES =cut =for html =head2 static new(any default_return) : Bivio::t::Test::Testee Instance created with I =cut sub new { my(undef, $default_return) = @_; my($self) = shift->SUPER::new(@_); $self->[$_IDI] = { default_return => $default_return, }; return $self; } =head1 METHODS =cut sub as_string { my($self) = @_; return ref($self) ? ref($self) . '[' . (($self->[$_IDI] || {})->{default_return} || '') . ']' : ref($self); } =for html =head2 die(Bivio::DieCode code) Always dies with specified I. =cut sub die { my($self, $code) = @_; Bivio::Die->throw($code || Bivio::DieCode->DIE, { message => $code, }); # DOES NOT RETURN } =for html =head2 ok(any result, ...) : any Returns I or I as specified to L If no instance, returns undef. =cut sub ok { my($self) = shift; return @_ if @_ >= 1; return ref($self) ? $self->[$_IDI]->{default_return} : undef; } =for html =head2 want_scalar(any result, ...) : any Returns the results as an array in list context or scalar count in array context. =cut sub want_scalar { shift; return @_; } #=PRIVATE METHODS =head1 COPYRIGHT Copyright (c) 2001 bivio Software, Inc. All Rights reserved. Visit http://www.bivio.biz for more info. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; If not, you may get a copy from: http://www.opensource.org/licenses/lgpl-license.html =head1 VERSION $Id: Testee.pm,v 2.4 2007/05/21 22:50:09 nagler Exp $ =cut 1;