Search in sources :

Example 91 with BFloat

use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.

the class BFloatValueTest method testFloatValue.

@Test(description = "Test double value assignment")
public void testFloatValue() {
    BValue[] returns = BRunUtil.invoke(result, "testFloatValue", 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.");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BFloat(org.ballerinalang.model.values.BFloat) Test(org.testng.annotations.Test)

Example 92 with BFloat

use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.

the class BFloatValueTest method testFloatValueAddition.

@Test(description = "Test double value Addition")
public void testFloatValueAddition() {
    BValue[] returns = BRunUtil.invoke(result, "testFloatAddition", new BValue[] {});
    Assert.assertEquals(returns.length, 1);
    Assert.assertSame(returns[0].getClass(), BFloat.class);
    BFloat floatValue = (BFloat) returns[0];
    Assert.assertEquals(floatValue.floatValue(), 20.0d, "Invalid float value returned.");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BFloat(org.ballerinalang.model.values.BFloat) Test(org.testng.annotations.Test)

Example 93 with BFloat

use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.

the class BFloatValueTest method testFloatParameter.

@Test(description = "Test double value assignment")
public void testFloatParameter() {
    BValue[] args = { new BFloat(3.3f) };
    BValue[] returns = BRunUtil.invoke(result, "testFloatParameter", args);
    Assert.assertEquals(returns.length, 1);
    Assert.assertSame(returns[0].getClass(), BFloat.class);
    BFloat floatValue = (BFloat) returns[0];
    Assert.assertEquals(floatValue.floatValue(), 3.3f, DELTA, "Invalid float value returned.");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BFloat(org.ballerinalang.model.values.BFloat) Test(org.testng.annotations.Test)

Example 94 with BFloat

use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.

the class WhileStmtTest method testWhileBlockScopesWithIf.

@Test(description = "Check the scope managing in while block with ifelse")
public void testWhileBlockScopesWithIf() {
    BValue[] returns = BRunUtil.invoke(positiveCompileResult, "testWhileScopeWithIf");
    Assert.assertEquals(returns.length, 2);
    Assert.assertSame(returns[0].getClass(), BInteger.class, "Class type of return param1 mismatched");
    Assert.assertSame(returns[1].getClass(), BFloat.class, "Class type of return param2 mismatched");
    BInteger actual = (BInteger) returns[0];
    Assert.assertEquals(actual.intValue(), 2, "mismatched output value");
    BFloat sum = (BFloat) returns[1];
    Assert.assertEquals(sum.floatValue(), 30.0, "mismatched output value");
}
Also used : BValue(org.ballerinalang.model.values.BValue) BInteger(org.ballerinalang.model.values.BInteger) BFloat(org.ballerinalang.model.values.BFloat) Test(org.testng.annotations.Test)

Example 95 with BFloat

use of org.ballerinalang.model.values.BFloat in project ballerina by ballerina-lang.

the class NextAfter method execute.

public void execute(Context ctx) {
    double a = ctx.getFloatArgument(0);
    double b = ctx.getFloatArgument(1);
    ctx.setReturnValues(new BFloat(Math.nextAfter(a, b)));
}
Also used : BFloat(org.ballerinalang.model.values.BFloat)

Aggregations

BFloat (org.ballerinalang.model.values.BFloat)158 BValue (org.ballerinalang.model.values.BValue)119 Test (org.testng.annotations.Test)107 BInteger (org.ballerinalang.model.values.BInteger)55 BString (org.ballerinalang.model.values.BString)41 BBoolean (org.ballerinalang.model.values.BBoolean)21 BRefType (org.ballerinalang.model.values.BRefType)7 BStruct (org.ballerinalang.model.values.BStruct)7 BType (org.ballerinalang.model.types.BType)6 BBlob (org.ballerinalang.model.values.BBlob)6 BStringArray (org.ballerinalang.model.values.BStringArray)5 BStructType (org.ballerinalang.model.types.BStructType)4 BIntArray (org.ballerinalang.model.values.BIntArray)4 UnsupportedFieldTypeException (org.ballerinalang.net.grpc.exception.UnsupportedFieldTypeException)4 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)4 BJSON (org.ballerinalang.model.values.BJSON)3 CompileResult (org.ballerinalang.launcher.util.CompileResult)2 BMap (org.ballerinalang.model.values.BMap)2 BRefValueArray (org.ballerinalang.model.values.BRefValueArray)2 Message (org.ballerinalang.net.grpc.Message)2