blob: 0fe06a254a8a7451c7f6a7fa60726e5dee80b5f5 (
plain)
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
|
# This file contains test code for the new KVS parser
# It does nothing useful
echo "Foreach test 1"
%arry[0] = "test0"
%arry[2] = "test2"
%i = 0
foreach(%x,%arry)
{
echo "Array item %i: (%x)"
%i++
}
echo "Foreach test 2"
%ahash{"keyA"} = "dataA"
%ahash{"keyB"} = "dataB"
%i = 0
foreach(%x,%ahash)
{
echo "Hash item %i: (%x)"
%i++
}
echo "Foreach test 3"
%i = 0
foreach(%x,$keys(%ahash))
{
echo "Hash entry %i: key->(%x), item->(%ahash{%x})"
%i++
}
echo "Foreach test 4"
%i = 0
foreach(%x,%arry,$keys(%ahash))
{
echo "Item %i: %x"
%i++
}
%tmp = 1
switch(%tmp)
{
case(1):
echo \%tmp was 1!
break;
case(2)
echo \%tmp was 2!
break;
default:
echo \%tmp was not 1 nor 2: it was %tmp!
break;
}
%tmp = 1
switch(%tmp)
{
case(1):
echo \%tmp was 1!
case(2)
echo \%tmp was 2!
break;
default:
echo \%tmp was either 1 or something different from 2 (%tmp)
break;
}
%tmp = "This is a test"
%tmp2 = "This is not a test"
switch(%tmp)
{
case(%tmp2)
echo \%tmp == \%tmp2
break;
case(%tmp)
{
# do not break here
echo "Yeah.. it's stupid.. \%tmp == \%tmp :D"
}
match("*TEST"):
echo "Matched *TEST"
regexp("[a-zA-Z ]*test"):
echo "Matched [a-zA-Z ]*text"
regexp("[a-zA-Z ]*not[a-zA-Z ]*"):
echo "Matched [a-zA-Z ]*not[a-zA-Z ]*"
default:
echo This is executed anyway (unless some break was called)
break;
}
|