/[webpac2]/trunk/t/5-output.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.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1069 - (hide annotations)
Tue Nov 27 23:54:43 2007 UTC (16 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1775 byte(s)
 r1673@llin:  dpavlin | 2007-11-28 00:46:28 +0100
 added tests for WebPAC::Output base class and added
 single_values option

1 dpavlin 1069 #!/usr/bin/perl -w
2    
3     use strict;
4     use blib;
5    
6     use Test::More tests => 8;
7    
8     BEGIN {
9     use_ok( 'WebPAC::Test' );
10     use_ok( 'WebPAC::Output' );
11     }
12    
13     my $ds = {
14     '000' => { foo => [ 42 ], bar => 'bug!' },
15     '900' => { foo => [
16     { a => '900a1', b => '900b1' },
17     { a => '900a2', b => '900b2' },
18     { a => '900a3', b => '900b3' },
19     ] },
20     '902' => { foo => [
21     { a => '900a1', b => '900b1' },
22     ] },
23    
24     'StRaNgE!Field' => { foo => 'value' },
25    
26     'array' => { foo => [ 'a' .. 'c' ] },
27     };
28    
29     my $hash;
30     ok( $hash = WebPAC::Output->ds_to_hash( $ds, 'foo' ), 'ds_to_hash' );
31     diag dump($hash) if $debug;
32     is_deeply( $hash, {
33     "000" => [42],
34     900 => [
35     { a => "900a1", b => "900b1" },
36     { a => "900a2", b => "900b2" },
37     { a => "900a3", b => "900b3" },
38     ],
39     902 => [{ a => "900a1", b => "900b1" }],
40     array => ["a", "b", "c"],
41     strange_field => "value",
42     }, 'is_deeply');
43    
44     ok( $hash = WebPAC::Output->ds_to_hash( $ds, 'foo', disable_key_mungle => 1 ), 'ds_to_hash disable_key_mungle' );
45     diag dump($hash) if $debug;
46     is_deeply( $hash, {
47     "000" => [42],
48     900 => [
49     { a => "900a1", b => "900b1" },
50     { a => "900a2", b => "900b2" },
51     { a => "900a3", b => "900b3" },
52     ],
53     902 => [{ a => "900a1", b => "900b1" }],
54     array => ["a", "b", "c"],
55     'StRaNgE!Field' => "value",
56     }, 'is_deeply');
57    
58     ok( $hash = WebPAC::Output->ds_to_hash( $ds, 'foo', single_values => 1 ), 'ds_to_hash single_values' );
59     diag dump($hash) if $debug;
60     is_deeply( $hash, {
61     "000" => 42,
62     900 => "{ a => \"900a1\", b => \"900b1\" } { a => \"900a2\", b => \"900b2\" } { a => \"900a3\", b => \"900b3\" }",
63     902 => "{ a => \"900a1\", b => \"900b1\" }",
64     array => "a b c",
65     strange_field => "value",
66     }, 'is_deeply');
67    
68    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26