mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
GC updates
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32420 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
b80266e49b
commit
68ba47afe2
3 changed files with 23 additions and 13 deletions
|
@ -4,20 +4,24 @@
|
|||
int
|
||||
main()
|
||||
{
|
||||
NSGarbageCollector *collector = [NSGarbageCollector defaultCollector];
|
||||
START_SET("Garbage collection");
|
||||
NSGarbageCollector *collector;
|
||||
NSZone *z;
|
||||
|
||||
if (collector == nil) return 0; // No garbage collection.
|
||||
collector = [NSGarbageCollector defaultCollector];
|
||||
if (collector == nil) SKIP("GNUstep was not built for Garbage collection")
|
||||
|
||||
PASS([collector zone] == NSDefaultMallocZone(),
|
||||
"collector zone is default");
|
||||
"collector zone is default")
|
||||
PASS([[NSObject new] zone] == NSDefaultMallocZone(),
|
||||
"object zone is default");
|
||||
"object zone is default")
|
||||
PASS((z = NSCreateZone(1024, 128, YES)) == NSDefaultMallocZone(),
|
||||
"created zone is default");
|
||||
"created zone is default")
|
||||
PASS((z = NSCreateZone(1024, 128, YES)) == NSDefaultMallocZone(),
|
||||
"created zone is default");
|
||||
NSRecycleZone(z);
|
||||
"created zone is default")
|
||||
PASS_RUNS(NSRecycleZone(z), "zone recycling works")
|
||||
|
||||
END_SET("Garbage collection");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -31,11 +31,13 @@ static unsigned finalisationCounter = 0;
|
|||
int
|
||||
main()
|
||||
{
|
||||
NSGarbageCollector *collector = [NSGarbageCollector defaultCollector];
|
||||
NSGarbageCollector *collector;
|
||||
NSNotificationCenter *center;
|
||||
MyClass *object;
|
||||
|
||||
if (collector == nil) return 0; // No garbage collection.
|
||||
START_SET("Garbage Collection");
|
||||
collector = [NSGarbageCollector defaultCollector];
|
||||
if (collector == nil) SKIP("GNUstep was not built for Garbage collection")
|
||||
|
||||
center = [NSNotificationCenter defaultCenter];
|
||||
object = [MyClass new];
|
||||
|
@ -45,12 +47,13 @@ main()
|
|||
object: nil];
|
||||
|
||||
[center postNotificationName: @"Notification" object: nil];
|
||||
PASS([MyClass notificationCounter] == 1, "simple notification works");
|
||||
PASS([MyClass notificationCounter] == 1, "simple notification works")
|
||||
object = nil;
|
||||
[collector collectExhaustively];
|
||||
PASS([MyClass finalisationCounter] == 1, "finalisation done");
|
||||
PASS([MyClass finalisationCounter] == 1, "finalisation done")
|
||||
[center postNotificationName: @"Notification" object: nil];
|
||||
PASS([MyClass notificationCounter] == 1, "automatic removal works");
|
||||
PASS([MyClass notificationCounter] == 1, "automatic removal works")
|
||||
|
||||
END_SET("Garbage Collection");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -176,7 +176,10 @@ int main()
|
|||
[tester setValue: m forKey: @"name"];
|
||||
PASS([tester valueForKey: @"name"] == m,
|
||||
"KVC works with mutable string");
|
||||
PASS(rc + 1 == [m retainCount], "KVC retains object values");
|
||||
if (nil == [NSGarbageCollector defaultCollector])
|
||||
{
|
||||
PASS(rc + 1 == [m retainCount], "KVC retains object values");
|
||||
}
|
||||
|
||||
[tester setValue:n forKey: @"num1"];
|
||||
PASS([[tester valueForKey: @"num1"] isEqualToNumber:n],
|
||||
|
|
Loading…
Reference in a new issue