File: report.t

package info (click to toggle)
libconfig-model-perl 2.021-3%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 3,104 kB
  • sloc: perl: 20,550; makefile: 11
file content (157 lines) | stat: -rw-r--r-- 2,684 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# -*- cperl -*-
# $Author$
# $Date$
# $Revision$

use ExtUtils::testlib;
use Test::More tests => 9;
use Test::Memory::Cycle;
use Config::Model;

use warnings;
no warnings qw(once);

use strict;

use vars qw/$model/;

$model = Config::Model -> new(legacy => 'ignore',)  ;

my $arg = shift || '' ;
my $trace = $arg =~ /t/ ? 1 : 0 ;
$::verbose          = 1 if $arg =~ /v/;
$::debug            = 1 if $arg =~ /d/;
Config::Model::Exception::Any->Trace(1) if $arg =~ /e/;

use Log::Log4perl qw(:easy) ;
Log::Log4perl->easy_init($arg =~ /l/ ? $TRACE: $WARN);

ok(1,"compiled");

my $inst = $model->instance (root_class_name => 'Master', 
			     model_file => 't/big_model.pm',
			     instance_name => 'test1');
ok($inst,"created dummy instance") ;

my $root = $inst -> config_root ;
ok($root,"Config root created") ;

my $step = 'std_id:ab X=Bv - std_id:bc X=Av - a_string="toto tata" '
  .'lista=a,b,c,d olist:0 X=Av - olist:1 X=Bv - listb=b,c,d '
    . '! hash_a:X2=x hash_a:Y2=xy  hash_b:X3=xy my_check_list=X2,X3' ;
ok( $root->load( step => $step, experience => 'advanced' ),
  "set up data in tree with '$step'");

$step = 'tree_macro=XY';
ok( $root->load( step => $step, experience => 'advanced' ),
  "set up data in tree with '$step'");

my $report = $root->report;

print "report string:\n$report" if $trace ;

my $expect = <<'EOF' ;
std_id:ab X = Bv

std_id:ab DX = Dv

std_id:bc X = Av

std_id:bc DX = Dv

  lista:0 = a

  lista:1 = b

  lista:2 = c

  lista:3 = d

  listb:0 = b

  listb:1 = c

  listb:2 = d

  hash_a:X2 = x

  hash_a:Y2 = xy

  hash_b:X3 = xy

olist:0 X = Av

olist:0 DX = Dv

olist:1 X = Bv

olist:1 DX = Dv

 tree_macro = XY
	DESCRIPTION: controls behavior of other elements
	SELECTED: XY help

 string_with_def = "yada yada"

 a_uniline = "yada yada"

 a_string = "toto tata"

 int_v = 10

 my_check_list = X2,X3
EOF

is_deeply([split /\n/,$report ],
	  [split /\n/,$expect ],"check dump of only customized values ") ;

$report = $root->audit();
print "audit string:\n$report" if $trace  ;

$expect = <<'EOF' ;
std_id:ab X = Bv

std_id:bc X = Av

  lista:0 = a

  lista:1 = b

  lista:2 = c

  lista:3 = d

  listb:0 = b

  listb:1 = c

  listb:2 = d

  hash_a:X2 = x

  hash_a:Y2 = xy

  hash_b:X3 = xy

olist:0 X = Av

olist:1 X = Bv

 tree_macro = XY
	DESCRIPTION: controls behavior of other elements
	SELECTED: XY help

 a_string = "toto tata"

 my_check_list = X2,X3
EOF

is_deeply([split /\n/,$report ],
	  [split /\n/,$expect ],"check dump of all values ") ;

my $list =  $model->list_class_element ;
ok($list,"check list_class_element") ;
print $list if $trace ;

#use Tk::ObjScanner; Tk::ObjScanner::scan_object($model) ;
memory_cycle_ok($model);