use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class ValueTypeCastExprTest method testStringToInt.
@Test
public void testStringToInt() {
BValue[] args = { new BString("100") };
BValue[] returns = BRunUtil.invoke(result, "stringToInt", args);
Assert.assertTrue(returns[0] instanceof BInteger);
final long expected = 100;
Assert.assertEquals(((BInteger) returns[0]).intValue(), expected);
}
use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class LengthOfOperatorTest method testArrayLengthAccessJSONArrayNegativeNonArrayCase.
@Test(description = "Test lengthof unary expression when reference point to JSON Object.")
public void testArrayLengthAccessJSONArrayNegativeNonArrayCase() {
BValue[] args = { new BInteger(100), new BInteger(5) };
BValue[] returns = BRunUtil.invoke(result, "arrayLengthAccessTestJSONArrayNegativeNonArrayCase", args);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BInteger.class);
int actual = (int) ((BInteger) returns[0]).intValue();
int expected = -1;
Assert.assertEquals(actual, expected);
}
use of org.ballerinalang.model.values.BInteger in project ballerina by ballerina-lang.
the class LengthOfOperatorTest method testArrayLengthAccessExprReturnExpressionCase.
@Test(description = "Test lengthof unary expression when present in Return statement.")
public void testArrayLengthAccessExprReturnExpressionCase() {
BValue[] args = { new BInteger(100), new BInteger(5) };
BValue[] returns = BRunUtil.invoke(result, "arrayLengthAccessTestReturnStatementCase", 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 testArrayLengthAccessExprMapInitializationCase.
@Test(description = "Test lengthof unary expression when present in Map initialization statement.")
public void testArrayLengthAccessExprMapInitializationCase() {
BValue[] args = { new BInteger(100), new BInteger(5) };
BValue[] returns = BRunUtil.invoke(result, "arrayLengthAccessTestMapInitializerCase", 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 testArrayLengthAccessExpArrayNullCase.
@Test(description = "Test lengthof unary expression when array is null.")
public void testArrayLengthAccessExpArrayNullCase() {
BValue[] args = { new BInteger(100), new BInteger(5) };
BRunUtil.invoke(resNegative, "arrayLengthAccessNullArrayCase", args);
}
Aggregations