use of org.ballerinalang.model.values.BValueType in project ballerina by ballerina-lang.
the class SystemTest method testBooleanPrintAndPrintln.
@Test
public void testBooleanPrintAndPrintln() throws IOException {
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
try {
System.setOut(new PrintStream(outContent));
final boolean v1 = false;
final boolean v2 = true;
final String expected = v1 + "\n" + v2;
BValueType[] args = { new BBoolean(v1), new BBoolean(v2) };
BRunUtil.invoke(compileResult, printFuncName + "Boolean", args);
Assert.assertEquals(outContent.toString().replace("\r", ""), expected);
} finally {
outContent.close();
System.setOut(original);
}
}
use of org.ballerinalang.model.values.BValueType in project ballerina by ballerina-lang.
the class SystemTest method testFloatPrintAndPrintln.
@Test
public void testFloatPrintAndPrintln() throws IOException {
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
try {
System.setOut(new PrintStream(outContent));
final float v1 = 1000;
final float v2 = 1;
final String expected = v1 + "\n" + v2;
BValueType[] args = { new BFloat(v1), new BFloat(v2) };
BRunUtil.invoke(compileResult, printFuncName + "Float", args);
Assert.assertEquals(outContent.toString().replace("\r", ""), expected);
} finally {
outContent.close();
System.setOut(original);
}
}
use of org.ballerinalang.model.values.BValueType in project ballerina by ballerina-lang.
the class VariableDTO method getStringValue.
private String getStringValue(BValue bValue) {
String bValueString;
if (bValue instanceof BValueType || bValue instanceof BXML || bValue instanceof BJSON) {
bValueString = bValue.stringValue();
} else if (bValue instanceof BNewArray) {
BNewArray bArray = (BNewArray) bValue;
bValueString = "Array[" + bArray.size() + "] ";
bValueString = bValueString + bArray.stringValue();
} else if (bValue instanceof BMap) {
BMap bmap = (BMap) bValue;
bValueString = "Map[" + bmap.size() + "] ";
bValueString = bValueString + bmap.stringValue();
} else if (bValue instanceof BStruct) {
BStruct bStruct = (BStruct) bValue;
bValueString = "struct " + bStruct.getType().getName() + " ";
bValueString = bValueString + bStruct.stringValue();
} else {
bValueString = "<Complex_Value>";
}
return bValueString;
}
use of org.ballerinalang.model.values.BValueType in project ballerina by ballerina-lang.
the class SystemTest method testIntPrintAndPrintln.
@Test
public void testIntPrintAndPrintln() throws IOException {
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
try {
System.setOut(new PrintStream(outContent));
final int v1 = 1000;
final int v2 = 1;
final String expected = v1 + "\n" + v2;
BValueType[] args = { new BInteger(v1), new BInteger(v2) };
BRunUtil.invoke(compileResult, printFuncName + "Int", args);
Assert.assertEquals(outContent.toString().replace("\r", ""), expected);
} finally {
outContent.close();
System.setOut(original);
}
}
use of org.ballerinalang.model.values.BValueType in project ballerina by ballerina-lang.
the class SystemTest method testStringPrintAndPrintln.
@Test
public void testStringPrintAndPrintln() throws IOException {
ByteArrayOutputStream outContent = new ByteArrayOutputStream();
try {
System.setOut(new PrintStream(outContent));
final String s1 = "Hello World...!!!";
final String s2 = "A Greeting from Ballerina...!!!";
final String expected = s1 + "\n" + s2;
BValueType[] args = { new BString(s1), new BString(s2) };
BRunUtil.invoke(compileResult, printFuncName + "String", args);
Assert.assertEquals(outContent.toString().replace("\r", ""), expected);
} finally {
outContent.close();
System.setOut(original);
}
}
Aggregations