summaryrefslogtreecommitdiffstats
path: root/src/tests/keywords/expr
blob: 7645931bdc62149217c29efa1e15b670fd4213e0 (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
102
103
104
105
106
107
108
#
#  PRE: update if
#
update control {
       Cleartext-Password := 'hello'
}

update reply {
	Filter-Id := "filter"
}

#
#  Simple
#
if ("%{expr: 1 + 2 + 3 + 4}" != 10) {
	update reply {
		Filter-Id := "fail-1"
	}
}

#
#  Precedence
#
if ("%{expr: 1 + 2 * 3 + 4}" != 11) {
	update reply {
		Filter-Id := "fail-2"
	}
}

#
#  attribute references
#
update request {
	Tmp-Integer-0 = 1
	Tmp-Integer-1 = 3
	Tmp-Integer-2 = 4
	Tmp-Date-0 = "%l"
}

if ("%{expr: 1 + 2 * &Tmp-Integer-1 + 4}" != 11) {
	update reply {
		Filter-Id := "fail-3"
	}
}

if ("%{expr: 1 + 2 * (&Tmp-Integer-1 + 4)}" != 15) {
	update reply {
		Filter-Id := "fail-4"
	}
}

if ("%{expr: 1 + 2 * (&Tmp-Integer-1 + &Tmp-Integer-2)}" != 15) {
	update reply {
		Filter-Id := "fail-5"
	}
}

if ("%{expr: 1 & ~1}" != 0) {
	update reply {
		Filter-Id := "fail-6"
	}
}

if ("%{expr: 1 & ~2}" != 1) {
	update reply {
		Filter-Id := "fail-7"
	}
}

if ("%{expr: -1 * 2}" != -2) {
	update reply {
		Filter-Id := "fail-8"
	}
}

if ("%{expr: 2 - -1}" != 3) {
	update reply {
		Filter-Id := "fail-9"
	}
}

if ("%{expr: 1 << 2 | 1}" != 5) {
	update reply {
		Filter-Id := "fail-10"
	}
}

if ("%{expr: &Tmp-Date-0}" <= 0) {
	update reply {
		Filter-Id := "fail-11"
	}
}

#
#  Unary negation
#
if ("%{expr: 6 + -(1 + 3)}" != 2) {
	update reply {
		Filter-Id := "fail-12"
	}
}

if ("%{expr: 6 * -&Tmp-Integer-2}" != -24) {
	update reply {
		Filter-Id := "fail-13"
	}
}