Comments (2)
I got it, when local1
value = 0, the result order is always reversed. how can i fix this?
from dexmaker.
Hey @wuyr sorry I'm getting back so late - I think this is working as expected. writing a comparison of compare(LT, local1, param) is the java equivalent of
if (local1 < param)
which could also be rewritten as
if (param >= local1)
I tried writing a test case for this with the local having a value of 0, and it seems to work correctly - lmk if you're seeing different, or if I'm misunderstanding your use case. Thanks!
@Test
public void testIntCompare() throws Exception {
/*
* public static bool call(int b) {
* return 0 < b
* }
*/
MethodId<?, Boolean> methodId = GENERATED.getMethod(
TypeId.BOOLEAN, "call", TypeId.INT);
Code code = dexMaker.declare(methodId, PUBLIC | STATIC);
Local<Integer> localA = code.newLocal(TypeId.INT);
Local<Integer> localB = code.getParameter(0, TypeId.INT);
Local<Boolean> result = code.newLocal(TypeId.get(boolean.class));
Label afterIf = new Label();
Label ifBody = new Label();
code.loadConstant(localA, 0);
code.compare(Comparison.LT, ifBody, localA, localB);
code.jump(afterIf);
code.mark(ifBody);
code.loadConstant(result, true);
code.returnValue(result);
code.mark(afterIf);
code.loadConstant(result, false);
code.returnValue(result);
Method method = getMethod();
assertEquals(true, method.invoke(null, 5));
assertEquals(false, method.invoke(null, -5));
assertEquals(false, method.invoke(null, 0));
}```
from dexmaker.
Related Issues (20)
- Breakpoints crash/hang debugger HOT 5
- Allow mocking of native methods HOT 1
- How to generate a class with generics type? HOT 4
- Could not init mockmaker InlineStaticMockMaker neither InlineDexmakerMockMaker HOT 8
- Does not introduce transitive dependency of mockito per README HOT 2
- mockStatic PendingIntent got NPE HOT 1
- Mock fail when use dexmaker-mockito-inline instead of dexmaker-mockito HOT 1
- Migrate away from JCenter HOT 6
- dexmaker crash HOT 2
- dexmaker gson crash HOT 1
- dexmaker under AOSP HOT 2
- Failed to load interface org.mockito.plugins.MockMaker implementation declared in sun.misc.CompoundEnumeratio HOT 5
- [Help] How get self method and Object HOT 12
- Random FileNotFoundException when mocking Android class HOT 5
- Gain
- java.lang.SecurityException: Writable dex file error when executing on Android 14 HOT 1
- UI test cases failing on API 34 HOT 5
- Whether the JDK version mapping description can be provided? HOT 1
- [URGENT] Library is not downloadable from maven HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dexmaker.