File: report.t

package info (click to toggle)
libconfig-model-perl 2.155-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,172 kB
  • sloc: perl: 15,117; makefile: 19
file content (145 lines) | stat: -rw-r--r-- 2,303 bytes parent folder | download | duplicates (4)
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
# -*- cperl -*-
use ExtUtils::testlib;
use Test::More;
use Test::Memory::Cycle;
use Config::Model;
use Config::Model::Tester::Setup qw/init_test/;

use warnings;
use strict;
use lib "t/lib";

my ($model, $trace) = init_test();

my $inst = $model->instance(
    root_class_name => 'Master',
    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 ), "set up data in tree with '$step'" );

$step = 'tree_macro=XY';
ok( $root->load( step => $step ), "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, "memory cycle");

done_testing;