mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
tidied
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@32686 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ae273366e8
commit
603e2f2f08
4 changed files with 138 additions and 137 deletions
|
@ -10,66 +10,66 @@ static int B_destroyed;
|
|||
|
||||
class A
|
||||
{
|
||||
int b;
|
||||
public:
|
||||
A() : b(12)
|
||||
{
|
||||
pass(0 == A_init, "Constructor only called once");
|
||||
pass(0 == B_init, "a constructor called before b constructor ");
|
||||
A_init = 1;
|
||||
};
|
||||
~A()
|
||||
{
|
||||
pass(0 == A_destroyed, "Destructor only called once");
|
||||
pass(1 == B_destroyed, "b destructor called before a destructor");
|
||||
A_destroyed = 1;
|
||||
};
|
||||
int b;
|
||||
public:
|
||||
A() : b(12)
|
||||
{
|
||||
PASS(0 == A_init, "Constructor only called once");
|
||||
PASS(0 == B_init, "a constructor called before b constructor ");
|
||||
A_init = 1;
|
||||
};
|
||||
~A()
|
||||
{
|
||||
PASS(0 == A_destroyed, "Destructor only called once");
|
||||
PASS(1 == B_destroyed, "b destructor called before a destructor");
|
||||
A_destroyed = 1;
|
||||
};
|
||||
};
|
||||
class A1
|
||||
{
|
||||
int b;
|
||||
public:
|
||||
A1() : b(12)
|
||||
{
|
||||
pass(1 == A_init, "a constructor called before b constructor ");
|
||||
B_init = 1;
|
||||
};
|
||||
~A1()
|
||||
{
|
||||
pass(0 == A_destroyed, "b destructor called before a destructor");
|
||||
B_destroyed = 1;
|
||||
};
|
||||
int b;
|
||||
public:
|
||||
A1() : b(12)
|
||||
{
|
||||
PASS(1 == A_init, "a constructor called before b constructor ");
|
||||
B_init = 1;
|
||||
};
|
||||
~A1()
|
||||
{
|
||||
PASS(0 == A_destroyed, "b destructor called before a destructor");
|
||||
B_destroyed = 1;
|
||||
};
|
||||
};
|
||||
|
||||
@interface B : NSObject
|
||||
{
|
||||
A a;
|
||||
A a;
|
||||
}
|
||||
@end
|
||||
@interface C : B
|
||||
{
|
||||
A1 b;
|
||||
A1 b;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation B
|
||||
- (id)init
|
||||
- (id) init
|
||||
{
|
||||
pass(1 == A_init, "a constructor called before -init");
|
||||
pass(1 == B_init, "b constructor called before -init");
|
||||
pass(0 == A_destroyed, "a destructor not called before -init");
|
||||
pass(0 == B_destroyed, "b destructor not called before -init");
|
||||
return self;
|
||||
PASS(1 == A_init, "a constructor called before -init");
|
||||
PASS(1 == B_init, "b constructor called before -init");
|
||||
PASS(0 == A_destroyed, "a destructor not called before -init");
|
||||
PASS(0 == B_destroyed, "b destructor not called before -init");
|
||||
return self;
|
||||
}
|
||||
@end
|
||||
|
||||
@implementation C @end
|
||||
int main(void)
|
||||
{
|
||||
// Make sure constructors / destructors are called even without -init
|
||||
[[C alloc] release];
|
||||
// Reset state
|
||||
A_init = B_init = A_destroyed = B_destroyed = 0;
|
||||
// Check init is called in the middle
|
||||
[[C new] release];
|
||||
// Make sure constructors / destructors are called even without -init
|
||||
[[C alloc] release];
|
||||
// Reset state
|
||||
A_init = B_init = A_destroyed = B_destroyed = 0;
|
||||
// Check init is called in the middle
|
||||
[[C new] release];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue