use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class MathTest method testUlp.
@Test(description = "Test 'ulp' function in ballerina.lang.math package")
public void testUlp() {
BValue[] args = { new BFloat(956.294) };
BValue[] returns = BRunUtil.invoke(compileResult, "ulpTest", args);
Assert.assertEquals(returns.length, 1);
Assert.assertEquals(((BFloat) returns[0]).floatValue(), 1.1368683772161603E-13, DELTA);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class MathTest method testAbsFloat.
@Test(description = "Test 'absFloat' function in ballerina.lang.math package")
public void testAbsFloat() {
BValue[] args = { new BFloat(-152.2544) };
BValue[] returns = BRunUtil.invoke(compileResult, "absFloatTest", args);
Assert.assertEquals(returns.length, 1);
Assert.assertEquals(((BFloat) returns[0]).floatValue(), 152.2544, DELTA);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class MathTest method testNextAfter.
@Test(description = "Test 'nextAfter' function in ballerina.lang.math package")
public void testNextAfter() {
BValue[] args = { new BFloat(98759.765), new BFloat(154.28764) };
BValue[] returns = BRunUtil.invoke(compileResult, "nextAfterTest", args);
Assert.assertEquals(returns.length, 1);
Assert.assertEquals(((BFloat) returns[0]).floatValue(), 98759.76499999998, DELTA);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class SimpleTypeCastExprTest method testFloatToBooleanCast.
private void testFloatToBooleanCast(float input, boolean excepted) {
BValue[] args = { new BFloat(input) };
BValue[] returns = BRunUtil.invoke(result, "floatToBooleanExplicit", args);
Assert.assertEquals(returns.length, 1);
Assert.assertEquals(returns[0].getClass(), BBoolean.class);
Assert.assertEquals(((BBoolean) returns[0]).booleanValue(), excepted);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class TypeCastExprTest method testFloatToString.
@Test
public void testFloatToString() {
BValue[] args = { new BFloat(111.333f) };
BValue[] returns = BRunUtil.invoke(result, "floattostring", args);
Assert.assertTrue(returns[0] instanceof BString);
final String expected = "111.333";
Assert.assertEquals(returns[0].stringValue().substring(0, 7), expected);
}
Aggregations