/[webpac2]/trunk/t/5-output-sorted.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /trunk/t/5-output-sorted.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 938 - (hide annotations)
Wed Oct 31 12:17:11 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1214 byte(s)
 r1416@llin:  dpavlin | 2007-10-31 13:17:08 +0100
 minor tweaks

1 dpavlin 920 #!/usr/bin/perl -w
2    
3 dpavlin 938 use Test::More tests => 16;
4 dpavlin 920 use Test::Exception;
5     use Cwd qw/abs_path/;
6     use Data::Dump qw/dump/;
7     use blib;
8     use strict;
9    
10     BEGIN {
11     use_ok( 'WebPAC::Output::Sorted' );
12     }
13    
14     my $debug = shift @ARGV;
15    
16     ok(my $abs_path = abs_path($0), "abs_path");
17     $abs_path =~ s#/[^/]*$#/#; #
18     diag "abs_path: $abs_path";
19     my $path = "$abs_path/sorted/";
20    
21     ok(my $out = new WebPAC::Output::Sorted({
22     path => $path,
23     database => 'test',
24     clean => 1,
25     debug => $debug,
26     }), "new");
27    
28     ok( $out->init, 'init' );
29    
30     my $ds = {
31     'Source' => {
32     'name' => 'Izvor: ',
33     'sorted' => [ 'foo' ]
34     },
35     'ID' => {
36     'sorted' => 'id',
37     },
38     'Array' => {
39     'sorted' => [ qw/a1 a2 s3 a4 a5/ ],
40     },
41     };
42    
43     throws_ok { $out->add( ) } qr/need id/, 'add without params';
44     throws_ok { $out->add( 42 ) } qr/need ds/, 'add without ds';
45    
46     ok( $out->add( 42, $ds ), 'add 42' );
47    
48     ok( $out->add( 99, { foo => { sorted => 'bar' } } ), 'add 99' );
49    
50     ok( $out->add( 100, { foo => { sorted => [ qw/foo bar baz/ ] } } ), 'add 100' );
51    
52     ok( -e $out->path, "created $path" );
53    
54     diag $out->path," eq ",$path;
55     cmp_ok( $out->path, 'eq', $path, 'path' );
56    
57     ok( $out->finish, 'finish' );
58    
59 dpavlin 938 foreach my $l ( qw/source id array foo/ ) {
60     ok( -e "$path/$l.txt", "list $l exists" );
61     }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26