Skip to content

Commit 257e5e2

Browse files
author
Matthias Güdemann
committed
Add regression test for lambda functions
Parses some class files with different lambda functions, matches status output of found references to lambdas.
1 parent 4d98795 commit 257e5e2

File tree

9 files changed

+108
-0
lines changed

9 files changed

+108
-0
lines changed

regression/cbmc-java/lambda1/B.class

1.32 KB
Binary file not shown.

regression/cbmc-java/lambda1/B.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class B {
2+
public int y;
3+
4+
public static java.util.function.Function<Double, Double> dmul = x -> x * 3.1415;
5+
6+
public void set(int x) {
7+
y = x;
8+
}
9+
}

regression/cbmc-java/lambda1/C.class

582 Bytes
Binary file not shown.
225 Bytes
Binary file not shown.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
interface CustomLambda<T> {
2+
boolean is_ok(T t);
3+
}
401 Bytes
Binary file not shown.
4.84 KB
Binary file not shown.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import java.util.function.*;
2+
3+
public class Lambdatest {
4+
5+
class A {
6+
int x;
7+
}
8+
9+
CustomLambda<Integer> custom = x -> true;
10+
BiFunction<Float, Integer, Integer> add = (x0, y0) -> x0.intValue() + y0;
11+
int z = 10;
12+
13+
A a;
14+
B b = new B();
15+
16+
public Integer g(Float x, Integer y, BiFunction<Float, Integer, Integer> fun) {
17+
return fun.apply(x, y);
18+
}
19+
20+
public int f(Float x, Integer y, Integer z) {
21+
Integer tmp = add.apply(x, y);
22+
Function<Integer, Integer> mul = (a) -> a * tmp;
23+
return mul.apply(z);
24+
}
25+
26+
public int i(int x) {
27+
int z = 5;
28+
Function<Integer, Integer> foo = (a) -> a * z;
29+
return foo.apply(x);
30+
}
31+
32+
public int j(int x) {
33+
Function<Integer, Integer> foo = (a) -> a * z;
34+
return foo.apply(x);
35+
}
36+
37+
public int k(int x) {
38+
a.x = 10;
39+
40+
Function<Integer, Integer> foo = (y) -> y * a.x;
41+
return foo.apply(x);
42+
}
43+
44+
public int l(int x) {
45+
b.y = 10;
46+
Function<Integer, Integer> foo = (y) -> {
47+
int r = y * b.y;
48+
b.set(r);
49+
return r;
50+
};
51+
b = new B();
52+
b.y = 14;
53+
return foo.apply(x);
54+
}
55+
56+
public int m(int x) {
57+
b.y = 10;
58+
Function<Integer, Integer> foo = (y) -> {
59+
int r = y * b.y;
60+
b.y = r;
61+
return r;
62+
};
63+
return foo.apply(x);
64+
}
65+
66+
// test static field of different class
67+
public double d(Double x) {
68+
return B.dmul.apply(x);
69+
}
70+
71+
public int capture2(Float a) {
72+
return add.apply(a, 1);
73+
}
74+
75+
public boolean custom(Integer i) {
76+
return custom.is_ok(i);
77+
}
78+
}
79+
80+
class C implements CustomLambda<Integer> {
81+
public boolean is_ok(Integer i) {
82+
return true;
83+
}
84+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
CORE
2+
Lambdatest.class
3+
--verbosity 10 --show-goto-functions
4+
lambda function reference lambda\$new\$0 in class \"Lambdatest\"
5+
lambda function reference lambda\$new\$1 in class \"Lambdatest\"
6+
lambda function reference lambda\$f\$2 in class \"Lambdatest\"
7+
lambda function reference lambda\$i\$3 in class \"Lambdatest\"
8+
lambda function reference lambda\$j\$4 in class \"Lambdatest\"
9+
lambda function reference lambda\$k\$5 in class \"Lambdatest\"
10+
lambda function reference lambda\$l\$6 in class \"Lambdatest\"
11+
lambda function reference lambda\$m\$7 in class \"Lambdatest\"
12+
lambda function reference lambda\$static\$0 in class \"B\"

0 commit comments

Comments
 (0)