| 1 | #!/usr/bin/perl |
| 2 | |
| 3 | use strictscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 strict/; |
| 4 | use warningsscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 warnings/; |
| 5 | |
| 6 | use Test::Morescip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 Test/More/; |
| 7 | |
| 8 | BEGIN { |
| 9 | planscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 main/plan(). skip_all => "This test requires File::Temp" unless eval { requirescip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 main/require(). File::Temp }; |
| 10 | planscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 main/plan(). tests => 4; |
| 11 | } |
| 12 | |
| 13 | use Test::Exceptionscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 Test/Exception/; |
| 14 | |
| 15 | use okscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 ok/ "Catalyst::Plugin::Cache::Backend::FastMmap"; |
| 16 | |
| 17 | my ( $fh, $name ) = File::Temp::tempfilescip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 File/Temp/tempfile().(); |
| 18 | |
| 19 | my $cache = Catalyst::Plugin::Cache::Backend::FastMmap->newscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 Catalyst/Plugin/Cache/Backend/FastMmap/new().( |
| 20 | share_file => $name, |
| 21 | ); |
| 22 | |
| 23 | lives_okscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 main/lives_ok(). { |
| 24 | $cache->setscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 Catalyst/Plugin/Cache/Backend/FastMmap/set().( key => "non_ref" ); |
| 25 | } "you can set non references too"; |
| 26 | |
| 27 | isscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 main/is().( $cache->getscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 Catalyst/Plugin/Cache/Backend/FastMmap/get().("key"), "non_ref", "they are returned properly" ); |
| 28 | |
| 29 | $cache->setscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 Catalyst/Plugin/Cache/Backend/FastMmap/set().( complex => my $d = { foo => [qw/bar gorch/], baz => "moose" } ); |
| 30 | |
| 31 | is_deeplyscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 main/is_deeply().( $cache->getscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 Catalyst/Plugin/Cache/Backend/FastMmap/get().("complex"), $d, "storing of refs is unaffected" ); |
| 32 | |
| 33 | END { |
| 34 | closescip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 main/close(). $fh; |
| 35 | unlinkscip-perl cpan Catalyst-Plugin-Cache-Store-FastMmap 0.02 main/unlink(). $name if -e $name; |
| 36 | } |