Skip to content

Commit 0ec01dc

Browse files
committed
[Tests] Add static keypaths tests.
1 parent b3c37a3 commit 0ec01dc

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// RUN: %empty-directory(%t/src)
2+
// RUN: split-file %s %t/src
3+
4+
/// Build LibA
5+
// RUN: %host-build-swift %t/src/LibA.swift -swift-version 5 -emit-module -emit-library -enable-library-evolution -module-name LibA -o %t/%target-library-name(LibA) -emit-module-interface-path %t/LibA.swiftinterface
6+
7+
// Build LibB
8+
// RUN: %target-build-swift %t/src/LibB.swift -I %t -L %t -l LibA -swift-version 5 -emit-module -emit-library -module-name LibB -o %t/%target-library-name(LibB)
9+
10+
// Build LibC
11+
// RUN: %target-build-swift %t/src/LibC.swift -I %t -L %t -l LibA -swift-version 5 -emit-module -emit-library -module-name LibC -o %t/%target-library-name(LibC)
12+
13+
// Build & run main.swift
14+
// RUN: %target-build-swift -I %t -L %t -l LibA -l LibB -l LibC %t/src/main.swift -o %t/a.out
15+
// RUN: %target-codesign %t/%target-library-name(LibA)
16+
// RUN: %target-codesign %t/%target-library-name(LibB)
17+
// RUN: %target-codesign %t/%target-library-name(LibC)
18+
// RUN: %target-codesign %t/a.out
19+
// RUN: %target-run %t/a.out | %FileCheck %s
20+
21+
// REQUIRES: executable_test
22+
23+
//--- LibA.swift
24+
public struct AStruct {
25+
public static var property1: Int = 1
26+
public static var property2: Int = 2
27+
private(set) public static var property3: Int = 3
28+
private(set) public static var property4: Int = 4
29+
}
30+
31+
//--- LibB.swift
32+
import LibA
33+
34+
public let keyPath1FromLibB = \AStruct.Type.property1
35+
public let keyPath2FromLibB = \AStruct.Type.property2
36+
public let keyPath3FromLibB = \AStruct.Type.property3
37+
public let keyPath4FromLibB = \AStruct.Type.property4
38+
39+
//--- LibC.swift
40+
import LibA
41+
42+
public let keyPath1FromLibC = \AStruct.Type.property1
43+
public let keyPath2FromLibC = \AStruct.Type.property2
44+
public let keyPath3FromLibC = \AStruct.Type.property3
45+
public let keyPath4FromLibC = \AStruct.Type.property4
46+
47+
//--- main.swift
48+
import LibB
49+
import LibC
50+
51+
// CHECK: true
52+
print(keyPath1FromLibB == keyPath1FromLibC)
53+
// CHECK: true
54+
print(keyPath1FromLibB != keyPath2FromLibC)
55+
56+
// CHECK: true
57+
print(keyPath3FromLibB == keyPath3FromLibC)
58+
// CHECK: true
59+
print(keyPath3FromLibB != keyPath4FromLibC)

0 commit comments

Comments
 (0)