Skip to content

Commit

Permalink
Add RegExp readonly intersection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
LakshanWeerasinghe committed Dec 11, 2023
1 parent 678ba28 commit dcf7afb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ function testRuntimeIsTypeForInherentlyImmutableBasicTypes() {
'xml:Text xmlText = xml `xml text`;
any n = xmlText;
assertTrue(n is readonly);

any reg1 = re `pattern`;
assertTrue(reg1 is readonly);

readonly reg2 = re `pattern`;
assertTrue(reg2 is readonly);
}

function testRuntimeIsTypeForNeverImmutableBasicTypes() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ function testRegExpWithUserDefinedType() {
type T1 string:RegExp & readonly;
type T2 regexp:RegExp & readonly;

type Foo record {|
int e;
readonly regexp:RegExp f;
|};

Foo & readonly rf = {e: 1, f: re `test`};

function testRegExpReadonlyLocalVars() {
string:RegExp & readonly x1 = re `test`;
T1 & readonly x2 = re `test`;
(T2 & readonly) & string:RegExp x3 = re `test`;
}

const ASSERTION_ERROR_REASON = "AssertionError";

function assertEquality(any|error expected, any|error actual) {
Expand Down

0 comments on commit dcf7afb

Please sign in to comment.