1
+ public class B {
2
+ public int forloop () {
3
+ int result = 0 ;
4
+ for (int i = 0 ; i < 10 ; i ++) {// $ bound="i in [0..10]" bound="i in [0..9]"
5
+ result = i ; // $ bound="i in [0..9]"
6
+ }
7
+ return result ; // $ bound="result in [0..9]"
8
+ }
9
+
10
+ public int forloopexit () {
11
+ int result = 0 ;
12
+ for (; result < 10 ;) { // $ bound="result in [0..10]"
13
+ result += 1 ; // $ bound="result in [0..9]"
14
+ }
15
+ return result ; // $ bound="result = 10"
16
+ }
17
+
18
+ public int forloopexitstep () {
19
+ int result = 0 ;
20
+ for (; result < 10 ;) { // $ bound="result in [0..12]"
21
+ result += 3 ; // $ bound="result in [0..9]"
22
+ }
23
+ return result ; // $ bound="result = 12"
24
+ }
25
+
26
+ public int forloopexitupd () {
27
+ int result = 0 ;
28
+ for (; result < 10 ; result ++) { // $ bound="result in [0..9]" bound="result in [0..10]"
29
+ }
30
+ return result ; // $ bound="result = 10"
31
+ }
32
+
33
+ public int forloopexitnested () {
34
+ int result = 0 ;
35
+ for (; result < 10 ;) {
36
+ int i = 0 ;
37
+ for (; i < 3 ;) { // $ bound="i in [0..3]"
38
+ i += 1 ; // $ bound="i in [0..2]"
39
+ }
40
+ result += i ; // $ bound="result in [0..9]" bound="i = 3"
41
+ }
42
+ return result ; // $ MISSING:bound="result = 12"
43
+ }
44
+
45
+ public int emptyforloop () {
46
+ int result = 0 ;
47
+ for (int i = 0 ; i < 0 ; i ++) { // $ bound="i = 0" bound="i in [0..-1]"
48
+ result = i ; // $ bound="i in [0..-1]"
49
+ }
50
+ return result ; // $ bound="result = 0"
51
+ }
52
+
53
+ public int noloop () {
54
+ int result = 0 ;
55
+ result += 1 ; // $ bound="result = 0"
56
+ return result ; // $ bound="result = 1"
57
+ }
58
+
59
+ public int foreachloop () {
60
+ int result = 0 ;
61
+ for (int i : new int [] {1 , 2 , 3 , 4 , 5 }) {
62
+ result = i ;
63
+ }
64
+ return result ;
65
+ }
66
+
67
+ public int emptyforeachloop () {
68
+ int result = 0 ;
69
+ for (int i : new int [] {}) {
70
+ result = i ;
71
+ }
72
+ return result ;
73
+ }
74
+
75
+ public int whileloop () {
76
+ int result = 100 ;
77
+ while (result > 5 ) { // $ bound="result in [4..100]"
78
+ result = result - 2 ; // $ bound="result in [6..100]"
79
+ }
80
+ return result ; // $ bound="result = 4"
81
+ }
82
+
83
+ public int oddwhileloop () {
84
+ int result = 101 ;
85
+ while (result > 5 ) { // $ bound="result in [5..101]"
86
+ result = result - 2 ; // $ bound="result in [7..101]"
87
+ }
88
+ return result ; // $ bound="result = 5"
89
+ }
90
+ }
0 commit comments