Since generated names now have their package names prefixed, the extra prefix, "Go", is both confusing and counter-productive to making the generated ObjC code look like any other native code. Change the default to the empty prefix, while preserving support for an explicit prefix if needed. This is a backwards incompatible change; to keep the old behaviour, specify "-prefix Go" to the gobind or gomobile command. While we're here, fix the Ivy example for the recent change in error returns. Change-Id: I7fef4a92a18ddadee972ccf359652e3b31624f33 Reviewed-on: https://go-review.googlesource.com/34643 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
98 lines
2.5 KiB
Objective-C
98 lines
2.5 KiB
Objective-C
// Copyright 2015 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
// +build ignore
|
|
|
|
@import ObjectiveC.message;
|
|
@import Foundation;
|
|
@import XCTest;
|
|
@import Objcpkg;
|
|
|
|
@interface TestNSObject : NSObject
|
|
|
|
- (NSString *)description;
|
|
- (NSString *)super_description;
|
|
|
|
@end
|
|
|
|
@implementation TestNSObject
|
|
|
|
- (NSString *)description {
|
|
return @"hej";
|
|
}
|
|
|
|
- (NSString *)super_description {
|
|
return [super description];
|
|
}
|
|
|
|
@end
|
|
|
|
@interface wrappers : XCTestCase
|
|
|
|
@end
|
|
|
|
@implementation wrappers
|
|
|
|
- (void)setUp {
|
|
[super setUp];
|
|
// Put setup code here. This method is called before the invocation of each test method in the class.
|
|
}
|
|
|
|
- (void)tearDown {
|
|
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
[super tearDown];
|
|
}
|
|
|
|
- (void)testFunction {
|
|
ObjcpkgFunc();
|
|
}
|
|
|
|
- (void)testMethod {
|
|
ObjcpkgMethod();
|
|
}
|
|
|
|
- (void)testNew {
|
|
ObjcpkgNew();
|
|
}
|
|
|
|
- (void)testError {
|
|
ObjcpkgError();
|
|
}
|
|
|
|
- (void)testClass {
|
|
ObjcpkgGoNSDate *d = [[ObjcpkgGoNSDate alloc] init];
|
|
NSString *desc = [d description];
|
|
XCTAssertEqual(d, [d getSelf], "GoNSDate self not identical");
|
|
XCTAssertEqual(ObjcpkgHash, [d hash], "GoNSDate hash not identical");
|
|
XCTAssertTrue([desc isEqualToString:ObjcpkgDescriptionStr], "GoNSDate description mismatch: %@", desc);
|
|
ObjcpkgGoUIResponder *resp = [[ObjcpkgGoUIResponder alloc] init];
|
|
[resp pressesBegan:nil withEvent:nil];
|
|
XCTAssertTrue([resp called], "GoUIResponder.pressesBegan not called");
|
|
}
|
|
|
|
- (void)testSuper {
|
|
ObjcpkgGoNSObject *o = [[ObjcpkgGoNSObject alloc] init];
|
|
struct objc_super _super = {
|
|
.receiver = o,
|
|
.super_class = [NSObject class],
|
|
};
|
|
NSString *superDesc = ((NSString *(*)(struct objc_super*, SEL))objc_msgSendSuper)(&_super, @selector(description));
|
|
XCTAssertTrue([superDesc isEqualToString:[o description]], "GoNSObject description mismatch");
|
|
[o setUseSelf:TRUE];
|
|
XCTAssertTrue([ObjcpkgDescriptionStr isEqualToString:[o description]], "GoNSObject description mismatch");
|
|
}
|
|
|
|
- (void)testIdentity {
|
|
NSDate *d = [[NSDate alloc] init];
|
|
NSDate *d2 = ObjcpkgDupNSDate(d);
|
|
XCTAssertEqual(d, d2, @"ObjcpkgDupNSDate failed to duplicate ObjC instance");
|
|
ObjcpkgGoNSDate *gd = [[ObjcpkgGoNSDate alloc] init];
|
|
NSDate *gd2 = ObjcpkgDupNSDate(gd);
|
|
XCTAssertEqual(gd, gd2, @"ObjcpkgDupNSDate failed to duplicate Go instance");
|
|
NSDate *gd3 = ObjcpkgNewGoNSDate();
|
|
NSDate *gd4 = ObjcpkgDupNSDate(gd3);
|
|
XCTAssertEqual(gd4, gd3, @"ObjcpkgDupNSDate failed to duplicate instance created in Go");
|
|
}
|
|
@end
|