-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ToStringAndBack test along with many of new ops
- Loading branch information
1 parent
1ce533b
commit c18374e
Showing
7 changed files
with
529 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
mod utils; | ||
use crate::utils::get_long; | ||
use utils::setup; | ||
|
||
#[test] | ||
fn should_convert_to_string_and_back() { | ||
let mut vm = setup(); | ||
let last_frame_value = vm | ||
.run("samples.javacore.strings.trivial.ToStringAndBack") | ||
.unwrap(); | ||
assert_eq!(1002000033239, get_long(last_frame_value)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package samples.javacore.strings.trivial; | ||
|
||
public class ToStringAndBack { | ||
|
||
public static void main(String[] args) { | ||
boolean convertedBoolean = convertBoolean(); | ||
byte convertedByte = convertByte(); | ||
short convertedShort = convertShort(); | ||
char convertedChar = convertChar(); | ||
int convertedInt = convertInt(); | ||
long convertedLong = convertLong(); | ||
float convertedFloat = convertFloat(); | ||
double convertedDouble = 0;//convertDouble(); fixme: freezes after WIDE ops | ||
|
||
long result = (convertedBoolean ? 1 : 0) + convertedByte + convertedShort + convertedChar + convertedInt + convertedLong + (long) convertedFloat + (long) convertedDouble; | ||
} | ||
|
||
private static boolean convertBoolean() { | ||
boolean value = true; | ||
String string = Boolean.toString(value); | ||
return Boolean.parseBoolean(string); | ||
} | ||
|
||
private static byte convertByte() { | ||
byte value = 127; | ||
String string = Byte.toString(value); | ||
return Byte.parseByte(string); | ||
} | ||
|
||
private static short convertShort() { | ||
short value = 31999; | ||
String string = Short.toString(value); | ||
return Short.parseShort(string); | ||
} | ||
|
||
private static char convertChar() { | ||
char value = 'ї'; | ||
String string = Character.toString(value); | ||
return string.charAt(0); | ||
} | ||
|
||
private static int convertInt() { | ||
int value = 1_999_999_999; | ||
String string = Integer.toString(value); | ||
return Integer.parseInt(string); | ||
} | ||
|
||
private static long convertLong() { | ||
long value = 999_999_999_999L; | ||
String string = Long.toString(value); | ||
return Long.parseLong(string); | ||
} | ||
|
||
private static double convertDouble() { | ||
double value = 3.14; | ||
String string = Double.toString(value); | ||
return Double.parseDouble(string); | ||
} | ||
|
||
private static float convertFloat() { | ||
float value = 3.14f; | ||
String string = Float.toString(value); | ||
return Float.parseFloat(string); | ||
} | ||
} |
Binary file added
BIN
+2.01 KB
tests/test_data/samples/javacore/strings/trivial/ToStringAndBack.class
Binary file not shown.
Oops, something went wrong.