Skip to content

Commit e127030

Browse files
committed
Swift: Test some edge cases for locations.
1 parent 58c9bf4 commit e127030

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

swift/ql/test/library-tests/regex/parse.expected

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6254,3 +6254,22 @@ regex.swift:
62546254
# 157| [RegExpConstant, RegExpEscape] \n
62556255

62566256
# 158| [RegExpConstant, RegExpEscape] \n
6257+
6258+
# 168| [RegExpConstant, RegExpNormalChar] aa
6259+
6260+
# 168| [RegExpAlt] aa|bb
6261+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] aa
6262+
#-----| 1 -> [RegExpConstant, RegExpNormalChar] bb
6263+
6264+
# 168| [RegExpConstant, RegExpNormalChar] bb
6265+
6266+
# 172| [RegExpConstant, RegExpNormalChar]
6267+
# 172| bb
6268+
6269+
# 172| [RegExpConstant, RegExpNormalChar] aa
6270+
6271+
# 172| [RegExpAlt] aa|
6272+
# 172| bb
6273+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] aa
6274+
#-----| 1 -> [RegExpConstant, RegExpNormalChar]
6275+
#-----| bb

swift/ql/test/library-tests/regex/regex.swift

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ class NSRegularExpression : NSObject {
9898
//
9999
// the focus for these tests is different ways of evaluating regexps.
100100

101-
func myRegexpMethodsTests(b: Bool) throws {
101+
func myRegexpMethodsTests(b: Bool, str_unknown: String) throws {
102102
let input = "abcdef"
103103
let regex = try Regex(".*")
104104

@@ -156,4 +156,21 @@ func myRegexpMethodsTests(b: Bool) throws {
156156
_ = try Regex("\n").firstMatch(in: input) // $ regex=NEWLINE input=input
157157
_ = try Regex("\\n").firstMatch(in: input) // $ regex=\n input=input
158158
_ = try Regex(#"\n"#).firstMatch(in: input) // $ regex=\n input=input
159+
160+
// --- interpolated values ---
161+
162+
let str_constant = "aa"
163+
_ = try Regex("\(str_constant))|bb").firstMatch(in: input) // $ input=input MISSING: regex=aa|bb
164+
_ = try Regex("\(str_unknown))|bb").firstMatch(in: input) // $ input=input
165+
166+
// --- multi-line ---
167+
168+
_ = try Regex("""
169+
aa|bb
170+
""").firstMatch(in: input) // $ input=input regex=aa|bb
171+
172+
_ = try Regex("""
173+
aa|
174+
bb
175+
""").firstMatch(in: input) // $ input=input regex=aa|NEWLINEbb
159176
}

0 commit comments

Comments
 (0)