File: objc_enum_multi_file.swift

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (54 lines) | stat: -rw-r--r-- 2,809 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// RUN: not %target-swift-frontend -disable-objc-attr-requires-foundation-module -enable-objc-interop -module-name main %s -primary-file %S/Inputs/objc_enum_multi_file_helper.swift -emit-ir -D NO_RAW_TYPE 2>&1 | %FileCheck -check-prefix=NO_RAW_TYPE %s
// RUN: not %target-swift-frontend -disable-objc-attr-requires-foundation-module -enable-objc-interop -module-name main %s -primary-file %S/Inputs/objc_enum_multi_file_helper.swift -emit-ir -D BAD_RAW_TYPE 2>&1 | %FileCheck -check-prefix=BAD_RAW_TYPE %s
// RUN: not %target-swift-frontend -disable-objc-attr-requires-foundation-module -enable-objc-interop -module-name main %s -primary-file %S/Inputs/objc_enum_multi_file_helper.swift -emit-ir -D NON_INT_RAW_TYPE 2>&1 | %FileCheck -check-prefix=NON_INT_RAW_TYPE %s
// RUN: not %target-swift-frontend -disable-objc-attr-requires-foundation-module -enable-objc-interop -module-name main %s -primary-file %S/Inputs/objc_enum_multi_file_helper.swift -emit-ir -D NON_INT_RAW_VALUE 2>&1 | %FileCheck -check-prefix=NON_INT_RAW_VALUE %s
// RUN: not %target-swift-frontend -disable-objc-attr-requires-foundation-module -enable-objc-interop -module-name main %s -primary-file %S/Inputs/objc_enum_multi_file_helper.swift -emit-ir -D NO_CASES 2>&1 | %FileCheck -check-prefix=NO_CASES %s
// RUN: not %target-swift-frontend -disable-objc-attr-requires-foundation-module -enable-objc-interop -module-name main %s -primary-file %S/Inputs/objc_enum_multi_file_helper.swift -emit-ir -D DUPLICATE_CASES 2>&1 | %FileCheck -check-prefix=DUPLICATE_CASES %s
// Note that the *other* file is the primary file in this test!

#if NO_RAW_TYPE
// NO_RAW_TYPE: :[[@LINE+1]]:12: error: '@objc' enum must declare an integer raw type
@objc enum TheEnum {
  case A
}

#elseif BAD_RAW_TYPE
// BAD_RAW_TYPE: :[[@LINE+1]]:12: error: '@objc' enum raw type 'Array<Int>' is not an integer type
@objc enum TheEnum : Array<Int> {
  case A
}

#elseif NON_INT_RAW_TYPE
// NON_INT_RAW_TYPE: :[[@LINE+1]]:12: error: '@objc' enum raw type 'Float' is not an integer type
@objc enum TheEnum : Float {
  case A = 0.0
}

#elseif NO_CASES
// NO_CASES: :[[@LINE+1]]:12: error: an enum with no cases cannot declare a raw type
@objc enum TheEnum : Int32 {
  static var A: TheEnum! { return nil }
}

#elseif DUPLICATE_CASES
@objc enum TheEnum : Int32 {
  case A
  case B = 0
  // DUPLICATE_CASES: :[[@LINE-1]]:12: error: raw value for enum case is not unique
  // DUPLICATE_CASES: note: raw value previously used here
  // DUPLICATE_CASES: note: raw value implicitly auto-incremented from zero
}

#elseif NON_INT_RAW_VALUE
@objc enum TheEnum : Int32 {
  case A = 0
  case B = "B"
  // NON_INT_RAW_VALUE: :[[@LINE-1]]:12: error: cannot convert value of type 'String' to raw type 'Int32'
}

#else
enum TheEnum: Invalid { // should never be hit
  case A
}

#endif