-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
105 additions
and
9 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
40 changes: 40 additions & 0 deletions
40
jadx-core/src/test/java/jadx/tests/integration/types/TestTypeResolver15.java
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,40 @@ | ||
package jadx.tests.integration.types; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.tests.api.SmaliTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
/** | ||
* Issue 921 (second case) | ||
*/ | ||
public class TestTypeResolver15 extends SmaliTest { | ||
|
||
public static class TestCls { | ||
private void test(boolean z) { | ||
useInt(z ? 0 : 8); | ||
useInt(!z ? 1 : 0); // replaced with xor in smali test | ||
} | ||
|
||
private void useInt(int i) { | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
noDebugInfo(); | ||
assertThat(getClassNode(TestCls.class)) | ||
.code() | ||
// .containsOne("useInt(!z ? 1 : 0);") // TODO: convert to ternary | ||
.containsOne("useInt(z ? 0 : 8);"); | ||
} | ||
|
||
@Test | ||
public void testSmali() { | ||
assertThat(getClassNodeFromSmali()) | ||
.code() | ||
.containsOne("useInt(z ? 0 : 8);") | ||
.containsOne("useInt(!z ? 1 : 0);"); | ||
} | ||
} |
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,27 @@ | ||
.class public Ltypes/TestTypeResolver15; | ||
.super Ljava/lang/Object; | ||
|
||
.method private test(Z)V | ||
.locals 2 | ||
|
||
if-eqz p1, :cond_0 | ||
|
||
const/4 v1, 0x0 | ||
goto :goto_0 | ||
|
||
:cond_0 | ||
const/16 v1, 0x8 | ||
|
||
:goto_0 | ||
invoke-virtual {p0, v1}, Ltypes/TestTypeResolver15;->useInt(I)V | ||
|
||
xor-int/lit8 p1, p1, 0x1 | ||
invoke-virtual {p0, p1}, Ltypes/TestTypeResolver15;->useInt(I)V | ||
|
||
return-void | ||
.end method | ||
|
||
.method private useInt(I)V | ||
.registers 2 | ||
return-void | ||
.end method |