2323import org .jd .core .v1 .service .layouter .LayoutFragmentProcessor ;
2424import org .jd .core .v1 .service .tokenizer .javafragmenttotoken .JavaFragmentToTokenProcessor ;
2525import org .jd .core .v1 .service .writer .WriteTokenProcessor ;
26+ import org .jd .core .v1 .stub .FloatingPointCasting ;
2627import org .junit .Test ;
2728
2829import java .util .Collections ;
@@ -40,35 +41,13 @@ public class CfrTest extends TestCase {
4041 @ Test
4142 // https://github.com/java-decompiler/jd-core/issues/34
4243 public void testFloatingPointCasting () throws Exception {
43- class FloatingPointCasting {
44- private final long l = 9223372036854775806L ;
45- private final Long L = 9223372036854775806L ;
46-
47- long getLong () {
48- return 9223372036854775806L ;
49- }
50-
51- void test1 () {
52- long b = (long ) (double ) getLong ();
53- System .out .println (b == getLong ()); // Prints "false"
54- }
55- void test2 () {
56- long b = (long ) (double ) l ;
57- System .out .println (b == l ); // Prints "false"
58- }
59- void test3 () {
60- long b = (long ) (double ) L ;
61- System .out .println (b == L ); // Prints "false"
62- }
63- }
64-
6544 String internalClassName = FloatingPointCasting .class .getName ().replace ('.' , '/' );
6645 String source = decompile (new ClassPathLoader (), new PlainTextPrinter (), internalClassName );
6746
6847 // Check decompiled source code
69- assertTrue (source .matches (PatternMaker .make (": 51 */" , "long b = (long)(double)" )));
70- assertTrue (source .matches (PatternMaker .make (": 55 */" , "long b = Long.MAX_VALUE" )));
71- assertTrue (source .matches (PatternMaker .make (": 59 */" , "long b = (long)(double)" )));
48+ assertTrue (source .matches (PatternMaker .make (": 12 */" , "long b = (long)(double)" )));
49+ assertTrue (source .matches (PatternMaker .make (": 16 */" , "long b = Long.MAX_VALUE" )));
50+ assertTrue (source .matches (PatternMaker .make (": 20 */" , "long b = (long)(double)" )));
7251
7352 // Recompile decompiled source code and check errors
7453 assertTrue (CompilerUtil .compile ("1.8" , new JavaSourceFileObject (internalClassName , source )));
0 commit comments