Skip to content
Newer
Older
100755 66 lines (35 sloc) 1.93 KB
1ed469a @supernovus Cleanups, another() method, initial List utils.
authored Oct 7, 2010
1 #!/usr/bin/env perl6
2
3 BEGIN { @*INC.unshift: './lib' }
4
5 use Test;
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
6 use Flower::TAL;
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
7 use Exemel;
1ed469a @supernovus Cleanups, another() method, initial List utils.
authored Oct 8, 2010
8
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
9 plan 7;
1ed469a @supernovus Cleanups, another() method, initial List utils.
authored Oct 8, 2010
10
11 my $xml = '<?xml version="1.0"?>';
12
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
13 ## test 1, group
14
e6899d3 @supernovus Added get-args method to Flower, and updated modifiers to use it.
authored Oct 9, 2010
15 my $template = '<table><tr tal:repeat="row group:items 2"><td tal:repeat="col row" tal:content="col"/></tr></table>';
1ed469a @supernovus Cleanups, another() method, initial List utils.
authored Oct 8, 2010
16
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
17 my $tal = Flower::TAL.new();
1ed469a @supernovus Cleanups, another() method, initial List utils.
authored Oct 8, 2010
18
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
19 $tal.add-tales('List');
1ed469a @supernovus Cleanups, another() method, initial List utils.
authored Oct 8, 2010
20
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
21 is ~$tal.parse($template, :items(['a'..'d'])), $xml~'<table><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table>', 'group: modifier';
1ed469a @supernovus Cleanups, another() method, initial List utils.
authored Oct 8, 2010
22
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
23 ## test 2, sort
1ed469a @supernovus Cleanups, another() method, initial List utils.
authored Oct 8, 2010
24
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
25 $template = '<fresh><i tal:repeat="item sort:items" tal:content="item"/></fresh>';
1ed469a @supernovus Cleanups, another() method, initial List utils.
authored Oct 8, 2010
26 my @items = 5,3,7,1,2;
27
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
28 is ~$tal.parse($template, :items(@items)), $xml~'<fresh><i>1</i><i>2</i><i>3</i><i>5</i><i>7</i></fresh>', 'sort: modifier';
1ed469a @supernovus Cleanups, another() method, initial List utils.
authored Oct 8, 2010
29
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
30 ## test 3, reverse
31
32 $template = '<reverse><i tal:repeat="item reverse:items" tal:content="item"/></reverse>';
33
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
34 is ~$tal.parse($template, :items(@items)), $xml~'<reverse><i>2</i><i>1</i><i>7</i><i>3</i><i>5</i></reverse>', 'reverse: modifier';
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
35
36 ## test 4, limit
37
38 $template = '<limit><i tal:repeat="item limit: items 2" tal:content="item"/></limit>';
39
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
40 is ~$tal.parse($template, :items(@items)), $xml~'<limit><i>5</i><i>3</i></limit>', 'limit: modifier';
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
41
42 ## test 5, limit using a variable
43
44 $template = '<limit><i tal:repeat="item limit: items ${limit}" tal:content="item"/></limit>';
45
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
46 is ~$tal.parse($template, :items(@items), :limit(3)), $xml~'<limit><i>5</i><i>3</i><i>7</i></limit>', 'limit: modifier using a variable';
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
47
48 ## test 6, shuffle
49
50 $template = '<shuffle><i tal:repeat="item shuffle: items" tal:content="item"/></shuffle>';
51
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
52 my $doc = $tal.parse($template, :items(@items));
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
53
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
54 my @is = $doc.root.elements(:TAG<i>);
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
55 is @is.elems, 5, 'shuffle: proper number of elements returned';
56
57 ## test 7, pick
58
59 $template = '<shuffle><i tal:repeat="item pick: items 3" tal:content="item"/></shuffle>';
60
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
61 $doc = $tal.parse($template, :items(@items));
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
62
cb40118 @supernovus New refactoring branch is done and all tests pass.
authored Oct 13, 2011
63 @is = $doc.root.elements(:TAG<i>);
031c66b @supernovus Lots of changes, this thing is getting complex. I wish Rakudo was fas…
authored Oct 10, 2010
64 is @is.elems, 3, 'pick: proper number of elements returned';
65
Something went wrong with that request. Please try again.