Skip to content

Commit a181f8e

Browse files
authored
Merge pull request #447 from ahoppen/pr/regex-parsing-tests
Add test cases for regex literal parsing
2 parents 6fa8f5e + 907bfcf commit a181f8e

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed

lit_tests/print_regex.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %lit-test-helper -print-tree -source-file %s | %FileCheck %s --check-prefix REGEX
3+
4+
_ = /abc/
5+
// REGEX: _ </TokenSyntax></DiscardAssignmentExprSyntax><AssignmentExprSyntax><TokenSyntax>= </TokenSyntax></AssignmentExprSyntax><RegexLiteralExprSyntax><TokenSyntax>/abc/</TokenSyntax></RegexLiteralExprSyntax></ExprListSyntax></SequenceExprSyntax></CodeBlockItemSyntax></CodeBlockItemListSyntax><TokenSyntax>
6+
// REGEX: </TokenSyntax></SourceFileSyntax>

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)