From 03929d3350911485c8afda3b6beabd03ea86bee0 Mon Sep 17 00:00:00 2001 From: paulklint Date: Thu, 1 Aug 2024 11:42:12 +0200 Subject: [PATCH] Added tests for closures that use keyword parameters --- .../tests/functionality/KeywordParameter.rsc | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc b/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc index c0008ca8c5f..5f766695fed 100644 --- a/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc +++ b/src/org/rascalmpl/library/lang/rascal/tests/functionality/KeywordParameter.rsc @@ -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; } \ No newline at end of file