-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #39600 from ushirask/issue_39341
Throw error when field access is used with a map of `xml`
- Loading branch information
Showing
9 changed files
with
79 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 5 additions & 28 deletions
33
...ina-unit-test/src/test/resources/test-src/types/xml/xml-attribute-access-lax-behavior.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,13 @@ | ||
import ballerina/lang.'xml; | ||
|
||
function testXMLAsMapContent() returns [string|error?, string|error?, boolean] { | ||
map<xml> xmap = getXMLMap(); | ||
string|error val = xmap.a.attr; | ||
string|error? val2 = xmap.a?.attr; | ||
string|error? val3 = xmap.a?.attr2; | ||
return [val, val2, val3 is ()]; | ||
} | ||
|
||
function testXMLASMapContentInvalidKey() returns string|error? { | ||
map<xml> xmap = getXMLMap(); | ||
string|error val = xmap.b.attr; | ||
return val; | ||
} | ||
|
||
function testXMLAttributeWithNSPrefix() returns | ||
[string|error?, string|error?, string|error?, boolean, boolean] { | ||
map<xml> xmap = {}; | ||
xmap["a"] = xml `<elem xmlns="ns-uri" attr="val" xml:space="preserve"></elem>`; | ||
string|error val = xmap.a.'xml:space; | ||
string|error? val2 = xmap.a?.'xml:space; | ||
string|error? val3 = xmap.b?.'xml:space; | ||
return [val, val2, val3]; | ||
function testXMLAttributeWithNSPrefix() returns [string|error?, string|error?] { | ||
xml a = xml `<elem xmlns="ns-uri" attr="val" xml:space="preserve"></elem>`; | ||
string|error val = a.'xml:space; | ||
string|error? val2 = a?.'xml:space; | ||
return [val, val2]; | ||
} | ||
|
||
function testXMLDirectAttributeAccess() returns [boolean, boolean, boolean, boolean] { | ||
xml x = xml `<elem xmlns="ns-uri" attr="val" xml:space="default"></elem>`; | ||
return [x.attr is string, x?.attr is string, x.attrNon is error, x?.attrNon is ()]; | ||
} | ||
|
||
function getXMLMap() returns map<xml> { | ||
map<xml> xmap = {}; | ||
xmap["a"] = xml `<elem attr="val"></elem>`; | ||
return xmap; | ||
} |