diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-01-31 02:13:12 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2015-01-31 02:13:12 +0000 |
commit | 7446bb2b9d24fa6b702fbb62d73084a32ade6f75 (patch) | |
tree | 50037edde1d3cde3aaa25e759cd39975841ca663 /t/golf.t | |
download | Class-Tiny-tarball-master.tar.gz |
Class-Tiny-1.001HEADClass-Tiny-1.001master
Diffstat (limited to 't/golf.t')
-rw-r--r-- | t/golf.t | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/t/golf.t b/t/golf.t new file mode 100644 index 0000000..43a186a --- /dev/null +++ b/t/golf.t @@ -0,0 +1,35 @@ +use 5.006; +use strict; +use warnings; +use lib 't/lib'; + +use Test::More 0.96; +use TestUtils; + +require_ok("Golf"); + +subtest "lazy defaults" => sub { + my $obj = new_ok("Golf"); + is( $obj->foo, undef, "foo is undef" ); + is( $obj->bar, undef, "bar is undef" ); + ok( !exists( $obj->{wibble} ), "lazy wibble doesn't exist" ); + ok( !exists( $obj->{wobble} ), "lazy wobble doesn't exist" ); + is( $obj->wibble, 42, "wibble access gives default" ); + is( ref $obj->wobble, 'ARRAY', "wobble access gives default" ); + ok( exists( $obj->{wibble} ), "lazy wibble does exist" ); + ok( exists( $obj->{wobble} ), "lazy wobble does exist" ); + my $obj2 = new_ok("Golf"); + isnt( $obj->wobble, $obj2->wobble, "coderefs run for each object" ); +}; + +done_testing; +# +# This file is part of Class-Tiny +# +# This software is Copyright (c) 2013 by David Golden. +# +# This is free software, licensed under: +# +# The Apache License, Version 2.0, January 2004 +# +# vim: ts=4 sts=4 sw=4 et: |