Skip to content

Commit

Permalink
Add tests for isolation analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
LakshanWeerasinghe committed Mar 4, 2024
1 parent 68707cd commit 780c45f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public void testIsolatedParamNegative() {
validateError(result, index++, NON_ISOLATED_ARG_FOR_ISOLATED_PARAM_ERROR, 51, 59);
validateError(result, index++, NON_ISOLATED_ARG_FOR_ISOLATED_PARAM_ERROR, 57, 82);
validateError(result, index++, NON_ISOLATED_ARG_FOR_ISOLATED_PARAM_ERROR, 65, 22);
validateError(result, index++, NON_ISOLATED_ARG_FOR_ISOLATED_PARAM_ERROR, 66, 22);
validateError(result, index++, NON_ISOLATED_ARG_FOR_ISOLATED_PARAM_ERROR, 67, 22);
validateError(result, index++, NON_ISOLATED_ARG_FOR_ISOLATED_PARAM_ERROR, 81, 22);
validateError(result, index++, NON_ISOLATED_ARG_FOR_ISOLATED_PARAM_ERROR, 82, 22);
validateError(result, index++, NON_ISOLATED_ARG_FOR_ISOLATED_PARAM_ERROR, 83, 22);
Assert.assertEquals(result.getErrorCount(), index);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,22 @@ isolated function testInvalidNonIsolatedFuncArgInFixedLengthArrayRestArg() {
int[] marks = [75, 80, 45, 90];
(function (int x) returns boolean)[1] fns = [x => x > 79];
_ = marks.filter(...fns);
_ = marks.filter(...[...fns]);
_ = marks.filter(...[...[...fns]]);
}

type Rec record {|
function(int) returns (boolean) func;
|};

isolated function testInvalidNonIsolatedFuncArgAsMappingsInFixedLengthArrayRestArg() {
int[] marks = [75, 80, 45, 90];
(function (int x) returns boolean) func = x => x > 79;
Rec rec = {
func
};
_ = marks.filter(...rec);
_ = marks.filter(...<Rec>{...rec});
_ = marks.filter(...<Rec>{func});
_ = marks.filter(...<Rec>{func: func});
}

0 comments on commit 780c45f

Please sign in to comment.