use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class DivisionOperationTest method testFloatDivisionInt.
@Test
public void testFloatDivisionInt() {
BValue[] args = { new BFloat(110f), new BInteger(22) };
BValue[] returns = BRunUtil.invoke(result, "floatDivideByInt", args);
Assert.assertTrue(returns[0] instanceof BFloat);
final String expected = "5.0";
Assert.assertEquals(returns[0].stringValue(), expected);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class GreaterLessThanOperationTest method testFloatRangeExpr.
@Test(description = "Test float greater than, less than expression")
public void testFloatRangeExpr() {
BValue[] args = { new BFloat(-123.8f) };
BValue[] returns = BRunUtil.invoke(result, "testFloatRanges", args);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BInteger.class);
long actual = ((BInteger) returns[0]).intValue();
long expected = 1;
Assert.assertEquals(actual, expected);
args = new BValue[] { new BFloat(75.4f) };
returns = BRunUtil.invoke(result, "testFloatRanges", args);
actual = ((BInteger) returns[0]).intValue();
expected = 2;
Assert.assertEquals(actual, expected);
args = new BValue[] { new BFloat(321.45f) };
returns = BRunUtil.invoke(result, "testFloatRanges", args);
actual = ((BInteger) returns[0]).intValue();
expected = 3;
Assert.assertEquals(actual, expected);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class GreaterLessThanOperationTest method testIntGTFloat.
@Test
public void testIntGTFloat() {
BValue[] args = { new BInteger(110), new BFloat(22L) };
BValue[] returns = BRunUtil.invoke(result, "intGTFloat", args);
Assert.assertTrue(returns[0] instanceof BBoolean);
final String expected = "true";
Assert.assertEquals(returns[0].stringValue(), expected);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class ModOperationTest method intFloatMod.
private void intFloatMod(int val1, float val2, double expected) {
BValue[] args = { new BInteger(val1), new BFloat(val2) };
BValue[] returns = BRunUtil.invoke(result, "intFloatMod", args);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BFloat.class);
double actual = ((BFloat) returns[0]).floatValue();
Assert.assertEquals(actual, expected);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class MultiplyOperationTest method testFloatMultiplyExpr.
@Test(description = "Test two float multiply expression")
public void testFloatMultiplyExpr() {
BValue[] args = { new BFloat(40.0f), new BFloat(40.0f) };
BValue[] returns = BRunUtil.invoke(result, "floatMultiply", args);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BFloat.class);
double actual = ((BFloat) returns[0]).floatValue();
double expected = 1600.0f;
Assert.assertEquals(actual, expected);
}
Aggregations