[Bps-public-commit] r13219 - in Shipwright/trunk: t

sunnavy at bestpractical.com sunnavy at bestpractical.com
Thu Jun 12 14:17:18 EDT 2008


Author: sunnavy
Date: Thu Jun 12 14:17:18 2008
New Revision: 13219

Modified:
   Shipwright/trunk/   (props changed)
   Shipwright/trunk/t/20.util.t

Log:
 r13320 at sunnavys-mb:  sunnavy | 2008-06-13 01:12:15 +0800
 tests for YAML stuff


Modified: Shipwright/trunk/t/20.util.t
==============================================================================
--- Shipwright/trunk/t/20.util.t	(original)
+++ Shipwright/trunk/t/20.util.t	Thu Jun 12 14:17:18 2008
@@ -6,6 +6,7 @@
 use Shipwright::Test;
 use Shipwright::Util;
 use File::Spec;
+use File::Temp qw/tempfile/;
 use Cwd;
 
 Shipwright::Test->init;
@@ -32,5 +33,28 @@
 );
 is( $share_root, Shipwright::Util->share_root, 'share_root works' );
 
-my ($out) = Shipwright::Util->run(['ls', 'lib']);
+my ($out) = Shipwright::Util->run( [ 'ls', 'lib' ] );
 like( $out, qr/Shipwright/, 'test run sub' );
+
+my $hashref = { foo => 'bar' };
+my $string = <<EOF;
+--- 
+foo: bar
+EOF
+
+my ( $fh, $fn ) = tempfile;
+print $fh $string;
+close $fh;
+
+is_deeply( $hashref, Shipwright::Util::LoadFile($fn), 'LoadFile works' );
+is_deeply( $hashref, Shipwright::Util::Load($string), 'Load works' );
+
+is_deeply( $string, Shipwright::Util::Dump($hashref), 'Dump works' );
+
+my ( undef, $fn2 ) = tempfile;
+Shipwright::Util::DumpFile( $fn2, $hashref );
+my $string2;
+{ local $/; open my $fh, '<', $fn2 or die $!; $string2 = <$fh>; }
+
+is( $string, $string2, 'DumpFile works' );
+



More information about the Bps-public-commit mailing list