]> git.proxmox.com Git - mirror_frr.git/blame - tests/lib/script1.lua
Merge pull request #9050 from LabNConsulting/chopps/reset-parallel
[mirror_frr.git] / tests / lib / script1.lua
CommitLineData
8a04c1e7
DL
1
2-- Positive testing
3
4535b611 4function foo(a, b)
8a04c1e7
DL
5 a = a + 1
6 b = b + 1
4535b611
DL
7 return {
8 a = a,
9 b = b,
10 }
11end
12
8a04c1e7
DL
13function bar(a, b)
14 a = a + 1
15 b = b + 1
16 c = 303
17 return {
18 b = b,
19 c = c,
20 }
21end
22
4535b611 23function fact(n)
8a04c1e7
DL
24 -- outer function must return a table
25 -- inner functions can be used to recurse or as helpers
4535b611
DL
26 function helper(m)
27 if m == 0 then
28 return 1
29 else
30 return m * helper(m - 1)
31 end
32 end
33 return {
5090d724 34 ans = helper(n)
4535b611
DL
35 }
36end
7948c5d2 37
8a04c1e7
DL
38-- Negative testing
39
7948c5d2
DL
40function bad_return1()
41end
42
43function bad_return2()
8a04c1e7 44 return 123
7948c5d2
DL
45end
46
47function bad_return3()
8a04c1e7
DL
48 return {}
49end
50
51function bad_return4()
7948c5d2
DL
52 error("Something bad!")
53end
54