/[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

Contents of /trunk/t/5-output.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1256 - (show annotations)
Tue Jul 28 12:40:46 2009 UTC (14 years, 9 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1780 byte(s)
use code from lib insted of blib

1 #!/usr/bin/perl -w
2
3 use strict;
4 use lib 'lib';
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