File: DiscoverableAsTestContent.swift

package info (click to toggle)
swiftlang 6.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,856,264 kB
  • sloc: cpp: 9,995,718; ansic: 2,234,019; asm: 1,092,167; python: 313,940; objc: 82,726; f90: 80,126; lisp: 38,373; pascal: 25,580; sh: 20,378; ml: 5,058; perl: 4,751; makefile: 4,725; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (57 lines) | stat: -rw-r--r-- 2,483 bytes parent folder | download
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
55
56
57
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2023–2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
//

/// A protocol describing a type that can be represented by a test content
/// record, stored in the test content section of a Swift binary at compile
/// time, and dynamically discovered at runtime.
///
/// Types conforming to this protocol must also conform to [`Sendable`](https://developer.apple.com/documentation/swift/sendable)
/// because they may be discovered within any isolation context or within
/// multiple isolation contexts running concurrently.
@_spi(Experimental) @_spi(ForToolsIntegrationOnly)
public protocol DiscoverableAsTestContent: Sendable {
  /// The value of the `kind` field in test content records associated with this
  /// type.
  ///
  /// The value of this property is reserved for each test content type. See
  /// `ABI/TestContent.md` for a list of values and corresponding types.
  static var testContentKind: TestContentKind { get }

  /// The type of the `context` field in test content records associated with
  /// this type.
  ///
  /// By default, this type equals `UInt`. This type can be set to some other
  /// type with the same stride and alignment as `UInt`. Using a type with
  /// different stride or alignment will result in a failure when trying to
  /// discover test content records associated with this type.
  associatedtype TestContentContext: BitwiseCopyable = UInt

  /// A type of "hint" passed to ``allTestContentRecords()`` to help the testing
  /// library find the correct result.
  ///
  /// By default, this type equals `Never`, indicating that this type of test
  /// content does not support hinting during discovery.
  associatedtype TestContentAccessorHint = Never

#if !SWT_NO_LEGACY_TEST_DISCOVERY
  /// A string present in the names of types containing test content records
  /// associated with this type.
  @available(swift, deprecated: 100000.0, message: "Do not adopt this functionality in new code. It will be removed in a future release.")
  static var _testContentTypeNameHint: String { get }
#endif
}

#if !SWT_NO_LEGACY_TEST_DISCOVERY
extension DiscoverableAsTestContent {
  public static var _testContentTypeNameHint: String {
    "__🟡$"
  }
}
#endif