use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class StringTest method testFloatValueOf.
@Test
public void testFloatValueOf() {
BValue[] args = { new BFloat(1.345f) };
BValue[] returns = BRunUtil.invoke(result, "floatValueOf", args);
Assert.assertTrue(returns[0] instanceof BString);
final String expected = "1.345";
Assert.assertEquals(returns[0].stringValue().substring(0, 5), expected);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class BAnyTypeSuccessScenariosTest method assignmentTest.
@Test(description = "Test any variable assignment with float")
public void assignmentTest() {
BValue[] returns = BRunUtil.invoke(result, "assignmentTest", new BValue[0]);
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BFloat.class);
BFloat floatVal = (BFloat) returns[0];
Assert.assertEquals(floatVal.floatValue(), 44.3d, "Invalid float value returned.");
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class BFloatValueTest method testFloatValueAssignmentByReturnValue.
@Test(description = "Test double value assignment from a value returned by function")
public void testFloatValueAssignmentByReturnValue() {
BValue[] returns = BRunUtil.invoke(result, "testFloatValueAssignmentByReturnValue", new BValue[] {});
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BFloat.class);
BFloat floatValue = (BFloat) returns[0];
Assert.assertEquals(floatValue.floatValue(), 10.1d, "Invalid float value returned.");
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class BFloatValueTest method testFloatValueDivision.
@Test(description = "Test double value Division")
public void testFloatValueDivision() {
BValue[] returns = BRunUtil.invoke(result, "testFloatDivision", new BValue[] {});
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BFloat.class);
BFloat floatValue = (BFloat) returns[0];
Assert.assertEquals(floatValue.floatValue(), 5.0d, "Invalid float value returned.");
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class BFloatValueTest method testFloatValueSubtraction.
@Test(description = "Test double value Subtraction")
public void testFloatValueSubtraction() {
BValue[] returns = BRunUtil.invoke(result, "testFloatSubtraction", new BValue[] {});
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BFloat.class);
BFloat floatValue = (BFloat) returns[0];
Assert.assertEquals(floatValue.floatValue(), 10.0d, "Invalid float value returned.");
}
Aggregations