diff --git a/tests/jballerina-unit-test/src/test/resources/test-src/types/xml/xml-indexed-access.bal b/tests/jballerina-unit-test/src/test/resources/test-src/types/xml/xml-indexed-access.bal index 90bf4e4bf061..5932de9c9c63 100644 --- a/tests/jballerina-unit-test/src/test/resources/test-src/types/xml/xml-indexed-access.bal +++ b/tests/jballerina-unit-test/src/test/resources/test-src/types/xml/xml-indexed-access.bal @@ -451,36 +451,92 @@ type XmlType2 xml; type XmlType3 XmlType1|XmlType2; function testXmlIndexedAccessWithUnionType() { + xml value; xml:Element|xml:Comment x1 = xml `abc`; - assert(x1[0], xml `abc`); - assert(x1[1], xml ``); + value = x1[0]; + assert(value, xml `abc`); + assertTrue(typeof value is typedesc); + value = x1[1]; + assert(value, xml ``); + assertTrue(typeof value is typedesc); + xml:Element|xml:Text x2 = xml `Hello World`; - assert(x2[0], xml `Hello World`); - assert(x2[0][1], xml ``); + value = x2[0]; + assert(value, xml `Hello World`); + assertTrue(typeof value is typedesc); + value = x2[0][1]; + assert(value, xml ``); + assertTrue(typeof value is typedesc); + xml:Element|xml:ProcessingInstruction x3 = xml ``; - assert(x3[0], xml ``); - assert(x3[1][100], xml ``); + value = x3[0]; + assert(value, xml ``); + assertTrue(typeof value is typedesc); + value = x3[1][100]; + assert(value, xml ``); + assertTrue(typeof value is typedesc); + xml:Element|xml:Comment x4 = xml ``; - assert(x4[0], xml ``); - assert(x4[50], xml ``); + value = x4[0]; + assert(value, xml ``); + assertTrue(typeof value is typedesc); + value = x4[10]; + assert(value, xml ``); + assertTrue(typeof value is typedesc); + xml:Text|xml:Comment x5 = xml ``; - assert(x5[0], xml ``); + value = x5[0]; + assert(value, xml ``); + assertTrue(typeof value is typedesc); + xml:ProcessingInstruction|xml:Comment x6 = xml ``; - assert(x6[0], xml ``); + value = x6[0]; + assert(value, xml ``); + assertTrue(typeof value is typedesc); + xml:ProcessingInstruction|xml:Text x7 = xml `Test Text`; - assert(x7[0], xml `Test Text`); + value = x7[0]; + assert(value, xml `Test Text`); + assertTrue(typeof value is typedesc); + xml|xml:Comment x8 = xml `abcdef`; - assert(x8[0], xml `abc`); + value = x8[0]; + assert(value, xml `abc`); + assertTrue(typeof value is typedesc); + xml|xml x9 = xml `ghijkl`; - assert(x9[0], xml `ghi`); + value = x9[0]; + assert(value, xml `ghi`); + assertTrue(typeof value is typedesc); + xml|xml x10 = xml `Dan Brown`; - assert(x10[0], xml `Dan Brown`); - assert(x10[50], xml ``); + value = x10[0]; + assert(value, xml `Dan Brown`); + assertTrue(typeof value is typedesc); + value = x10[1]; + assert(value, xml ``); + assertTrue(typeof value is typedesc); + XmlType1 x11 = xml `Hello!`; - assert(x11[0], xml `Hello!`); - XmlType3 x12 = xml `Sherlock Holmes`; - assert(x12[0], xml `Sherlock Holmes`); - assert(x12[50][1], xml ``); + value = x11[0]; + assert(value, xml `Hello!`); + assertTrue(typeof value is typedesc); + + XmlType2 x12 = xml `Sherlock HolmesDetective`; + value = x12[0]; + assert(value, xml `Sherlock Holmes`); + assertTrue(typeof value is typedesc); + value = x12[1]; + assert(value, xml `Detective`); + assertTrue(typeof value is typedesc); + + XmlType3 x13 = xml `Sherlock Holmes`; + value = x13[0]; + assert(value, xml `Sherlock Holmes`); + assertTrue(typeof value is typedesc); + value = x13[50][1]; + assert(value, xml ``); + assertTrue(typeof value is typedesc); } function testInvalidXMLUnionAccessWithNegativeIndex() {