Skip to content

Commit 24bc8d6

Browse files
committed
refactor: move test stub out
1 parent 7a3799b commit 24bc8d6

File tree

2 files changed

+27
-25
lines changed

2 files changed

+27
-25
lines changed

src/test/java/org/jd/core/v1/CfrTest.java

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import org.jd.core.v1.service.layouter.LayoutFragmentProcessor;
2424
import org.jd.core.v1.service.tokenizer.javafragmenttotoken.JavaFragmentToTokenProcessor;
2525
import org.jd.core.v1.service.writer.WriteTokenProcessor;
26+
import org.jd.core.v1.stub.FloatingPointCasting;
2627
import org.junit.Test;
2728

2829
import 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)));
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.jd.core.v1.stub;
2+
3+
public class FloatingPointCasting {
4+
private final long l = 9223372036854775806L;
5+
private final Long L = 9223372036854775806L;
6+
7+
long getLong() {
8+
return 9223372036854775806L;
9+
}
10+
11+
void test1() {
12+
long b = (long) (double) getLong();
13+
System.out.println(b == getLong()); // Prints "false"
14+
}
15+
void test2() {
16+
long b = (long) (double) l;
17+
System.out.println(b == l); // Prints "false"
18+
}
19+
void test3() {
20+
long b = (long) (double) L;
21+
System.out.println(b == L); // Prints "false"
22+
}
23+
}

0 commit comments

Comments
 (0)