Skip to content

Commit

Permalink
fix(test): missing function parameters (#461)
Browse files Browse the repository at this point in the history
* fix(test): missing function parameters

* Update function_optional_argument_array.ab

* fix(test): after review

* fix(test): review
  • Loading branch information
Mte90 authored Sep 11, 2024
1 parent 805031f commit c1290df
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/tests/validity/function_optional_argument_array.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Output
// 1100

fun sum_array(a : [Num] = [Num]): Num {
let sum = 0
loop n in a {
sum += n;
}
return sum;
}
let x = [100,1000]
let result = sum_array(x)
echo result
12 changes: 12 additions & 0 deletions src/tests/validity/function_optional_argument_array_default.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Output
// 1000

fun sum_array(a : [Num] = [100,200,300,400]): Num {
let sum = 0
loop n in a {
sum += n;
}
return sum;
}
let result = sum_array();
echo result
7 changes: 7 additions & 0 deletions src/tests/validity/function_optional_argument_generic.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Output
// hello

fun echo_var(a = 100){
echo a
}
echo_var("hello")
9 changes: 9 additions & 0 deletions src/tests/validity/function_optional_argument_int.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Output
// 1010

fun addition(a: Num, b: Num = 100): Num {
return a + b
}

let result = addition(10, 1000)
echo result
7 changes: 7 additions & 0 deletions src/tests/validity/function_optional_argument_int_default.ab
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Output
// 110
fun addition(a: Num, b: Num = 100): Num {
return a + b
}
let result = addition(10)
echo result

0 comments on commit c1290df

Please sign in to comment.