···11+// Test rest parameters in function definitions
22+33+// Test 1: Basic rest parameter
44+function sum(...numbers) {
55+ let total = 0;
66+ for (let i = 0; i < numbers.length; i++) {
77+ total = total + numbers[i];
88+ }
99+ return total;
1010+}
1111+1212+Ant.println("Test 1 - Basic rest params:");
1313+Ant.println(sum(1, 2, 3, 4, 5)); // Should print 15
1414+1515+// Test 2: Rest parameter with regular parameters
1616+function greet(greeting, ...names) {
1717+ let result = greeting;
1818+ for (let i = 0; i < names.length; i++) {
1919+ result = result + " " + names[i];
2020+ }
2121+ return result;
2222+}
2323+2424+Ant.println("\nTest 2 - Rest params with regular params:");
2525+Ant.println(greet("Hello", "Alice", "Bob", "Charlie")); // Should print "Hello Alice Bob Charlie"
2626+2727+// Test 3: Rest parameter with no arguments passed
2828+function noArgs(...args) {
2929+ return args.length;
3030+}
3131+3232+Ant.println("\nTest 3 - Rest params with no args:");
3333+Ant.println(noArgs()); // Should print 0
3434+3535+// Test 4: Rest parameter with single argument
3636+function singleArg(...args) {
3737+ return args[0];
3838+}
3939+4040+Ant.println("\nTest 4 - Rest params with single arg:");
4141+Ant.println(singleArg(42)); // Should print 42
4242+4343+// Test 5: Arrow function with rest parameters
4444+const multiply = (...factors) => {
4545+ let result = 1;
4646+ for (let i = 0; i < factors.length; i++) {
4747+ result = result * factors[i];
4848+ }
4949+ return result;
5050+};
5151+5252+Ant.println("\nTest 5 - Arrow function with rest params:");
5353+Ant.println(multiply(2, 3, 4)); // Should print 24
5454+5555+// Test 6: Multiple regular params with rest
5656+function compute(operation, initial, ...values) {
5757+ let result = initial;
5858+ if (operation === "add") {
5959+ for (let i = 0; i < values.length; i++) {
6060+ result = result + values[i];
6161+ }
6262+ }
6363+ if (operation === "multiply") {
6464+ for (let i = 0; i < values.length; i++) {
6565+ result = result * values[i];
6666+ }
6767+ }
6868+ return result;
6969+}
7070+7171+Ant.println("\nTest 6 - Multiple params with rest:");
7272+Ant.println(compute("add", 10, 5, 3, 2)); // Should print 20
7373+Ant.println(compute("multiply", 2, 3, 4)); // Should print 24
7474+7575+// Test 7: Rest parameter is an actual array
7676+function checkArray(...items) {
7777+ return items.length;
7878+}
7979+8080+Ant.println("\nTest 7 - Rest param is array:");
8181+Ant.println(checkArray("a", "b", "c", "d")); // Should print 4