Skip to content

Commit

Permalink
Add more tests for user defined import prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
prakanth97 committed May 30, 2024
1 parent 97dc5ec commit 5430f78
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,20 @@ public void testComplexUnionTypeCaseWhenUserDefinedModulePrefix() {
Assert.assertEquals(errorDiagnosticsList.get(0).diagnosticInfo().messageFormat(),
"invalid type: expected a record type");
}

@Test
public void testComplexUnionTypeCaseWhenUserDefinedModulePrefix2() {
DiagnosticResult diagnosticResult =
CompilerPluginTestUtils.loadPackage("sample_package_12").getCompilation().diagnosticResult();
List<Diagnostic> errorDiagnosticsList = diagnosticResult.diagnostics().stream()
.filter(r -> r.diagnosticInfo().severity().equals(DiagnosticSeverity.ERROR))
.collect(Collectors.toList());
Assert.assertEquals(errorDiagnosticsList.size(), 3);
Assert.assertEquals(errorDiagnosticsList.get(0).diagnosticInfo().messageFormat(),
"invalid type: expected a record type");
Assert.assertEquals(errorDiagnosticsList.get(1).diagnosticInfo().messageFormat(),
"invalid type: expected a record type");
Assert.assertEquals(errorDiagnosticsList.get(2).diagnosticInfo().messageFormat(),
"invalid type: expected a record type");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[package]
org = "xmldata_test"
name = "sample_12"
version = "0.1.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ballerina/data.xmldata as xd;

public function testFunc() returns error? {
string str = string `{"a": 1, "b": "str"}`;
UnionType _ = check xd:parseString(str);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ballerina/data.xmldata as xd2;

public function testFunc2() returns error? {
string str = string `{"a": 1, "b": "str"}`;
UnionType _ = check xd2:parseString(str);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import ballerina/data.xmldata;

public function testFunc3() returns error? {
string str = string `{"a": 1, "b": "str"}`;
UnionType _ = check xmldata:parseString(str);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
type UnionType record {|int a;|}|record {|string b;|};

0 comments on commit 5430f78

Please sign in to comment.