Skip to content

Commit a83269e

Browse files
Merge pull request #74361 from nate-chandler/gh69252
[Test] Add regression test.
2 parents 6694bba + b1c7999 commit a83269e

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// RUN: %target-swift-frontend \
2+
// RUN: -emit-sil -verify \
3+
// RUN: %s \
4+
// RUN: -sil-verify-all
5+
6+
////////////////////////////////////////////////////////////////////////////////
7+
// https://github.com/apple/swift/issues/69252 {{
8+
////////////////////////////////////////////////////////////////////////////////
9+
public enum LineEnding: String {
10+
/// The default unix `\n` character
11+
case lineFeed = "\n"
12+
/// MacOS line ending `\r` character
13+
case carriageReturn = "\r"
14+
/// Windows line ending sequence `\r\n`
15+
case carriageReturnLineFeed = "\r\n"
16+
17+
/// Initialize a line ending from a line string.
18+
/// - Parameter line: The line to use
19+
public init?(line: borrowing String) {
20+
guard let lastChar = line.last,
21+
let lineEnding = LineEnding(rawValue: String(lastChar)) else { return nil }
22+
self = lineEnding
23+
}
24+
25+
26+
static func makeLineEnding(_ line: borrowing String) -> LineEnding? {
27+
guard let lastChar = line.last,
28+
let lineEnding = LineEnding(rawValue: String(lastChar)) else { return nil }
29+
_ = lineEnding
30+
return nil
31+
}
32+
33+
func makeLineEnding(_ line: borrowing String) -> LineEnding? {
34+
guard let lastChar = line.last,
35+
let lineEnding = LineEnding(rawValue: String(lastChar)) else { return nil }
36+
_ = lineEnding
37+
return nil
38+
}
39+
}
40+
////////////////////////////////////////////////////////////////////////////////
41+
// https://github.com/apple/swift/issues/69252 }}
42+
////////////////////////////////////////////////////////////////////////////////

0 commit comments

Comments
 (0)