Skip to content

Commit

Permalink
Added tests for closures that use keyword parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulKlint committed Aug 1, 2024
1 parent f683d12 commit 03929d3
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -244,4 +244,33 @@ data GGG = ggg(rel[int a, int b] r = {<1,2>});
test bool fieldsNamesOfKeywordParametersIssue1851() {
ax = ggg();
return ax.r.a == {1};
}

// Keyword parameters used in closures

test bool keywordParameterInClosure1(){
int f(int n, int(int) fun) = n + fun(n);

int g(int d = 3){
return f(7, int(int x) { return x + d; });
}
return g(d = 5) == 19;
}

test bool keywordParameterInClosure2(){
int f(int n, int(int) fun) = n + fun(n);

int g(int n, int d = 2 * n){
return f(n, int(int x) { return x + d; });
}
return g(7) == 28;
}

test bool keywordParameterInClosure3(){
int f(int n, int(int) fun) = n+ fun(n);

int g(int n, int d = 2 * n){
return f(n, int(int x) { return x + d; });
}
return g(7, d=5) == 19;
}

0 comments on commit 03929d3

Please sign in to comment.