Skip to content

Commit dc1571e

Browse files
Added tests for invalid number of arguments in function calls
1 parent 2d5267d commit dc1571e

3 files changed

Lines changed: 49 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
bundle agent main
2+
{
3+
vars:
4+
"users1"
5+
slist => getusers(); # This is valid, zero args will not filter any, not caught at all, syntax-desc shows 2 params
6+
"users2"
7+
slist => getusers("a");
8+
"users3"
9+
slist => getusers("a", "b");
10+
"users4"
11+
slist => getusers("a", "b", "c", "d"); # This is allowed to run, but the c and d gets ignored
12+
"file1"
13+
string => readfile(); # Should fail
14+
"file2"
15+
string => readfile("/tmp/tmp.txt"); # Valid
16+
reports:
17+
"found user1 $(users1)";
18+
"found user2 $(users2)";
19+
"found user3 $(users3)";
20+
"found user4 $(users4)";
21+
"found file1 $(file1)";
22+
"found file2 $(file2)";
23+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
"string1"
3+
string => canonify();
4+
^--------^
5+
Error: Expected 1 arguments, received 0 at tests/lint/013_invalid_num_args_func.x.cf:5:15
6+
7+
"string3"
8+
string => canonify("test", "test");
9+
^----------------------^
10+
Error: Expected 1 arguments, received 2 at tests/lint/013_invalid_num_args_func.x.cf:9:15
11+
FAIL: tests/lint/013_invalid_num_args_func.x.cf (2 errors)
12+
Failure, 2 errors in total.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
bundle agent main
2+
{
3+
vars:
4+
"string1"
5+
string => canonify();
6+
"string2"
7+
string => canonify("test");
8+
"string3"
9+
string => canonify("test", "test");
10+
reports:
11+
"Test1 => $(string1)";
12+
"Test2 => $(string2)";
13+
"Test3 => $(string3)";
14+
}

0 commit comments

Comments
 (0)