use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class AssertTest method testAssertFloatEquals.
@Test
public void testAssertFloatEquals() {
BValue[] args = { new BFloat(10.000), new BFloat(20.050) };
BTestUtils.invoke(compileResult, "testAssertFloatEquals", args);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class VariableDefinitionTest method testUpdateVarValue.
@Test
public void testUpdateVarValue() {
int v1 = 56;
boolean v3 = false;
String v4 = "newstr";
double v5 = 68.3325f;
BValue[] args = { new BInteger(v1), new BBoolean(v3), new BString(v4), new BFloat(v5) };
BValue[] returns = BRunUtil.invoke(result, "updateVarValue", args);
Assert.assertEquals(returns.length, 4);
Assert.assertSame(returns[0].getClass(), BInteger.class);
long i = ((BInteger) returns[0]).intValue();
Assert.assertEquals(i, v1);
Assert.assertSame(returns[1].getClass(), BBoolean.class);
boolean b = ((BBoolean) returns[1]).booleanValue();
Assert.assertEquals(b, v3);
Assert.assertSame(returns[2].getClass(), BString.class);
String s = ((BString) returns[2]).stringValue();
Assert.assertEquals(s, v4);
Assert.assertSame(returns[3].getClass(), BFloat.class);
double f = ((BFloat) returns[3]).floatValue();
Assert.assertEquals(f, v5, DELTA);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class VariableDefinitionTest method testInlineVarInit.
@Test
public void testInlineVarInit() {
BValue[] returns = BRunUtil.invoke(result, "inlineVarInit", new BValue[0]);
Assert.assertEquals(returns.length, 4);
Assert.assertSame(returns[0].getClass(), BInteger.class);
long i = ((BInteger) returns[0]).intValue();
Assert.assertEquals(i, 10);
Assert.assertSame(returns[1].getClass(), BBoolean.class);
boolean b = ((BBoolean) returns[1]).booleanValue();
Assert.assertEquals(b, true);
Assert.assertSame(returns[2].getClass(), BString.class);
String s = ((BString) returns[2]).stringValue();
Assert.assertEquals(s, "hello");
Assert.assertSame(returns[3].getClass(), BFloat.class);
double f = ((BFloat) returns[3]).floatValue();
Assert.assertEquals(f, 2.6f, DELTA);
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class BFloatValueTest method testNegativeFloatValue.
@Test(description = "Test negative double value assignment")
public void testNegativeFloatValue() {
BValue[] returns = BRunUtil.invoke(result, "testNegativeFloatValue", new BValue[] {});
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BFloat.class);
BFloat floatValue = (BFloat) returns[0];
Assert.assertEquals(floatValue.floatValue(), (-10.1f), DELTA, "Invalid float value returned.");
}
use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.
the class BFloatValueTest method testFloatValueMultiplication.
@Test(description = "Test double value Multiplication")
public void testFloatValueMultiplication() {
BValue[] returns = BRunUtil.invoke(result, "testFloatMultiplication", new BValue[] {});
Assert.assertEquals(returns.length, 1);
Assert.assertSame(returns[0].getClass(), BFloat.class);
BFloat floatValue = (BFloat) returns[0];
Assert.assertEquals(floatValue.floatValue(), 13.75d, "Invalid float value returned.");
}
Aggregations