@@ 442-465 (lines=24) @@ | ||
439 | ||
440 | $conditionCounter = 0; |
|
441 | $invariantIterator = $assertionLists->getIterator(); |
|
442 | for ($i = 0; $i < $invariantIterator->count(); $i++) { |
|
443 | // Create the inner loop for the different assertions |
|
444 | if ($invariantIterator->current()->count() !== 0) { |
|
445 | $assertionIterator = $invariantIterator->current()->getIterator(); |
|
446 | ||
447 | // collect all assertion code for assertions of this instance |
|
448 | for ($j = 0; $j < $assertionIterator->count(); $j++) { |
|
449 | // Code to catch failed assertions |
|
450 | $code .= $assertionIterator->current()->toCode(); |
|
451 | $assertionIterator->next(); |
|
452 | $conditionCounter++; |
|
453 | } |
|
454 | ||
455 | // generate the check for assertions results |
|
456 | if ($conditionCounter > 0) { |
|
457 | $code .= 'if (!empty(' . ReservedKeywords::FAILURE_VARIABLE . ') || !empty(' . ReservedKeywords::UNWRAPPED_FAILURE_VARIABLE . ')) { |
|
458 | ' . Placeholders::ENFORCEMENT . 'invariant' . Placeholders::PLACEHOLDER_CLOSE . ' |
|
459 | }'; |
|
460 | } |
|
461 | } |
|
462 | ||
463 | // increment the outer loop |
|
464 | $invariantIterator->next(); |
|
465 | } |
|
466 | ||
467 | $code .= '} |
|
468 | \AppserverIo\Doppelgaenger\ContractContext::close(); |
@@ 159-188 (lines=30) @@ | ||
156 | // We need a counter to check how much conditions we got |
|
157 | $conditionCounter = 0; |
|
158 | $listIterator = $assertionLists->getIterator(); |
|
159 | for ($i = 0; $i < $listIterator->count(); $i++) { |
|
160 | // Create the inner loop for the different assertions |
|
161 | $assertionIterator = $listIterator->current()->getIterator(); |
|
162 | ||
163 | // Only act if we got actual entries |
|
164 | if ($assertionIterator->count() === 0) { |
|
165 | // increment the outer loop |
|
166 | $listIterator->next(); |
|
167 | continue; |
|
168 | } |
|
169 | ||
170 | // collect all assertion code for assertions of this instance |
|
171 | for ($j = 0; $j < $assertionIterator->count(); $j++) { |
|
172 | // Code to catch failed assertions |
|
173 | $code .= $assertionIterator->current()->toCode(); |
|
174 | $assertionIterator->next(); |
|
175 | $conditionCounter++; |
|
176 | } |
|
177 | ||
178 | // generate the check for assertions results |
|
179 | if ($conditionCounter > 0) { |
|
180 | $code .= ' if (!empty(' . ReservedKeywords::FAILURE_VARIABLE . ') || !empty(' . ReservedKeywords::UNWRAPPED_FAILURE_VARIABLE . ')) { |
|
181 | ' . Placeholders::ENFORCEMENT . $functionName . 'postcondition' . Placeholders::PLACEHOLDER_CLOSE . ' |
|
182 | } |
|
183 | '; |
|
184 | } |
|
185 | ||
186 | // increment the outer loop |
|
187 | $listIterator->next(); |
|
188 | } |
|
189 | ||
190 | // Closing bracket for contract depth check |
|
191 | $code .= '} |
@@ 123-157 (lines=35) @@ | ||
120 | // We need a counter to check how much conditions we got |
|
121 | $conditionCounter = 0; |
|
122 | $listIterator = $assertionLists->getIterator(); |
|
123 | for ($i = 0; $i < $listIterator->count(); $i++) { |
|
124 | // Create the inner loop for the different assertions |
|
125 | $assertionIterator = $listIterator->current()->getIterator(); |
|
126 | ||
127 | // Only act if we got actual entries |
|
128 | if ($assertionIterator->count() === 0) { |
|
129 | // increment the outer loop |
|
130 | $listIterator->next(); |
|
131 | continue; |
|
132 | } |
|
133 | ||
134 | // create a wrap around assuring that inherited conditions get or-combined |
|
135 | $code .= ' |
|
136 | if (' . ReservedKeywords::PASSED_ASSERTION_FLAG . ' === false) { |
|
137 | '; |
|
138 | ||
139 | // iterate through the conditions for this certain instance |
|
140 | for ($j = 0; $j < $assertionIterator->count(); $j++) { |
|
141 | $conditionCounter++; |
|
142 | ||
143 | // Code to catch failed assertions |
|
144 | $code .= $assertionIterator->current()->toCode(); |
|
145 | $assertionIterator->next(); |
|
146 | } |
|
147 | ||
148 | // close the or-combined wrap |
|
149 | $code .= ' if (empty(' . ReservedKeywords::FAILURE_VARIABLE . ') && empty(' . ReservedKeywords::UNWRAPPED_FAILURE_VARIABLE . ')) { |
|
150 | ' . ReservedKeywords::PASSED_ASSERTION_FLAG . ' = true; |
|
151 | } |
|
152 | } |
|
153 | '; |
|
154 | ||
155 | // increment the outer loop |
|
156 | $listIterator->next(); |
|
157 | } |
|
158 | ||
159 | // Preconditions need or-ed conditions so we make sure only one condition list gets checked |
|
160 | $code .= 'if (' . ReservedKeywords::PASSED_ASSERTION_FLAG . ' === false){ |