Skip to content

Commit 0fc6441

Browse files
committed
instruction_test: improved if_icmp* tests
1 parent 722125b commit 0fc6441

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

src/testfiles/IfIntegerCompare.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class IfIntegerCompare
2121
{
2222
private static int res1;
2323
private static int res2;
24+
private static int res3;
25+
private static int res4;
2426
private static int cmp0 = 0;
2527
private static int cmp3 = 3;
2628

@@ -38,6 +40,18 @@ public static void main(String [] args)
3840
} else {
3941
res2 = 0xBABE;
4042
}
43+
// if_icmplt
44+
if ( cmp0 >= cmp3 ) {
45+
res3 = 0;
46+
} else {
47+
res3 = 0xBEEF;
48+
}
49+
// if_icmpgt
50+
if ( cmp0 <= cmp3 ) {
51+
res4 = 0xAFFE;
52+
} else {
53+
res4 = 0;
54+
}
4155
}
4256

4357
}

src/testfiles/LdcInteger.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+

src/unittests/instruction_test.fs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,17 +200,36 @@ program_sipush write-programm
200200
assert( depth 0 = )
201201
;
202202

203+
: ldc_integer_test
204+
assert( depth 0 = )
205+
s" ../testfiles/" jvm_classpath.add()
206+
s" LdcInteger" 2dup
207+
jvm_java
208+
jvm_stack.findClass() throw
209+
s" babe|I" jvm_class.getStatic() throw
210+
assert( 0xBABE = )
211+
assert( depth 0 = )
212+
;
213+
203214
: if_icmp_test1
204215
assert( depth 0 = )
205216
s" ../testfiles/" jvm_classpath.add()
206-
s" IfIntegerCompare" 2dup
217+
s" IfIntegerCompare" 2dup
207218
jvm_java
208219
jvm_stack.findClass() throw
209220
dup
210221
s" res1|I" jvm_class.getStatic() throw
211222
assert( 0xDEAD = )
223+
dup
212224
s" res2|I" jvm_class.getStatic() throw
213225
assert( 0xBABE = )
226+
dup
227+
s" res3|I" jvm_class.getStatic() throw
228+
assert( 0xBEEF = )
229+
dup
230+
s" res4|I" jvm_class.getStatic() throw
231+
assert( 0xAFFE = )
232+
drop
214233
\ TODO test: eq ne lt gt ifeq ifne iflt ifge ifgt ifle
215234
assert( depth 0 = )
216235
;
@@ -229,4 +248,5 @@ program_sipush write-programm
229248
static_inititilazer_test1
230249
static_inititilazer_test2
231250
if_icmp_test1
251+
ldc_integer_test
232252
;

0 commit comments

Comments
 (0)