use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class LengthOfOperatorTest method testArrayLengthAccessExprVariableDefinitionCase.
@Test(description = "Test lengthof unary expression when present in Variable definition statement.")
public void testArrayLengthAccessExprVariableDefinitionCase() {
BValue[] args = { new BInteger(100), new BInteger(5) };
BValue[] returns = BRunUtil.invoke(result, "arrayLengthAccessTestVariableDefinitionCase", args);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BInteger.class);
int actual = (int) ((BInteger) returns[0]).intValue();
int expected = 3;
Assert.assertEquals(actual, expected);
}
use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class LengthOfOperatorTest method testArrayLengthAccessExprMultiReturnExpressionCase.
@Test(description = "Test lengthof unary expression when present in multi Return statement.")
public void testArrayLengthAccessExprMultiReturnExpressionCase() {
BValue[] args = { new BInteger(100), new BInteger(5) };
BValue[] returns = BRunUtil.invoke(result, "arrayLengthAccessTestMultiReturnStatementCase", args);
Assert.assertEquals(returns.length, 3);
Assert.assertSame(returns[0].getClass(), BInteger.class);
int actualFirst = (int) ((BInteger) returns[0]).intValue();
int actualSecond = (int) ((BInteger) returns[1]).intValue();
int actualThird = (int) ((BInteger) returns[2]).intValue();
int expectedFirst = 3;
int expectedSecond = 1;
int expectedThird = 2;
Assert.assertEquals(actualFirst, expectedFirst);
Assert.assertEquals(actualSecond, expectedSecond);
Assert.assertEquals(actualThird, expectedThird);
}
use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class LengthOfOperatorTest method lengthOfMapEmpty.
@Test(description = "Test lengthof map empty")
public void lengthOfMapEmpty() {
BValue[] args = { new BInteger(100), new BInteger(5) };
BValue[] returns = BRunUtil.invoke(result, "lengthOfMapEmpty", args);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BInteger.class);
int actual = (int) ((BInteger) returns[0]).intValue();
int expected = 0;
Assert.assertEquals(actual, expected);
}
use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class LengthOfOperatorTest method lengthOfMap.
@Test(description = "Test lengthof map")
public void lengthOfMap() {
BValue[] args = { new BInteger(100), new BInteger(5) };
BValue[] returns = BRunUtil.invoke(result, "lengthOfMap", args);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BInteger.class);
int actual = (int) ((BInteger) returns[0]).intValue();
int expected = 4;
Assert.assertEquals(actual, expected);
}
use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class LengthOfOperatorTest method testArrayLengthAccessExpStructFieldAccessCase.
@Test(description = "Test lengthof unary expression when present in Struct field access expression.")
public void testArrayLengthAccessExpStructFieldAccessCase() {
BValue[] args = { new BInteger(100), new BInteger(5) };
BValue[] returns = BRunUtil.invoke(result, "arrayLengthAccessTestStructFieldAccessCase", args);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BInteger.class);
int actual = (int) ((BInteger) returns[0]).intValue();
int expected = 3;
Assert.assertEquals(actual, expected);
}
Aggregations