Search in sources :

Example 41 with BInteger

use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.

the class BMapValueTest method testBMapClear.

@Test
public void testBMapClear() {
    BMap<BString, BInteger> map = new BMap<>();
    map.put(new BString("IS"), new BInteger(0));
    map.put(new BString("ESB"), new BInteger(1));
    map.put(new BString("APIM"), new BInteger(2));
    assertEquals(map.size(), 3);
    map.clear();
    assertEquals(map.size(), 0);
}
Also used : BMap(org.ballerinalang.model.values.BMap) BString(org.ballerinalang.model.values.BString) BInteger(org.ballerinalang.model.values.BInteger) Test(org.testng.annotations.Test)

Example 42 with BInteger

use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.

the class BMapValueTest method testBMapToString.

@Test(description = "Testing convert map values to string")
public void testBMapToString() {
    BMap<String, BRefType> map = new BMap<>();
    map.put(new String("key1"), new BInteger(1));
    map.put(new String("key2"), new BString("foo"));
    map.put(new String("key3"), new BXMLItem("<bar>hello</bar>"));
    Assert.assertEquals(map.stringValue(), "{\"key1\":1, \"key2\":\"foo\", \"key3\":<bar>hello</bar>}");
}
Also used : BRefType(org.ballerinalang.model.values.BRefType) BXMLItem(org.ballerinalang.model.values.BXMLItem) BMap(org.ballerinalang.model.values.BMap) BString(org.ballerinalang.model.values.BString) BInteger(org.ballerinalang.model.values.BInteger) BString(org.ballerinalang.model.values.BString) Test(org.testng.annotations.Test)

Example 43 with BInteger

use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.

the class BNullValueTest method testStructNull.

@Test(description = "Test null value of a struct")
public void testStructNull() {
    BValue[] vals = BRunUtil.invoke(positiveCompileResult, "testStructNull", new BValue[] {});
    Assert.assertEquals(vals[0], null);
    Assert.assertEquals(vals[1], null);
    Assert.assertEquals(vals[2], new BInteger(7));
}
Also used : BValue(org.ballerinalang.model.values.BValue) BInteger(org.ballerinalang.model.values.BInteger) Test(org.testng.annotations.Test)

Example 44 with BInteger

use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.

the class BNullValueTest method testXmlNull.

@Test(description = "Test null value of a xml")
public void testXmlNull() {
    BValue[] vals = BRunUtil.invoke(positiveCompileResult, "testXmlNull", new BValue[] {});
    Assert.assertEquals(vals[0], null);
    Assert.assertEquals(vals[1], null);
    Assert.assertEquals(vals[2], new BInteger(5));
}
Also used : BValue(org.ballerinalang.model.values.BValue) BInteger(org.ballerinalang.model.values.BInteger) Test(org.testng.annotations.Test)

Example 45 with BInteger

use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.

the class BNullValueTest method testJsonNull.

@Test(description = "Test null value of a json")
public void testJsonNull() {
    BValue[] vals = BRunUtil.invoke(positiveCompileResult, "testJsonNull", new BValue[] {});
    Assert.assertEquals(vals[0], null);
    Assert.assertEquals(vals[1], null);
    Assert.assertEquals(vals[2], new BInteger(6));
}
Also used : BValue(org.ballerinalang.model.values.BValue) BInteger(org.ballerinalang.model.values.BInteger) Test(org.testng.annotations.Test)

Aggregations

BInteger (org.ballerinalang.model.values.BInteger)364 BValue (org.ballerinalang.model.values.BValue)324 Test (org.testng.annotations.Test)305 BString (org.ballerinalang.model.values.BString)91 BFloat (org.ballerinalang.model.values.BFloat)55 BStruct (org.ballerinalang.model.values.BStruct)33 BBoolean (org.ballerinalang.model.values.BBoolean)24 BRefValueArray (org.ballerinalang.model.values.BRefValueArray)18 CompileResult (org.ballerinalang.launcher.util.CompileResult)12 BBlob (org.ballerinalang.model.values.BBlob)11 BeforeTest (org.testng.annotations.BeforeTest)11 BIntArray (org.ballerinalang.model.values.BIntArray)9 BMap (org.ballerinalang.model.values.BMap)9 BRefType (org.ballerinalang.model.values.BRefType)8 BStringArray (org.ballerinalang.model.values.BStringArray)8 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)8 BType (org.ballerinalang.model.types.BType)6 BStructType (org.ballerinalang.model.types.BStructType)4 BJSON (org.ballerinalang.model.values.BJSON)4 UnsupportedFieldTypeException (org.ballerinalang.net.grpc.exception.UnsupportedFieldTypeException)4