Skip to content

Commit 510ddc9

Browse files
committed
Add test cases for regex literal parsing
This adds test cases to verify that regex literals can be correctly parsed.
1 parent 6fa8f5e commit 510ddc9

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

lit_tests/round_trip_regex.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %lit-test-helper -roundtrip -source-file %s -out %t/afterRoundtrip.swift
3+
// RUN: diff -u %t/afterRoundtrip.swift %s
4+
5+
6+
_ = /abc/
7+
_ = #/abc/#
8+
_ = ##/abc/##
9+
10+
func foo<T>(_ x: T...) {}
11+
foo(/abc/, #/abc/#, ##/abc/##)
12+
13+
let arr = [/abc/, #/abc/#, ##/abc/##]
14+
15+
_ = /\w+/.self
16+
_ = #/\w+/#.self
17+
_ = ##/\w+/##.self
18+
19+
_ = /#\/\#\\/
20+
_ = #/#/\/\#\\/#
21+
_ = ##/#|\|\#\\/##
22+
23+
_ = #/
24+
multiline
25+
/#
26+
27+
_ = #/
28+
double
29+
multiline
30+
/#
31+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %lit-test-helper -roundtrip -source-file %s -out %t/afterRoundtrip.swift
3+
// RUN: diff -u %t/afterRoundtrip.swift %s
4+
5+
_ = /abc
6+
_ = #/abc
7+
_ = #/abc/
8+
_ = ##/abc/#
9+
10+
_ #/x
11+
/#
12+
_ #/
13+
x/#
14+
15+
_ //#
16+
_ /x/#
17+
18+
_ = ""

0 commit comments

Comments
 (0)