use of org.ballerinalang.model.values.BIntArray in project ballerina by ballerina-lang.
the class SQLActionsTest method testBatchUpdateWithFailure.
@Test(groups = "ConnectorTest")
public void testBatchUpdateWithFailure() {
BValue[] returns = BRunUtil.invoke(result, "testBatchUpdateWithFailure");
BIntArray retValue = (BIntArray) returns[0];
Assert.assertEquals(retValue.get(0), 1);
Assert.assertEquals(retValue.get(1), 1);
Assert.assertEquals(retValue.get(2), -3);
Assert.assertEquals(retValue.get(3), -3);
Assert.assertEquals(((BInteger) returns[1]).intValue(), 2);
}
use of org.ballerinalang.model.values.BIntArray in project ballerina by ballerina-lang.
the class FunctionSignatureTest method testOptionalArgsInNativeFunc.
@Test(enabled = false)
public void testOptionalArgsInNativeFunc() {
NativeElementRepository repo = NativeUnitLoader.getInstance().getNativeElementRepository();
StandardNativeElementProvider provider = new StandardNativeElementProvider();
provider.populateNatives(repo);
CompileResult result = BCompileUtil.compile(this, "test-src/functions/", "foo.bar");
BValue[] returns = BRunUtil.invoke(result, "testOptionalArgsInNativeFunc");
Assert.assertTrue(returns[0] instanceof BInteger);
Assert.assertEquals(((BInteger) returns[0]).intValue(), 78);
Assert.assertTrue(returns[1] instanceof BFloat);
Assert.assertEquals(((BFloat) returns[1]).floatValue(), 89.0);
Assert.assertTrue(returns[2] instanceof BString);
Assert.assertEquals(returns[2].stringValue(), "John");
Assert.assertTrue(returns[3] instanceof BInteger);
Assert.assertEquals(((BInteger) returns[3]).intValue(), 5);
Assert.assertTrue(returns[4] instanceof BString);
Assert.assertEquals(returns[4].stringValue(), "Doe");
Assert.assertTrue(returns[5] instanceof BIntArray);
Assert.assertEquals(returns[5].stringValue(), "[4, 5, 6]");
}
use of org.ballerinalang.model.values.BIntArray in project ballerina by ballerina-lang.
the class NativeConversionTest method testJsonToIntArray.
@Test(description = "Test converting a JSON array to int array")
public void testJsonToIntArray() {
BValue[] returns = BRunUtil.invoke(compileResult, "testJsonToIntArray");
Assert.assertTrue(returns[0] instanceof BStruct);
BStruct anyArrayStruct = (BStruct) returns[0];
BIntArray array = (BIntArray) anyArrayStruct.getRefField(0);
Assert.assertEquals(array.getType().toString(), "int[]");
Assert.assertEquals(array.get(0), 4);
Assert.assertEquals(array.get(1), 3);
Assert.assertEquals(array.get(2), 9);
}
use of org.ballerinalang.model.values.BIntArray in project ballerina by ballerina-lang.
the class ArrayAccessExprTest method testArrayReturnValue.
@Test(description = "Test arrays return value")
public void testArrayReturnValue() {
BValue[] args = { new BInteger(100), new BInteger(5) };
BValue[] returns = BRunUtil.invoke(compileResult, "arrayReturnTest", args);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BIntArray.class);
BIntArray arrayValue = (BIntArray) returns[0];
Assert.assertEquals(arrayValue.size(), 106);
Assert.assertEquals(arrayValue.get(0), 100);
Assert.assertEquals(arrayValue.get(1), 5);
Assert.assertEquals(arrayValue.get(105), 105);
}
use of org.ballerinalang.model.values.BIntArray in project ballerina by ballerina-lang.
the class ArrayAccessExprTest method testArrayArgValue.
@Test(description = "Test arrays arg value")
public void testArrayArgValue() {
BIntArray arrayValue = new BIntArray();
arrayValue.add(0, 10);
arrayValue.add(1, 1);
BValue[] args = { arrayValue };
BValue[] returns = BRunUtil.invoke(compileResult, "arrayArgTest", args);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BInteger.class);
long actual = ((BInteger) returns[0]).intValue();
long expected = 11;
Assert.assertEquals(actual, expected);
}
Aggregations