ObjFW  Diff

Differences From Artifact [8332694435]:

To Artifact [723d9a0843]:

  • File tests/OFArrayTests.m — part of check-in [e1e7ffa903] at 2011-09-22 23:25:42 on branch trunk — Exceptions are now autoreleased.

    This is safe as an "exception loop" can't happen, since if allocating
    an exception fails, it throws an OFAllocFailedException which is
    preallocated and can always be thrown.

    So, the worst case would be that an autorelease of an exception fails,
    triggering an OFOutOfMemoryException for which there is no memory,
    resulting in an OFAllocFailedException to be thrown. (user: js, size: 8249) [annotate] [blame] [check-ins using]


208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
		for (OFString *s in m[0]) {
			if (i == 0)
				[m[0] addObject: @""];
			i++;
		}
	} @catch (OFEnumerationMutationException *e) {
		ok = YES;
		[e release];
	}

	TEST(@"Detection of mutation during Fast Enumeration", ok)

	[m[0] removeNObjects: 1];
#endif








<







208
209
210
211
212
213
214

215
216
217
218
219
220
221
		for (OFString *s in m[0]) {
			if (i == 0)
				[m[0] addObject: @""];
			i++;
		}
	} @catch (OFEnumerationMutationException *e) {
		ok = YES;

	}

	TEST(@"Detection of mutation during Fast Enumeration", ok)

	[m[0] removeNObjects: 1];
#endif

245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
		@try {
			[a2 enumerateObjectsUsingBlock:
			    ^ (id obj, size_t idx, BOOL *stop) {
				[a2 removeObjectAtIndex: idx];
			}];
		} @catch (OFEnumerationMutationException *e) {
			ok = YES;
			[e release];
		} @catch (OFOutOfRangeException *e) {
			/*
			 * Out of bounds access due to enumeration not being
			 * detected.
			 */
			[e release];
		}

		TEST(@"Detection of mutation during enumeration using blocks",
		    ok)
	}

	TEST(@"-[replaceObjectsUsingBlock:]",







<





<







244
245
246
247
248
249
250

251
252
253
254
255

256
257
258
259
260
261
262
		@try {
			[a2 enumerateObjectsUsingBlock:
			    ^ (id obj, size_t idx, BOOL *stop) {
				[a2 removeObjectAtIndex: idx];
			}];
		} @catch (OFEnumerationMutationException *e) {
			ok = YES;

		} @catch (OFOutOfRangeException *e) {
			/*
			 * Out of bounds access due to enumeration not being
			 * detected.
			 */

		}

		TEST(@"Detection of mutation during enumeration using blocks",
		    ok)
	}

	TEST(@"-[replaceObjectsUsingBlock:]",