Annotation of parser3/tests/246.html, revision 1.3

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

E-mail: