Skip to content

Commit

Permalink
Revert "Fix set of failing test due to type mismatch"
Browse files Browse the repository at this point in the history
This reverts commit f1ebb95
  • Loading branch information
rdulmina committed Nov 21, 2024
1 parent fb628eb commit 35555f3
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BMap;
import io.ballerina.runtime.api.values.BObject;
import org.ballerinalang.test.BAssertUtil;
Expand Down Expand Up @@ -122,7 +121,7 @@ public void testRefTypes() {
assertEquals(getType(foo2.get(StringUtils.fromString("rp"))).getTag(), TypeTags.OBJECT_TYPE_TAG);
assertEquals(((BObject) foo2.get(StringUtils.fromString("rp"))).get(StringUtils.fromString("name")).toString(),
"John Doe");
assertEquals(TypeUtils.getReferredType(getType(foo2.get(StringUtils.fromString("ra")))).getTag(),
assertEquals(getType(foo2.get(StringUtils.fromString("ra"))).getTag(),
TypeTags.RECORD_TYPE_TAG);
assertEquals(foo2.get(StringUtils.fromString("ra")).toString(), "{\"city\":\"Colombo\",\"country\":\"Sri " +
"Lanka\"}");
Expand All @@ -134,8 +133,7 @@ public void testRefTypes() {
assertEquals(getType(foo2.get(StringUtils.fromString("rp"))).getTag(), TypeTags.OBJECT_TYPE_TAG);
assertEquals(((BObject) foo2.get(StringUtils.fromString("crp"))).get(StringUtils.fromString("name")).toString(),
"Jane Doe");
assertEquals(TypeUtils.getReferredType(getType(foo2.get(StringUtils.fromString("cra")))).getTag(),
TypeTags.RECORD_TYPE_TAG);
assertEquals(getType(foo2.get(StringUtils.fromString("cra"))).getTag(), TypeTags.RECORD_TYPE_TAG);
assertEquals(foo2.get(StringUtils.fromString("cra")).toString(), "{\"city\":\"Colombo\",\"country\":\"Sri " +
"Lanka\"}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BMap;
import io.ballerina.runtime.api.values.BObject;
import org.ballerinalang.test.BAssertUtil;
Expand Down Expand Up @@ -113,8 +112,7 @@ public void testRefTypes() {
assertEquals(getType(foo2.get(StringUtils.fromString("rp"))).getTag(), TypeTags.OBJECT_TYPE_TAG);
assertEquals(((BObject) foo2.get(StringUtils.fromString("rp"))).get(StringUtils.fromString("name")).toString(),
"John Doe");
assertEquals(TypeUtils.getReferredType(getType(foo2.get(StringUtils.fromString("ra")))).getTag(),
TypeTags.RECORD_TYPE_TAG);
assertEquals(getType(foo2.get(StringUtils.fromString("ra"))).getTag(), TypeTags.RECORD_TYPE_TAG);
assertEquals(foo2.get(StringUtils.fromString("ra")).toString(),
"{\"city\":\"Colombo\",\"country\":\"Sri Lanka\"}");
assertEquals(getType(foo2.get(StringUtils.fromString("crx"))).getTag(), TypeTags.XML_ELEMENT_TAG);
Expand All @@ -125,8 +123,7 @@ public void testRefTypes() {
assertEquals(getType(foo2.get(StringUtils.fromString("rp"))).getTag(), TypeTags.OBJECT_TYPE_TAG);
assertEquals(((BObject) foo2.get(StringUtils.fromString("crp"))).get(StringUtils.fromString("name")).toString(),
"Jane Doe");
assertEquals(TypeUtils.getReferredType(getType(foo2.get(StringUtils.fromString("cra")))).getTag(),
TypeTags.RECORD_TYPE_TAG);
assertEquals(getType(foo2.get(StringUtils.fromString("cra"))).getTag(), TypeTags.RECORD_TYPE_TAG);
assertEquals(foo2.get(StringUtils.fromString("cra")).toString(),
"{\"city\":\"Colombo\",\"country\":\"Sri Lanka\"}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
*/
package org.ballerinalang.test.record;

import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BMap;
import org.ballerinalang.test.BAssertUtil;
Expand Down Expand Up @@ -135,14 +133,12 @@ public void testOptionalNonDefField4() {
BArray returns = (BArray) BRunUtil.invoke(compileResult, "testOptionalNonDefField4");
Assert.assertEquals(returns.get(0).toString(), "{\"street\":\"Palm Grove\",\"city\":\"Colombo 3\"," +
"\"country\":\"LK\"}");
Type type = TypeUtils.getReferredType(getType(returns.get(0)));
Assert.assertEquals(type.getTag(), TypeTags.RECORD_TYPE_TAG);
Assert.assertEquals(type.getName(), "Address3");
Assert.assertEquals(getType(returns.get(0)).getTag(), TypeTags.RECORD_TYPE_TAG);
Assert.assertEquals(getType(returns.get(0)).getName(), "Address3");
Assert.assertEquals(returns.get(1).toString(), "{\"street\":\"Palm Grove\",\"city\":\"Colombo 3\"," +
"\"country\":\"LK\"}");
type = TypeUtils.getReferredType(getType(returns.get(1)));
Assert.assertEquals(type.getTag(), TypeTags.RECORD_TYPE_TAG);
Assert.assertEquals(type.getName(), "Address3");
Assert.assertEquals(getType(returns.get(1)).getTag(), TypeTags.RECORD_TYPE_TAG);
Assert.assertEquals(getType(returns.get(1)).getName(), "Address3");
}

@Test(description = "Test defaultable user defined type as an optional field")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
*/
package org.ballerinalang.test.record;

import io.ballerina.runtime.api.types.Type;
import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BMap;
import org.ballerinalang.test.BAssertUtil;
Expand Down Expand Up @@ -138,14 +136,12 @@ public void testOptionalNonDefField4() {
BArray returns = (BArray) BRunUtil.invoke(compileResult, "testOptionalNonDefField4");
Assert.assertEquals(returns.get(0).toString(),
"{\"street\":\"Palm Grove\",\"city\":\"Colombo 3\",\"country\":\"LK\"}");
Type type = TypeUtils.getReferredType(getType(returns.get(0)));
Assert.assertEquals(type.getTag(), TypeTags.RECORD_TYPE_TAG);
Assert.assertEquals(type.getName(), "Address3");
Assert.assertEquals(getType(returns.get(0)).getTag(), TypeTags.RECORD_TYPE_TAG);
Assert.assertEquals(getType(returns.get(0)).getName(), "Address3");
Assert.assertEquals(returns.get(1).toString(),
"{\"street\":\"Palm Grove\",\"city\":\"Colombo 3\",\"country\":\"LK\"}");
type = TypeUtils.getReferredType(getType(returns.get(1)));
Assert.assertEquals(type.getTag(), TypeTags.RECORD_TYPE_TAG);
Assert.assertEquals(type.getName(), "Address3");
Assert.assertEquals(getType(returns.get(1)).getTag(), TypeTags.RECORD_TYPE_TAG);
Assert.assertEquals(getType(returns.get(1)).getName(), "Address3");
}

@Test(description = "Test defaultable user defined type as an optional field")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.ballerinalang.test.types.anydata;

import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.internal.types.BArrayType;
import org.ballerinalang.test.BCompileUtil;
Expand Down Expand Up @@ -74,7 +73,7 @@ public void testAnydataToXml() {
@Test(description = "Test anydata to record conversion")
public void testAnydataToRecord() {
BArray returns = (BArray) BRunUtil.invoke(result, "testAnydataToRecord");
assertEquals(TypeUtils.getReferredType(getType(returns.get(0))).getTag(), TypeTags.RECORD_TYPE_TAG);
assertEquals(getType(returns.get(0)).getTag(), TypeTags.RECORD_TYPE_TAG);
assertEquals(returns.get(0).toString(), "{\"a\":15}");
}

Expand All @@ -98,8 +97,8 @@ public void testAnydataToUnion2() {
BArray returns = (BArray) BRunUtil.invoke(result, "testAnydataToUnion2");
assertEquals(getType(returns.get(0)).getTag(), TypeTags.MAP_TAG);
assertEquals(getType(returns.get(1)).getTag(), TypeTags.XML_ELEMENT_TAG);
assertEquals(TypeUtils.getReferredType(getType(returns.get(2))).getTag(), TypeTags.RECORD_TYPE_TAG);
assertEquals(TypeUtils.getReferredType(getType(returns.get(3))).getTag(), TypeTags.RECORD_TYPE_TAG);
assertEquals(getType(returns.get(2)).getTag(), TypeTags.RECORD_TYPE_TAG);
assertEquals(getType(returns.get(3)).getTag(), TypeTags.RECORD_TYPE_TAG);
assertEquals(returns.get(0).toString(), "{\"name\":\"apple\",\"color\":\"red\",\"price\":40}");
assertEquals(returns.get(1).toString(), "<book>The Lost World</book>");
assertEquals(returns.get(2).toString(), "{\"a\":15}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.StringUtils;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BMap;
import io.ballerina.runtime.api.values.BXml;
Expand Down Expand Up @@ -183,7 +182,7 @@ public void testAnydataToXml() {
@Test(description = "Test anydata to record conversion")
public void testAnydataToRecord() {
BArray returns = (BArray) BRunUtil.invoke(result, "testAnydataToRecord");
assertEquals(TypeUtils.getReferredType(getType(returns.get(0))).getTag(), TypeTags.RECORD_TYPE_TAG);
assertEquals(getType(returns.get(0)).getTag(), TypeTags.RECORD_TYPE_TAG);
assertEquals(returns.get(0).toString(), "{\"a\":15}");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
*/
package org.ballerinalang.test.types.typedesc;

import io.ballerina.runtime.api.types.TypeTags;
import io.ballerina.runtime.api.utils.TypeUtils;
import io.ballerina.runtime.api.TypeTags;
import io.ballerina.runtime.api.values.BArray;
import io.ballerina.runtime.api.values.BTypedesc;
import org.ballerinalang.test.BCompileUtil;
Expand Down Expand Up @@ -125,8 +124,7 @@ public void testRecordTypes() {
Assert.assertEquals(returns.size(), 2);
Assert.assertEquals(returns.get(0).toString(), "typedesc RecordA");
Assert.assertTrue(returns.get(1) instanceof BTypedesc);
Assert.assertEquals(TypeTags.RECORD_TYPE_TAG,
TypeUtils.getReferredType(((BTypedesc) returns.get(1)).getDescribingType()).getTag());
Assert.assertEquals(TypeTags.RECORD_TYPE_TAG, ((BTypedesc) returns.get(1)).getDescribingType().getTag());
}

@Test(description = "Test any to typedesc cast")
Expand Down

0 comments on commit 35555f3

Please sign in to comment.