Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix conformance tests #1324

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function init() {
io:println(a1 + a7); // @output Infinity

io:println(a2 + a1); // @output 4.9E-324
io:println(a2 + a2); // @output 1.0E-323
io:println(a2 + a2); // @output 9.9E-324
io:println(a2 + a3); // @output 124.0
io:println(a2 + a4); // @output 75647.096547382
io:println(a2 + a5); // @output 4657382.1234
Expand Down Expand Up @@ -90,7 +90,7 @@ function init() {
io:println(a1 + a7); // @output -Infinity

io:println(a2 + a1); // @output -4.9E-324
io:println(a2 + a2); // @output -1.0E-323
io:println(a2 + a2); // @output -9.9E-324
io:println(a2 + a3); // @output -124.0
io:println(a2 + a4); // @output -75647.096547382
io:println(a2 + a5); // @output -4657382.1234
Expand Down Expand Up @@ -506,7 +506,7 @@ function init() {
io:println((a1 + a8).toBalString()); // @output ()

io:println(a2 + a1); // @output 4.9E-324
io:println(a2 + a2); // @output 1.0E-323
io:println(a2 + a2); // @output 9.9E-324
io:println(a2 + a3); // @output 124.0
io:println(a2 + a4); // @output 75647.096547382
io:println(a2 + a5); // @output 4657382.1234
Expand Down Expand Up @@ -588,7 +588,7 @@ function init() {
io:println((a1 + a8).toBalString()); // @output ()

io:println(a2 + a1); // @output -4.9E-324
io:println(a2 + a2); // @output -1.0E-323
io:println(a2 + a2); // @output -9.9E-324
io:println(a2 + a3); // @output -124.0
io:println(a2 + a4); // @output -75647.096547382
io:println(a2 + a5); // @output -4657382.1234
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ function init() {
io:println(seq[3] is xml:Element); // @output true

xml:Comment comment = xml `<!--Comment-->`;
xml:Comment commentMem = comment[0];
xml:Comment|xml<never> commentMem = comment[0];
io:println(commentMem); // @output <!--Comment-->
io:println(comment[0] is xml:Comment); // @output true

Expand All @@ -761,35 +761,39 @@ function init() {
io:println(ele2[0] is xml:Text); // @output true

XmlType2 com = xml `<!--Comment1-->`;
xml:Comment comMem = com[0];
xml:Comment|xml<never> comMem = com[0];
io:println(comMem); // @output <!--Comment1-->
io:println(com[0] is xml:Comment); // @output true
}

Test-Case: output
Description: Test the static type of member access expression when static type of the container expression is
a subtype of xml<M>.
Fail-Issue: ballerina-platform/ballerina-lang#35019
Labels: is-expr, member-access-expr, module-type-defn, union-type, xml, xml:Comment, xml:Element,
xml:ProcessingInstruction, xml:Text, xml-template-expr, xml-type-parameter

type XmlType1 xml<xml:Element|xml:ProcessingInstruction>;

function init() {
xml<xml:Comment> xml1 = xml `<!--Comment1--><!--Comment2-->`;
xml:Comment mem1 = xml1[1];
xml:Comment|xml<never> mem1 = xml1[1];
io:println(mem1); // @output <!--Comment2-->

xml<xml:ProcessingInstruction> xml2 = xml `<?xml-stylesheet type="text/xsl" href="style.xsl"?>`;
xml:ProcessingInstruction mem2 = xml2[0];
xml:ProcessingInstruction|xml<never> mem2 = xml2[0];
io:println(mem2); // @output <?xml-stylesheet type="text/xsl" href="style.xsl"?>

xml<xml:Element> xml3 = xml `<name>Sherlock Holmes</name><name>Enid Blyton</name>`;
xml:Element mem3 = xml3[1];
xml:Element|xml<never> mem3 = xml3[1];
io:println(mem3); // @output <name>Enid Blyton</name>

XmlType1 xml4 = xml `<name>Enid Blyton</name><name>Dan Brown</name>`;
xml:Element|xml:ProcessingInstruction mem4 = xml4[1];
xml:Element|xml:ProcessingInstruction|xml<never> mem4 = xml4[1];
io:println(mem4); // @output <name>Dan Brown</name>

xml<xml:Element|xml:Comment|xml:Text> xml5 = xml `<name>Enid Blyton</name><name>Dan Brown</name>`;
xml:Element|xml:Comment|xml:Text mem5 = xml5[0];
io:println(mem5); // @output <name>Enid Blyton</name>
}

Test-Case: error
Expand All @@ -798,7 +802,28 @@ Labels: member-access-expr, string, xml, xml-template-expr

function errorFunction() {
xml e = xml `<name>Enid Blyton</name><name>Dan Brown</name>`;
string _ = e[1]; // @error @error expected string, found xml
string _ = e[1]; // @error expected string, found xml
xml:Element|xml:Comment|xml:ProcessingInstruction _ = e[2]; // @error expected string, found xml
}

Test-Case: error
Description: Test assigning result of member access expression to an invalid type, when the static type of
the container expression is a subtype of xml<M>.
Labels: member-access-expr, string, xml, xml:Comment, xml:Element, xml:ProcessingInstruction,
xml:Text, xml-template-expr, xml-type-parameter

function errorFunction() {
xml<xml:Element> e = xml `<name>Enid Blyton</name><name>Dan Brown</name>`;
xml:Element _ = e[1]; // @error expected xml:Element, found xml:Element|xml<never>

xml<xml:Comment> c = xml `<!--comments!-->`;
xml:Comment _ = c[1]; // @error expected xml:Comment, found xml:Comment|xml<never>

xml<xml:ProcessingInstruction> p = xml `<?pi 1?><?pi 2?><?pi 3?>`;
xml:ProcessingInstruction _ = p[0]; // @error expected xml:ProcessingInstruction, found xml:ProcessingInstruction|xml<never>

xml<xml:Element|xml:Text|xml:Comment> s = xml `<elem/><!--comment-->`;
xml:Comment|xml:Text _ = s[0]; // @error expected xml:Comment|xml:Text, found xml:Element|xml:Text|xml:Comment
}

Test-Case: output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function init() {
Test-Case: output
Description: Test xml-optional-attribute-access-expr when xml-attribute-name is an identifier and
expression is a xml-step-expr.
Labels: local-init-var-decl-stmt, string, xml, xml-filter-expr, xml-qualified-name, xml-optional-attribute-access-expr, xml-step-expr
Labels: checking-expr, checkpanic, local-init-var-decl-stmt, string, xml, xml-filter-expr, xml-qualified-name, xml-optional-attribute-access-expr, xml-step-expr

function init() {
xml x = xml `<messages>
Expand Down Expand Up @@ -184,11 +184,14 @@ function init() {
io:println(x/*.<pen>/<color>?.id); // @output 21
io:println(x/<*>.<planner>/<kind>?.id); // @output 14
io:println(x/<*>.<pen>/<color>?.id); // @output 21
io:println(x/**/<items>/<book>[0]/<author>/<name>/<Date>?.id); // @output 12
io:println(x/**/<items>/<book>[1]?.id); // @output 20
io:println(x/**/<items>/<planner>/<kind>?.id); // @output 14
io:println(x/**/<items>/<pen>/<color>?.id); // @output 21
io:println(x/**/<items>/<book>[0]/<author>/<name>/<Date>?.id); // @output 12
io:println(x/**/<book>[0]/<author>/<name>/<Date>?.id); // @output 12
io:println(x/**/<book>[1]?.id); // @output 20
io:println(x/**/<planner>/<kind>?.id); // @output 14
io:println(x/**/<pen>/<color>?.id); // @output 21
io:println(x/**/<book>[0]/<author>/<name>/<Date>?.id); // @output 12
io:println((checkpanic (x/**/<items>/<planner>/<kind>?.id)).toBalString()); // @output ()
io:println((checkpanic (x/**/<items>/<pen>/<color>?.id)).toBalString()); // @output ()
io:println((checkpanic (x/**/<items>/<book>[0]/<author>/<name>/<Date>?.id)).toBalString()); // @output ()
}

Test-Case: output
Expand Down Expand Up @@ -348,11 +351,11 @@ function init() {
io:println(x/*.<pen>/<color>?.ns:id); // @output 21
io:println(x/<*>.<planner>/<kind>?.ns:id); // @output 14
io:println(x/<*>.<pen>/<color>?.ns:id); // @output 21
io:println(x/**/<items>/<book>[0]/<author>/<name>/<Date>?.ns:id); // @output 12
io:println(x/**/<items>/<book>[1]?.id); // @output 20
io:println(x/**/<items>/<planner>/<kind>?.ns:id); // @output 14
io:println(x/**/<items>/<pen>/<color>?.ns:id); // @output 21
io:println(x/**/<items>/<book>[0]/<author>/<name>/<Date>?.ns:id); // @output 12
io:println(x/**/<book>[0]/<author>/<name>/<Date>?.ns:id); // @output 12
io:println(x/**/<book>[1]?.id); // @output 20
io:println(x/**/<planner>/<kind>?.ns:id); // @output 14
io:println(x/**/<pen>/<color>?.ns:id); // @output 21
io:println(x/**/<book>[0]/<author>/<name>/<Date>?.ns:id); // @output 12
}

Test-Case: output
Expand Down Expand Up @@ -520,14 +523,14 @@ function init() {
io:println(x/<*>.<planner>/<kind>?.idx == ()); // @output true
io:println(x/<*>.<pen>/<color>?.id); // @output 21
io:println(x/<*>.<pen>/<color>?.idx == ()); // @output true
io:println(x/**/<items>/<book>[0]/<author>/<name>/<Date>?.id); // @output 12
io:println(x/**/<items>/<book>[0]/<author>/<name>/<Date>?.idx == ()); // @output true
io:println(x/**/<items>/<book>[1]?.id); // @output 20
io:println(x/**/<items>/<book>[1]?.idx == ()); // @output true
io:println(x/**/<items>/<planner>/<kind>?.id); // @output 14
io:println(x/**/<items>/<planner>/<kind>?.idx == ()); // @output true
io:println(x/**/<items>/<pen>/<color>?.id); // @output 21
io:println(x/**/<items>/<pen>/<color>?.idx == ()); // @output true
io:println(x.<items>/<book>[0]/<author>/<name>/<Date>?.id); // @output 12
io:println(x.<items>/<book>[0]/<author>/<name>/<Date>?.idx == ()); // @output true
io:println(x.<items>/<book>[1]?.id); // @output 20
io:println(x.<items>/<book>[1]?.idx == ()); // @output true
io:println(x.<items>/<planner>/<kind>?.id); // @output 14
io:println(x.<items>/<planner>/<kind>?.idx == ()); // @output true
io:println(x.<items>/<pen>/<color>?.id); // @output 21
io:println(x.<items>/<pen>/<color>?.idx == ()); // @output true
}

Test-Case: output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ function init() {
io:println(x/<*>.<book>[1].id); // @output 20
io:println(x/<*>.<planner>/<kind>.id); // @output 14
io:println(x/<*>.<pen>/<color>.id); // @output 21
io:println(x/**/<items>/<book>[0]/<author>/<name>/<Date>.id); // @output 12
io:println(x/**/<items>/<book>[1].id); // @output 20
io:println(x/**/<items>/<planner>/<kind>.id); // @output 14
io:println(x/**/<items>/<pen>/<color>.id); // @output 21
io:println(x/**/<items>/<book>[0]/<author>/<name>/<Date>.id); // @output 12
io:println(x/**/<book>[0]/<author>/<name>/<Date>.id); // @output 12
io:println(x/**/<book>[1].id); // @output 20
io:println(x/**/<planner>/<kind>.id); // @output 14
io:println(x/**/<pen>/<color>.id); // @output 21
io:println(x/**/<book>[0]/<author>/<name>/<Date>.id); // @output 12
}

Test-Case: output
Expand Down Expand Up @@ -372,11 +372,11 @@ function init() {
io:println(x/<*>.<book>[1].id); // @output 20
io:println(x/<*>.<planner>/<kind>.ns:id); // @output 14
io:println(x/<*>.<pen>/<color>.ns:id); // @output 21
io:println(x/**/<items>/<book>[0]/<author>/<name>/<Date>.ns:id); // @output 12
io:println(x/**/<items>/<book>[1].id); // @output 20
io:println(x/**/<items>/<planner>/<kind>.ns:id); // @output 14
io:println(x/**/<items>/<pen>/<color>.ns:id); // @output 21
io:println(x/**/<items>/<book>[0]/<author>/<name>/<Date>.ns:id); // @output 12
io:println(x/**/<book>[0]/<author>/<name>/<Date>.ns:id); // @output 12
io:println(x/**/<book>[1].id); // @output 20
io:println(x/**/<planner>/<kind>.ns:id); // @output 14
io:println(x/**/<pen>/<color>.ns:id); // @output 21
io:println(x/**/<book>[0]/<author>/<name>/<Date>.ns:id); // @output 12
}

Test-Case: error
Expand Down