forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request swiftlang#73585 from kubamracek/embedded-string-un…
…icode-tables [embedded] Provide Unicode data tables for embedded as a static library
- Loading branch information
Showing
11 changed files
with
234 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,28 @@ | ||
// Test String operations that require unicode data tables. This is not an executable test yet, because the data tables | ||
// are not available for linking yet. | ||
|
||
// RUN: %target-swift-frontend -emit-ir %s -enable-experimental-feature Embedded | ||
// RUN: %target-run-simple-swift( -enable-experimental-feature Embedded -runtime-compatibility-version none -wmo -Xlinker %swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos/libswiftUnicodeDataTables.a) | %FileCheck %s | ||
// RUN: %target-run-simple-swift(-Osize -Xlinker -dead_strip -enable-experimental-feature Embedded -runtime-compatibility-version none -wmo -Xlinker %swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos/libswiftUnicodeDataTables.a) | %FileCheck %s | ||
|
||
// REQUIRES: swift_in_compiler | ||
// REQUIRES: executable_test | ||
// REQUIRES: optimized_stdlib | ||
// REQUIRES: OS=macosx || OS=linux-gnu | ||
// REQUIRES: OS=macosx | ||
|
||
public func test1() { | ||
let string = "string" | ||
let other = "other" | ||
let appended = string + other | ||
_ = appended | ||
print(appended) // CHECK: stringother | ||
|
||
let _ = "aa" == "bb" | ||
let dict: [String:Int] = [:] | ||
_ = dict | ||
var dict: [String:Int] = [:] | ||
dict["aa"] = 42 | ||
print(dict["aa"]!) // CHECK: 42 | ||
|
||
let _ = "aaa".uppercased() | ||
let u = "aaa".uppercased() | ||
print(u) // CHECK: AAA | ||
|
||
let space: Character = " " | ||
let split = appended.split(separator: space) | ||
_ = split | ||
print(split[0]) // CHECK: stringother | ||
} | ||
|
||
test1() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// RUN: %target-run-simple-swift( -enable-experimental-feature Embedded -parse-as-library -runtime-compatibility-version none -wmo -Xlinker %swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos/libswiftUnicodeDataTables.a) | %FileCheck %s | ||
// RUN: %target-run-simple-swift(-Osize -Xlinker -dead_strip -enable-experimental-feature Embedded -parse-as-library -runtime-compatibility-version none -wmo -Xlinker %swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos/libswiftUnicodeDataTables.a) | %FileCheck %s | ||
|
||
// REQUIRES: swift_in_compiler | ||
// REQUIRES: executable_test | ||
// REQUIRES: optimized_stdlib | ||
// REQUIRES: OS=macosx | ||
|
||
@main | ||
struct Main { | ||
static func main() { | ||
let str = "Hello😊" | ||
print(str) // CHECK: Hello😊 | ||
print(str.dropLast()) // CHECK: Hello | ||
print(str.dropLast().count) // CHECK: 5 | ||
|
||
var dict: [String:String] = [:] | ||
let c = "Cafe\u{301}" | ||
let d = "Cafe\u{301}" | ||
let e = "Café" | ||
let f = "Caf\u{65}\u{301}" | ||
let g = "Caf\u{e9}" | ||
dict[c] = str | ||
dict[d] = str | ||
dict[e] = str | ||
dict[f] = str | ||
dict[g] = str | ||
print(dict.count) // CHECK: 1 | ||
print(dict[f]!) // CHECK: Hello😊 | ||
|
||
var emoji = "" | ||
// VAMPIRE, ZERO-WIDTH JOINER, FEMALE SIGN, VARIATION SELECTOR-16 | ||
emoji += "\u{1f9db}" | ||
emoji += "\u{200d}" | ||
emoji += "\u{2640}" | ||
emoji += "\u{fe0f}" | ||
print(emoji.count) // CHECK: 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// RUN: %target-swift-frontend -Osize -parse-as-library -enable-experimental-feature Embedded %s -c -o %t/a.o | ||
// RUN: %target-clang %t/a.o -o %t/a.out -dead_strip %swift_obj_root/lib/swift/embedded/%target-cpu-apple-macos/libswiftUnicodeDataTables.a | ||
// RUN: %llvm-nm --defined-only --format=just-symbols --demangle %t/a.out | grep swift_stdlib_ | sort | %FileCheck %s --check-prefix=INCLUDES | ||
// RUN: %llvm-nm --defined-only --format=just-symbols --demangle %t/a.out | grep swift_stdlib_ | sort | %FileCheck %s --check-prefix=EXCLUDES | ||
|
||
// REQUIRES: swift_in_compiler | ||
// REQUIRES: optimized_stdlib | ||
// REQUIRES: OS=macosx | ||
|
||
@main | ||
struct Main { | ||
static func main() { | ||
var dict: [String:String] = [:] | ||
let c = "Cafe\u{301}" | ||
let d = "Cafe\u{301}" | ||
let e = "Café" | ||
let f = "Caf\u{65}\u{301}" | ||
let g = "Caf\u{e9}" | ||
dict[c] = "x" | ||
dict[d] = "x" | ||
dict[e] = "x" | ||
dict[f] = "x" | ||
dict[g] = "x" | ||
print(dict.count) | ||
print(dict[f]!) | ||
} | ||
} | ||
|
||
// The code uses String equality and hashing, should need the normalization, NFC, NFD tables, and not the others. | ||
// EXCLUDES-NOT: swift_stdlib_case | ||
// EXCLUDES-NOT: swift_stdlib_graphemeBreakProperties | ||
// EXCLUDES-NOT: swift_stdlib_linkingConsonant | ||
// EXCLUDES-NOT: swift_stdlib_mappings | ||
// EXCLUDES-NOT: swift_stdlib_names | ||
// INCLUDES: swift_stdlib_nfc | ||
// INCLUDES: swift_stdlib_nfd | ||
// INCLUDES: swift_stdlib_normData | ||
// EXCLUDES-NOT: swift_stdlib_scripts | ||
// EXCLUDES-NOT: swift_stdlib_special_mappings | ||
// EXCLUDES-NOT: swift_stdlib_words |
Oops, something went wrong.