Skip to content

Commit

Permalink
Add typeof tests for resource segments
Browse files Browse the repository at this point in the history
  • Loading branch information
nipunayf committed Nov 6, 2023
1 parent 9ae8b30 commit 846a27f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@

import java.util.Optional;

import static io.ballerina.compiler.api.symbols.TypeDescKind.INT;
import static io.ballerina.compiler.api.symbols.TypeDescKind.STRING;
import static io.ballerina.compiler.api.symbols.TypeDescKind.TYPE_REFERENCE;
import static io.ballerina.compiler.api.symbols.TypeDescKind.UNION;
import static org.testng.Assert.assertEquals;
Expand Down Expand Up @@ -60,6 +62,14 @@ public Object[][] getPos() {
return new Object[][]{
{42, 23, 42, 54, UNION},
{42, 23, 42, 32, TYPE_REFERENCE},
{110, 9, 110, 12, STRING},
{111, 9, 111, 14, STRING},
{111, 17, 111, 25, STRING},
{112, 17, 111, 19, STRING},
{113, 15, 113, 19, INT},
{114, 15, 114, 16, INT},
{115, 9, 115, 14, STRING},
{115, 17, 115, 24, STRING},
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,27 @@ public function testPathSegmentOfAmbiguousResourceFunction() {
Bam bam = new;
bam->/path1/path2.post();
}

client class Resc {
resource function post user() {}

resource function post [string name]() {}

resource function get sports/[string name]() {}

resource function get pets/[int id]() {}

resource function get sports/[string name]/info () {}
}

function testTypeOfResourceSegments() {
Resc cl = new;
string myString = "";
int myInt = 0;
cl->/user.post();
cl->/sports/[myString]();
cl->/sports/["A"]();
cl->/pets/[myInt]();
cl->/pets/[1]();
cl->/sports/[myString]/
}

0 comments on commit 846a27f

Please sign in to comment.