-
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.
fix: adjust types for arithmetic instructions (#921)
- Loading branch information
Showing
9 changed files
with
176 additions
and
121 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
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
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
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
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
37 changes: 37 additions & 0 deletions
37
jadx-core/src/test/java/jadx/tests/integration/arith/TestArith4.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,37 @@ | ||
package jadx.tests.integration.arith; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.tests.api.IntegrationTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
public class TestArith4 extends IntegrationTest { | ||
|
||
public static class TestCls { | ||
public static byte test(byte b) { | ||
int k = b & 7; | ||
return (byte) (((b & 255) >>> (8 - k)) | (b << k)); | ||
} | ||
|
||
public static int test2(String str) { | ||
int k = 'a' | str.charAt(0); | ||
return (1 - k) & (1 + k); | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
assertThat(getClassNode(TestCls.class)) | ||
.code() | ||
.containsOne("int k = b & 7;") | ||
.containsOne("return (1 - k) & (k + 1);"); | ||
} | ||
|
||
@Test | ||
public void testNoDebug() { | ||
noDebugInfo(); | ||
assertThat(getClassNode(TestCls.class)) | ||
.code(); | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
jadx-core/src/test/java/jadx/tests/integration/arith/TestXor.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,63 @@ | ||
package jadx.tests.integration.arith; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import jadx.tests.api.SmaliTest; | ||
|
||
import static jadx.tests.api.utils.assertj.JadxAssertions.assertThat; | ||
|
||
public class TestXor extends SmaliTest { | ||
|
||
@SuppressWarnings("PointlessBooleanExpression") | ||
public static class TestCls { | ||
public boolean test1() { | ||
return test() ^ true; | ||
} | ||
|
||
public boolean test2(boolean v) { | ||
return v ^ true; | ||
} | ||
|
||
public boolean test() { | ||
return true; | ||
} | ||
|
||
public void check() { | ||
assertThat(test1()).isFalse(); | ||
assertThat(test2(true)).isFalse(); | ||
assertThat(test2(false)).isTrue(); | ||
} | ||
} | ||
|
||
@Test | ||
public void test() { | ||
assertThat(getClassNode(TestCls.class)) | ||
.code() | ||
.containsOne("return !test();") | ||
.containsOne("return !v;"); | ||
} | ||
|
||
@Test | ||
public void smali() { | ||
// @formatter:off | ||
/* | ||
public boolean test1() { | ||
return test() ^ true; | ||
} | ||
public boolean test2() { | ||
return test() ^ false; | ||
} | ||
public boolean test() { | ||
return true; | ||
} | ||
*/ | ||
// @formatter:on | ||
assertThat(getClassNodeFromSmali()) | ||
.code() | ||
.containsOne("return !test();") | ||
.containsOne("return test();"); | ||
} | ||
|
||
} |
61 changes: 0 additions & 61 deletions
61
jadx-core/src/test/java/jadx/tests/integration/conditions/TestXor.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.