Skip to content

Commit

Permalink
Tests for using keyword parameters in inner functions
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Aug 7, 2024
1 parent 37e47cb commit 74f6bed
Showing 1 changed file with 65 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,68 @@ test bool keywordParameterInClosure3(){
return f(n, int(int x) { return x + d; });
}
return g(7, d=5) == 19;
}
}

// Using keyword parameters in inner functions


int outer1(int t, int tabSize=4){
int rec(int t) = t + tabSize when t > 10;
default int rec(int t) = t;
return rec(t);
}

test bool outer1_1() = outer1(1) == 1;
test bool outer1_11() = outer1(11) == 15;
test bool outer1_11_kw() = outer1(11, tabSize=40) == 51;

int outer2(int t, int tabSize=4){
int rec(int t, int innerKwp = 5) = t + tabSize + innerKwp when t > 10;
default int rec(int t) = t;
return rec(t);
}

test bool outer2_1() = outer2(1) == 1;
test bool outer2_11() = outer2(11) == 20;
test bool outer2_11_kw() = outer2(11, tabSize=40) == 56;

int outer3(int t, int tabSize=4){
int rec(int t){
int rec_inner(int t) = t + tabSize when t > 10;
default int rec_inner(int t) = t;
return rec_inner(t);
}
return rec(t);
}

test bool outer3_1() = outer3(1) == 1;
test bool outer3_11() = outer3(11) == 15;
test bool outer3_11_kw() = outer3(11, tabSize=40) == 51;


int outer4(int t, int tabSize=4){
int rec(int t){
int rec_inner(int t, int innerKwp = 5) = t + tabSize + innerKwp when t > 10;
default int rec_inner(int t) = t;
return rec_inner(t);
}
return rec(t);
}

test bool outer4_1() = outer4(1) == 1;
test bool outer4_11() = outer4(11) == 20;
test bool outer4_11_kw() = outer4(11, tabSize=40) == 56;


int outer5(int t, int tabSize=4){
int rec(int t){
int rec_inner(int t, int innerKwp = 5) = t + tabSize + innerKwp when t > 10;
default int rec_inner(int t) = t;
return rec_inner(t, innerKwp = 50);
}
return rec(t);
}

test bool outer5_1() = outer5(1) == 1;
test bool outer5_11() = outer5(11) == 65;
test bool outer5_11_kw() = outer5(11, tabSize=40) == 101;

0 comments on commit 74f6bed

Please sign in to comment.