Annotation of parser3/tests/432.html, revision 1.3
1.1 moko 1: @main[]
2: $a[^array::create[]]
3: ^first_and_last[Empty hash (^$a[^^hash::create[]]);$a]
4:
5: $a.1[a]
6: ^first_and_last[One element was added (^$a.1[a]);$a]
7:
8: ^a.delete(1)
9: ^first_and_last[One element was deleted (^^a.delete[1]);$a]
10:
11: $a.1[a]
12: ^first_and_last[One element was added (^$a.1[a]);$a]
13:
1.2 moko 14: $a[^array::copy[
1.1 moko 15: $.1[a]
16: $.2[b]
17: $.3[c]
18: $.4[d]
19: $.5[e]
20: ]]
21: ^first_and_last[Hash with 5 elements (^$a[ ^$.1[a] ^$.2[b] ^$.3[c] ^$.4[d] ^$.5[e] ]);$a]
22:
23: ^a.delete(5)
24: ^first_and_last[The last element was deleted (^^a.delete[5]);$a]
25:
26: ^a.delete(1)
27: ^first_and_last[The first element was deleted (^^a.delete[1]);$a]
28:
29: $a.5[e]
30: ^first_and_last[One element was added at the end (^$a.5[e]);$a]
31:
32: $a.3[cc]
33: ^first_and_last[One element was added at the middle (^$a.3[cc]);$a]
34:
1.2 moko 35: $a[^array::copy[
1.1 moko 36: $.1[a]
37: $.2[b]
38: $.3[c]
39: $.4[d]
40: $.5[e]
41: ]]
1.3 ! moko 42: ^test_at[]
! 43: $a[a;b;c;d;e]
! 44: ^test_at[]
! 45:
! 46: @test_at[]
! 47: <h3>_at on array with ^a.count[] elements (^$a[ ^a.foreach[k;v]{^$.${k}[$v]}[ ] ])</h3>
1.1 moko 48: ^at(0)
49: ^at(1)
50: ^at(2)
51: ^at(3)
52: ^at(4)
53:
54: <br />
55: ^at(-1)
56: ^at(-2)
57: ^at(-3)
58: ^at(-4)
59: ^at(-5)
60:
61: <br />
62: ^at(0)[key]
63: ^at(1)[key]
64: ^at(2)[key]
65: ^at(3)[key]
66: ^at(4)[key]
67:
68: <br />
69: ^at(0)[value]
70: ^at(1)[value]
71: ^at(2)[value]
72: ^at(3)[value]
73: ^at(4)[value]
74:
75: <br />
76: ^at(0)[hash]
77: ^at(1)[hash]
78: ^at(2)[hash]
79: ^at(3)[hash]
80: ^at(4)[hash]
81:
1.3 ! moko 82: ^^a._at[first;hash]=^print[^a._at[first;hash]]<br />
! 83: ^^a._at[last;hash]=^print[^a._at[last;hash]]<br />
! 84:
1.1 moko 85: <br />
86: # check if values preserve tainting. keys are always lost tainting
87: <h3>The first element was replaced (^$a.1[b&b])</h3>
88: $a.1[b&b]
89: ^^a._at[first;hash]=^print[^a._at[first;hash]]<br />
90: ^at(0)[key]
91: ^at(0)[value]
92: ^at(0)[hash]
93: <h3>One element was added at the end (^$a.100[^^taint[d&d]])</h3>
94: $a.100[^taint[d&d]]
95: ^at(5)[key]
96: ^at(5)[value]
97: ^at(5)[hash]
98: ^^a._at[last;hash]=^print[^a._at[last;hash]]<br />
99:
100: <br />
101: ^do[^^a._at[]]{must fail^a._at[]}
102: ^do[^^a._at[first^;key^;hren]]{must fail^a._at[first;key;hren]}
103: ^do[^^a._at(1){code}]{must fail^a._at(1){code}}
104: ^do[^^a._at(1)(true)]{must fail^a._at(1)(true)}
105: ^do[^^a._at[hren]]{must fail^a._at[hren]}
106: ^do[^^a._at[first][hren]]{must fail^a._at[first][hren]}
107: ^do[^^a._at[last][hren]]{must fail^a._at[last][hren]}
108: ^do[^^a._at(1)[hren]]{must fail^a._at(1)[hren]}
109:
110: @at[i;type]
111: ^^a._at($i)^if(def $type){[$type]}=^print[^if(def $type){^a._at($i)[$type]}{^a._at($i)}]<br />
112:
113: @first_and_last[sTitle;a]
114: ^if(def $sTitle){<h3>$sTitle</h3>}
115: first:last='^a._at[first]':'^a._at[last;value]'<br />
116: first_key:last_key='^a._at[first;key]':'^a._at[last;key]'<br />
117:
118: @do[label;code]
119: $label=^try{${code}}{$exception.handled(true)<b>^taint[as-is;$exception.comment]</b>}<br />
120:
121: @print[u][k;v]
122: ^if($u is "array" || $u is "hash"){
123: $result[^u.foreach[k;v]{'$k':'$v'}[, ]]
124: }{
125: $result[$u]
126: }
E-mail: