From c915bff66e46c43822f4e5f03282c23a745fb6f6 Mon Sep 17 00:00:00 2001 From: "H.Merijn Brand" Date: Wed, 3 Jun 2009 10:20:51 +0200 Subject: [PATCH] Tests for DDsort --- Peek.pm | 2 +- t/10_DDumper.t | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Peek.pm b/Peek.pm index dc6b8b1..9082dff 100644 --- a/Peek.pm +++ b/Peek.pm @@ -8,7 +8,7 @@ use DynaLoader (); use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK ); $VERSION = "0.26"; @ISA = qw( DynaLoader Exporter ); -@EXPORT = qw( DDumper DPeek DDisplay DDump DDual ); +@EXPORT = qw( DDumper DDsort DPeek DDisplay DDump DDual ); @EXPORT_OK = qw( triplevar ); $] >= 5.007003 and push @EXPORT, "DDump_IO"; diff --git a/t/10_DDumper.t b/t/10_DDumper.t index ed8afd8..3afccf1 100644 --- a/t/10_DDumper.t +++ b/t/10_DDumper.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 43; +use Test::More tests => 56; use Test::NoWarnings; BEGIN { @@ -21,6 +21,8 @@ while () { next; } + $v =~ s/^S:([^:]*):// and DDsort ($1), $v =~ m/^()/; # And reset $1 for below + unless ($v eq "") { eval "\$var = $v"; ok ($dump = DDumper ($var), "DDumper ($v)"); @@ -28,7 +30,7 @@ while () { $dump =~ s/;\n\Z//; } if ($re) { - like ($dump, qr{$exp}m, ".. content $re"); + like ($dump, qr{$exp}ms, ".. content $re"); $1 and print STDERR "# '$1' (", length ($1), ")\n"; } else { @@ -64,3 +66,10 @@ undef undef ^ {4}\{\n {8}foo {14}=> 1\n {8}}\n inner hash ^ {4}]\Z outer list end [[0],{foo=>1}] \A\[\n {4}\[\n {8}0\n {8}],\n {4}\{\n {8}foo {14}=> 1\n {8}}\n {4}]\Z full struct +-- Sorting +S:1:{ab=>1,bc=>2,cd=>3,de=>13} ab.*bc.*cd.*de default sort +S:R:{ab=>1,bc=>2,cd=>3,de=>13} de.*cd.*bc.*ab reverse sort +S:V:{ab=>1,bc=>2,cd=>3,de=>13} 1.*13.*2.*3 sort by value +S:VR:{ab=>1,bc=>2,cd=>3,de=>13} 3.*2.*13.*1 reverse sort by value +S:VN:{ab=>1,bc=>2,cd=>3,de=>13} 1.*2.*3.*13 sort by value numeric +S:VNR:{ab=>1,bc=>2,cd=>3,d=>13} 13.*3.*2.*1 reverse sort by value numeric -- 2.11.4.GIT