Skip to content

Commit d7b306b

Browse files
committed
[embedded] Add tests that verify dead-stripping of Unicode data tables works
1 parent 7d92baa commit d7b306b

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// RUN: %target-swift-frontend -Osize -parse-as-library -enable-experimental-feature Embedded %s -c -o %t/a.o
2+
// RUN: %target-clang %t/a.o -o %t/a.out -dead_strip %swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos/libswiftUnicodeDataTables.a
3+
// RUN: %llvm-nm --defined-only --format=just-symbols --demangle %t/a.out | grep swift_stdlib_ | sort | %FileCheck %s --check-prefix=INCLUDES
4+
// RUN: %llvm-nm --defined-only --format=just-symbols --demangle %t/a.out | grep swift_stdlib_ | sort | %FileCheck %s --check-prefix=EXCLUDES
5+
6+
// REQUIRES: swift_in_compiler
7+
// REQUIRES: optimized_stdlib
8+
// REQUIRES: OS=macosx || OS=linux-gnu
9+
10+
@main
11+
struct Main {
12+
static func main() {
13+
var dict: [String:String] = [:]
14+
let c = "Cafe\u{301}"
15+
let d = "Cafe\u{301}"
16+
let e = "Café"
17+
let f = "Caf\u{65}\u{301}"
18+
let g = "Caf\u{e9}"
19+
dict[c] = "x"
20+
dict[d] = "x"
21+
dict[e] = "x"
22+
dict[f] = "x"
23+
dict[g] = "x"
24+
print(dict.count)
25+
print(dict[f]!)
26+
}
27+
}
28+
29+
// The code uses String equality and hashing, should need the normalization, NFC, NFD tables, and not the others.
30+
// EXCLUDES-NOT: swift_stdlib_case
31+
// EXCLUDES-NOT: swift_stdlib_graphemeBreakProperties
32+
// EXCLUDES-NOT: swift_stdlib_linkingConsonant
33+
// EXCLUDES-NOT: swift_stdlib_mappings
34+
// EXCLUDES-NOT: swift_stdlib_names
35+
// INCLUDES: swift_stdlib_nfc
36+
// INCLUDES: swift_stdlib_nfd
37+
// INCLUDES: swift_stdlib_normData
38+
// EXCLUDES-NOT: swift_stdlib_scripts
39+
// EXCLUDES-NOT: swift_stdlib_special_mappings
40+
// EXCLUDES-NOT: swift_stdlib_words
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-swift-frontend -Osize -parse-as-library -enable-experimental-feature Embedded %s -c -o %t/a.o
2+
// RUN: %target-clang %t/a.o -o %t/a.out -dead_strip %swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos/libswiftUnicodeDataTables.a
3+
// RUN: %llvm-nm --defined-only --format=just-symbols --demangle %t/a.out | grep swift_stdlib_ | sort | %FileCheck %s --check-prefix=INCLUDES
4+
// RUN: %llvm-nm --defined-only --format=just-symbols --demangle %t/a.out | grep swift_stdlib_ | sort | %FileCheck %s --check-prefix=EXCLUDES
5+
6+
// REQUIRES: swift_in_compiler
7+
// REQUIRES: optimized_stdlib
8+
// REQUIRES: OS=macosx || OS=linux-gnu
9+
10+
@main
11+
struct Main {
12+
static func main() {
13+
let e = "Café"
14+
print(e.uppercased())
15+
}
16+
}
17+
18+
// The code uses String case conversion, should need the mapping tables, and not the others.
19+
// EXCLUDES-NOT: swift_stdlib_case
20+
// EXCLUDES-NOT: swift_stdlib_graphemeBreakProperties
21+
// EXCLUDES-NOT: swift_stdlib_linkingConsonant
22+
// INCLUDES: swift_stdlib_mappings
23+
// EXCLUDES-NOT: swift_stdlib_names
24+
// EXCLUDES-NOT: swift_stdlib_nfc
25+
// EXCLUDES-NOT: swift_stdlib_nfd
26+
// EXCLUDES-NOT: swift_stdlib_normData
27+
// EXCLUDES-NOT: swift_stdlib_scripts
28+
// INCLUDES: swift_stdlib_special_mappings
29+
// EXCLUDES-NOT: swift_stdlib_words
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %target-swift-frontend -Osize -parse-as-library -enable-experimental-feature Embedded %s -c -o %t/a.o
2+
// RUN: %target-clang %t/a.o -o %t/a.out -dead_strip %swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos/libswiftUnicodeDataTables.a
3+
// RUN: %llvm-nm --defined-only --format=just-symbols --demangle %t/a.out | grep swift_stdlib_ | sort | %FileCheck %s --check-prefix=INCLUDES
4+
// RUN: %llvm-nm --defined-only --format=just-symbols --demangle %t/a.out | grep swift_stdlib_ | sort | %FileCheck %s --check-prefix=EXCLUDES
5+
6+
// REQUIRES: swift_in_compiler
7+
// REQUIRES: optimized_stdlib
8+
// REQUIRES: OS=macosx || OS=linux-gnu
9+
10+
@main
11+
struct Main {
12+
static func main() {
13+
let e = "Café\nMacs"
14+
for i in e.split(separator: "\n") {
15+
print(i)
16+
}
17+
}
18+
}
19+
20+
// The code uses String splitting, should need the normalization, NFC, NFD, grapheme breaking, linking tables, and not the others.
21+
// EXCLUDES-NOT: swift_stdlib_case
22+
// INCLUDES: swift_stdlib_graphemeBreakProperties
23+
// INCLUDES: swift_stdlib_linkingConsonant
24+
// EXCLUDES-NOT: swift_stdlib_mappings
25+
// EXCLUDES-NOT: swift_stdlib_names
26+
// INCLUDES: swift_stdlib_nfc
27+
// INCLUDES: swift_stdlib_nfd
28+
// INCLUDES: swift_stdlib_normData
29+
// EXCLUDES-NOT: swift_stdlib_scripts
30+
// EXCLUDES-NOT: swift_stdlib_special_mappings
31+
// EXCLUDES-NOT: swift_stdlib_words

0 commit comments

Comments
 (0)