github.com/MrKrisYu/mobile@v0.0.0-20230923092425-9be92a9aeacc/bind/testdata/testpkg/objcpkg/objc.go (about)

     1  // Copyright 2016 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package objcpkg
     6  
     7  import (
     8  	"ObjC/Foundation/NSDate"
     9  	"ObjC/Foundation/NSString"
    10  	"ObjC/QuartzCore/CAMediaTimingFunction"
    11  )
    12  
    13  func Func() {
    14  	NSDate.Date()
    15  	CAMediaTimingFunction.FunctionWithControlPoints(0, 0, 0, 0)
    16  }
    17  
    18  func Method() string {
    19  	d := NSDate.Date()
    20  	return d.Description()
    21  }
    22  
    23  func New() {
    24  	NSDate.New()
    25  	CAMediaTimingFunction.NewWithControlPoints(0, 0, 0, 0)
    26  }
    27  
    28  func Error() {
    29  	str, err := NSString.StringWithContentsOfFileEncodingError("<non-existent>", 0)
    30  	if err == nil {
    31  		panic("no error from stringWithContentsOfFile")
    32  	}
    33  	// Assert err is an error
    34  	err = err.(error)
    35  	if str != "" {
    36  		panic("non-empty string from stringWithContentsOfFile")
    37  	}
    38  	str, err = NSString.NewWithContentsOfFileEncodingError("<non-existent>", 0)
    39  	if err == nil {
    40  		panic("no error from stringWithContentsOfFile")
    41  	}
    42  	// Assert err is an error
    43  	err = err.(error)
    44  	if str != "" {
    45  		panic("non-empty string from initWithContentsOfFile")
    46  	}
    47  }