~ubuntu-branches/ubuntu/oneiric/gnustep-base/oneiric

« back to all changes in this revision

Viewing changes to Tests/base/NSObject/test01.m

  • Committer: Bazaar Package Importer
  • Author(s): Yavor Doganov
  • Date: 2011-05-31 11:03:16 UTC
  • mfrom: (1.2.12 upstream) (7.2.4 experimental)
  • Revision ID: james.westby@ubuntu.com-20110531110316-0uny1hmsdl3gmn5v
Tags: 1.22.0-1
* New major upstream release:
  + Includes support for the new Objective-C runtime (Closes: #624928).
* debian/control.m4 (Vcs-Arch): Replace with...
  (Vcs-Git): ...since tla-buildpackage is gone.
  (Vcs-Browser): New field.
  (Standards-Version): Bump to 3.9.2; no changes needed.
  (Build-Depends): Add libicu-dev, needed for NSLocale.
  (libgnustep-base`'SOV_BASE-dbg) <Conflicts>: Set to
  libgnustep-base1.20-dbg only.
  <Recommends>: Set to libobjc3-dbg.
* debian/control: Regenerate.
* debian/patches/gnutls-deprecated.patch: New; fix usage of deprecated
  GnuTLS function (Closes: #624054).
* debian/patches/missing-header.patch:
* debian/patches/no-march.patch: Delete; fixed upstream.
* debian/patches/NSBundle-PROCFS_EXE_LINK.patch: Delete; apparently not
  needed anymore.
* debian/patches/manpage-fixes.patch: A few more fixes.
* debian/patches/avoid-nsl-linkage.patch: Refresh.
* debian/patches/autoreconf.patch: Regenerate.
* debian/patches/series: Update.
* debian/rules (v_objc, v_make): Bump to 4:4.6 (for libobjc3) and 2.6
  (for the sake of the testsuite) accordingly.
  (debian/build-shared-stamp): Run the testsuite.
  (install-shared): Do not delete non-existent .swp file.
  (install-common): Use $(sov_base) instead of hardcoded version.
* debian/copyright: Update copyright years.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#import "Testing.h"
 
2
#import <Foundation/NSAutoreleasePool.h>
 
3
#import <Foundation/NSString.h>
 
4
#import <Foundation/NSArray.h>
 
5
@interface MyEvilClass : NSObject
 
6
{
 
7
 Class class;
 
8
 const char *name;
 
9
 long version;
 
10
 unsigned long info;
 
11
 /* not sure which of these is correct */
 
12
 Class class_;
 
13
 const char *name_;
 
14
 long version_;
 
15
 unsigned long info_;
 
16
}
 
17
-(void)setInfo:(unsigned long)info;
 
18
@end
 
19
 
 
20
@implementation MyEvilClass 
 
21
-(void)setInfo:(unsigned long)theInfo
 
22
{
 
23
  info = theInfo;
 
24
}
 
25
@end
 
26
 
 
27
int main()
 
28
{
 
29
  NSAutoreleasePool   *arp = [NSAutoreleasePool new];
 
30
  id evilObject;
 
31
  PASS([NSObject isClass] &&
 
32
       [NSString isClass] &&
 
33
       [NSArray isClass],
 
34
       "-isClass returns YES on a Class");
 
35
  
 
36
  PASS((![[[NSObject new] autorelease] isClass] &&
 
37
       ![[NSString stringWithCString:"foo"] isClass] &&
 
38
       ![[[NSArray new] autorelease] isClass]),
 
39
       "-isClass returns NO on an instance");
 
40
  
 
41
  evilObject = [MyEvilClass new];
 
42
  [evilObject setInfo:1];
 
43
  PASS(![evilObject isClass], 
 
44
       "-isClass returns NO on an instance (special test for broken libobjc)");
 
45
  
 
46
  PASS(([[[NSObject new] autorelease] isKindOfClass:[NSObject class]] &&
 
47
       [[[NSString new] autorelease] isKindOfClass:[NSString class]] &&
 
48
       ![[[NSObject new] autorelease] isKindOfClass:[NSString class]] &&
 
49
       [[[NSString new] autorelease] isKindOfClass:[NSObject class]] &&
 
50
       ![[[NSString new] autorelease] isKindOfClass:[NSArray class]] &&
 
51
       [[[NSMutableString new] autorelease] isKindOfClass:[NSString class]]),
 
52
       "-isKindOfClass: works"); 
 
53
  
 
54
     /* should return YES if receiver and argument are both NSObject */
 
55
  PASS([NSObject isKindOfClass:[NSObject class]] &&
 
56
       ![NSString isKindOfClass:[NSString class]] &&  
 
57
       ![NSObject isKindOfClass:[NSString class]] &&
 
58
       [NSString isKindOfClass:[NSObject class]],
 
59
       "+isKindOfClass: works");
 
60
 
 
61
  [arp release]; arp = nil;
 
62
  return 0;
 
63
}