Skip to content

Commit

Permalink
Add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chiranSachintha committed Mar 20, 2024
1 parent 834b86d commit b863355
Showing 1 changed file with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -308,14 +308,37 @@ function baz(int a, F1 b = function() returns int { return a + 1; }) returns int
return a + b();
}

function baz1(int a, F2 b = function() returns function() returns int { return function () returns int { return a; }; }) returns int {
function baz1(int a, F2 b = function() returns function() returns int { return function () returns int { return a; }; })
returns int {
F1 f = b();
return a + f();
}

function baz2(int a, function() returns int b = function() returns int { function (int x = a) returns int f =
function (int p) returns int { return p + 1;};
return f();
}) returns int {
return a + b();
}

function baz3(int a, function() returns int b = function() returns int { function (int x = a) returns int f =
function (int p) returns int {
function (int c = p) returns int g =
function (int c) returns int {
return c + 1;
};
return p + g() + 1;
};
return f();
}) returns int {
return a + b();
}

function testParamUseAsValueInAnonFuncWithDefaultForNextParam() {
assertEquality(baz(10), 21);
assertEquality(baz1(100), 200);
assertEquality(baz2(10), 21);
assertEquality(baz3(10), 32);
}

const ASSERTION_ERROR_REASON = "AssertionError";
Expand Down

0 comments on commit b863355

Please sign in to comment.