From: Shawn M Moore Date: Sat, 4 Aug 2007 19:06:14 +0000 (+0000) Subject: Add failing false-value tests, will try to get them passing X-Git-Tag: 0_07~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMooseX-Storage.git;a=commitdiff_plain;h=669c005508d8a834ee77e435d8731a10b7116265 Add failing false-value tests, will try to get them passing --- diff --git a/MANIFEST b/MANIFEST index 2e3267b..e086a59 100644 --- a/MANIFEST +++ b/MANIFEST @@ -24,6 +24,7 @@ t/003_basic_w_embedded_objects.t t/004_w_cycles.t t/005_w_versions_and_authority_check.t t/006_w_custom_type_handlers.t +t/007_false.t t/010_basic_json.t t/020_basic_yaml.t t/030_with_checksum.t diff --git a/t/007_false.t b/t/007_false.t new file mode 100644 index 0000000..ee53900 --- /dev/null +++ b/t/007_false.t @@ -0,0 +1,59 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More tests => 7; + +BEGIN { + use_ok('MooseX::Storage'); +} + +{ + + package Foo; + use Moose; + use MooseX::Storage; + + with Storage; + + has 'number' => ( is => 'ro', isa => 'Int', default => 42 ); + has 'string' => ( is => 'ro', isa => 'Str', default => "true" ); + has 'boolean' => ( is => 'ro', isa => 'Bool', default => 1 ); +} + +{ + my $foo = Foo->new( + number => 0, + string => '', + boolean => 0, + ); + isa_ok( $foo, 'Foo' ); + + is_deeply( + $foo->pack, + { + __CLASS__ => 'Foo', + number => 0, + string => '', + boolean => 0, + }, + '... got the right frozen class' + ); +} + +{ + my $foo = Foo->unpack( + { + __CLASS__ => 'Foo', + number => 0, + string => '', + boolean => 0, + } + ); + isa_ok( $foo, 'Foo' ); + + is( $foo->number, 0, '... got the right number' ); + is( $foo->string, '', '... got the right string' ); + ok( !$foo->boolean, '... got the right boolean' ); +}