~doctormo/template-direct-perl/trunk

« back to all changes in this revision

Viewing changes to t/01-templating.t

  • Committer: Martin Owens
  • Date: 2008-04-14 06:59:02 UTC
  • Revision ID: doctormo@gmail.com-20080414065902-rssui6jplyof0o0h
New maths module, lots of bug fixes and improved testing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!perl -T
 
1
#!/usr/bin/perl
2
2
 
3
 
use Test::More tests => 39;
 
3
use Test::More tests => 49;
4
4
use strict;
5
5
 
6
6
BEGIN {
17
17
                Simple1 => 'foo',
18
18
                Simple2 => 'bar',
19
19
                hash    => {
 
20
                        B => '6',
 
21
                        C => '5',
20
22
                        A => '1',
21
 
                        B => '2',
22
 
                        C => '3',
23
23
                },
24
24
                array   => [ 'A', 'B', 'C' ],
25
25
                array2  => [ [ 'A', 'B', 'C' ], [ 'D', 'E', 'F' ], [ 'G', 'H', 'I' ] ],
40
40
                                { name => 'Song' },
41
41
                        ] },
42
42
                ],
 
43
                array7 => [],
43
44
                integer => 12,
 
45
                number  => [ 4, 16, 2.2, 9.4, 2.4, 3.14159265 ],
44
46
                struct1 => [
45
47
                        { name => 'A',   value => '1' },
46
48
                        { name => 'B',   value => '2', children => [
81
83
        s1 => 'Variables 1',
82
84
        s2 => 'Variables 2',
83
85
        h0 => 'Hash Listing',
84
 
        h1 => 'Hash Variables 1',
85
 
        h2 => 'Hash Variables 2',
86
 
        h3 => 'Hash Listed Integer List',
 
86
        h1 => 'Sorted Hash Listing',
 
87
        h2 => 'Hash Variables 1',
 
88
        h3 => 'Hash Variables 2',
 
89
        h4 => 'Hash Listed Integer List',
87
90
        l0 => 'Array Listing',
88
91
        l1 => 'Array Variables 1',
89
92
        l2 => 'Array Variables 2',
111
114
        o6 => 'Conditional in Static Array',
112
115
        o7 => 'Conditional in Variable Array',
113
116
        o8 => 'Not Conditional in Variable Array',
 
117
    o9 => 'Array as conditional',
114
118
        l6 => 'Arrays can exists after conditionals',
115
119
        li => 'Lists within lists with the same values',
116
120
        p1 => 'Included Page',
 
121
        m1 => 'Simple Mathamatics',
 
122
        m2 => 'Mathamatical Precidence',
 
123
        m3 => 'Mathamatics with brackets',
 
124
        m4 => 'Formated Printing of Numbers',
 
125
        m5 => 'Data in calculations',
 
126
        m6 => 'Complex Mathamatical Precidence',
 
127
        m7 => 'Powers and Remainders',
 
128
        sort1 => 'Numericaly Sorted List Items',
117
129
);
118
130
my %expected = (
119
131
        s1 => 'foo',
120
132
        s2 => 'bar',
121
 
        h0 => 'A=1, C=3, B=2',
122
 
        h1 => '1',
123
 
        h2 => '2',
124
 
        h3 => 'A=1; C=1, 2, 3; B=1, 2',
 
133
        h0 => 'A=1, B=6, C=5',
 
134
        h1 => 'A=1, C=5, B=6',
 
135
        h2 => '1',
 
136
        h3 => '6',
 
137
        h4 => 'A=1; B=1, 2, 3, 4, 5, 6; C=1, 2, 3, 4, 5',
125
138
        l0 => 'A, B, C',
126
139
        l1 => 'A',
127
140
        l2 => 'B',
132
145
        nl1 => 'TRUE',
133
146
        i0 => '1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12',
134
147
        i1 => '12',
135
 
        i2 => '1, 2',
 
148
        i2 => '1, 2, 3, 4, 5, 6',
136
149
        i3 => '1, 2, 3, 4',
137
150
        c1 => '-A=1, C=, B=2, -',
138
151
        e1 => 'A:1,B:2(BA:21,BB:22),C:3(CA:31,CB:32,CC:33(CCA:331,CCB:332))',
149
162
        o6 => 'True',
150
163
        o7 => 'True',
151
164
        o8 => 'True',
 
165
        o9 => 'False',
152
166
        l6 => 'A, B, C',
153
167
        li => 'One=[A, Uno, Ngang], Two=[B, Duo, Song]',
154
 
        p1 => '*A=1, C=3, B=2*',
 
168
        p1 => '*A=1, C=5, B=6*',
 
169
        m1 => '4',
 
170
        m2 => '22',
 
171
        m3 => '18',
 
172
        m4 => '0.67',
 
173
        m5 => '4.36',
 
174
        m6 => '3.5',
 
175
        m7 => '50',
 
176
        sort1 => '2.2, 2.4, 3.14159265, 4, 9.4, 16',
155
177
);
156
178
 
157
179
my $a = is(ref($document), 'Template::Direct', 'Document object creation');