use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class MapInitializerExprTest method testNestedMapInit.
@Test
public void testNestedMapInit() {
BValue[] returns = BRunUtil.invoke(compileResult, "testNestedMapInit", new BValue[] {});
Assert.assertTrue(returns[0] instanceof BMap<?, ?>);
BMap<String, BValue> outerMap = (BMap<String, BValue>) returns[0];
Assert.assertEquals(outerMap.get("name"), new BString("Supun"));
BValue info = outerMap.get("info");
Assert.assertTrue(info instanceof BMap<?, ?>);
BMap<String, BValue> infoMap = (BMap<String, BValue>) info;
Assert.assertEquals(infoMap.get("city"), new BString("Colombo"));
Assert.assertEquals(infoMap.get("country"), new BString("SriLanka"));
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class MapInitializerExprTest method testMapInitWithPackageVars.
@Test(enabled = false)
public void testMapInitWithPackageVars() {
CompileResult result = BCompileUtil.compile(this, "test-src/types/map/", "a.b");
BValue[] returns = BRunUtil.invoke(result, "testMapInitWithPackageVars");
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BMap.class);
BMap<String, ?> mapValue = (BMap<String, BString>) returns[0];
Assert.assertEquals(mapValue.size(), 2);
Assert.assertEquals(mapValue.get("name").stringValue(), "PI");
Assert.assertEquals(((BFloat) mapValue.get("value")).floatValue(), 3.14159);
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class MapInitializerExprTest method testMapInitWithJson.
@Test
public void testMapInitWithJson() {
BValue[] returns = BRunUtil.invoke(compileResult, "testMapInitWithJson", new BValue[] {});
Assert.assertTrue(returns[0] instanceof BMap<?, ?>);
BMap<String, BValue> outerMap = (BMap<String, BValue>) returns[0];
Assert.assertEquals(outerMap.get("name"), new BString("Supun"));
BValue info = outerMap.get("info");
Assert.assertTrue(info instanceof BJSON);
BJSON infoJson = (BJSON) info;
Assert.assertEquals(infoJson.stringValue(), "{\"city\":\"Colombo\",\"country\":\"SriLanka\"}");
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class StringTest method testBooleanValueOf.
@Test
public void testBooleanValueOf() {
BValue[] args = { new BBoolean(true) };
BValue[] returns = BRunUtil.invoke(result, "booleanValueOf", args);
Assert.assertTrue(returns[0] instanceof BString);
final String expected = "true";
Assert.assertEquals(returns[0].stringValue(), expected);
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class StringTest method testXmlValueOf.
@Test
public void testXmlValueOf() {
BValue[] args = { new BXMLItem("<test>name</test>") };
BValue[] returns = BRunUtil.invoke(result, "xmlValueOf", args);
Assert.assertTrue(returns[0] instanceof BString);
final String expected = "<test>name</test>";
Assert.assertEquals(returns[0].stringValue(), expected);
}
Aggregations