Skip to content

Commit 2b9d25b

Browse files
committed
Swift: Additional test cases.
1 parent fcc98f8 commit 2b9d25b

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6549,3 +6549,53 @@ regex.swift:
65496549

65506550
# 221| [RegExpStar] .*
65516551
#-----| 0 -> [RegExpDot] .
6552+
6553+
# 227| [RegExpGroup] (?i-s)
6554+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] i-s
6555+
6556+
# 227| [RegExpSequence] (?i-s)abc
6557+
#-----| 0 -> [RegExpGroup] (?i-s)
6558+
#-----| 1 -> [RegExpConstant, RegExpNormalChar] abc
6559+
6560+
# 227| [RegExpConstant, RegExpNormalChar] i-s
6561+
6562+
# 227| [RegExpConstant, RegExpNormalChar] abc
6563+
6564+
# 230| [RegExpConstant, RegExpNormalChar] abc
6565+
6566+
# 230| [RegExpSequence] abc(?i)def
6567+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] abc
6568+
#-----| 1 -> [RegExpGroup] (?i)
6569+
#-----| 2 -> [RegExpConstant, RegExpNormalChar] def
6570+
6571+
# 230| [RegExpGroup] (?i)
6572+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] i
6573+
6574+
# 230| [RegExpConstant, RegExpNormalChar] i
6575+
6576+
# 230| [RegExpConstant, RegExpNormalChar] def
6577+
6578+
# 231| [RegExpConstant, RegExpNormalChar] abc
6579+
6580+
# 231| [RegExpSequence] abc(?i:def)ghi
6581+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] abc
6582+
#-----| 1 -> [RegExpGroup] (?i:def)
6583+
#-----| 2 -> [RegExpConstant, RegExpNormalChar] ghi
6584+
6585+
# 231| [RegExpGroup] (?i:def)
6586+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] i:def
6587+
6588+
# 231| [RegExpConstant, RegExpNormalChar] i:def
6589+
6590+
# 231| [RegExpConstant, RegExpNormalChar] ghi
6591+
6592+
# 232| [RegExpGroup] (?i)
6593+
#-----| 0 -> [RegExpConstant, RegExpNormalChar] i
6594+
6595+
# 232| [RegExpConstant, RegExpNormalChar] i
6596+
6597+
# 232| [RegExpConstant, RegExpNormalChar] abc
6598+
6599+
# 232| [RegExpConstant, RegExpNormalChar] -i
6600+
6601+
# 232| [RegExpConstant, RegExpNormalChar] def

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,11 @@ func myRegexpMethodsTests(b: Bool, str_unknown: String) throws {
223223
_ = input.replacingOccurrences(of: ".*", with: "", options: [.regularExpression, .caseInsensitive]) // $ MISSING: regex=.* input=input modes=IGNORECASE
224224

225225
_ = NSString(string: "abc").replacingOccurrences(of: ".*", with: "", options: [.regularExpression, .caseInsensitive], range: NSMakeRange(0, inputNS.length)) // $ MISSING: regex=.* input=inputNS modes=IGNORECASE
226+
227+
_ = try Regex("(?i-s)abc").firstMatch(in: input) // $ input=input regex=(?i-s)abc MISSING: modes=IGNORECASE SPURIOUS: modes="DOTALL | IGNORECASE"
228+
229+
// these cases use parse modes on localized areas of the regex, which we don't currently support
230+
_ = try Regex("abc(?i)def").firstMatch(in: input) // $ input=input modes=IGNORECASE regex=abc(?i)def
231+
_ = try Regex("abc(?i:def)ghi").firstMatch(in: input) // $ input=input modes=IGNORECASE regex=abc(?i:def)ghi
232+
_ = try Regex("(?i)abc(?-i)def").firstMatch(in: input) // $ input=input modes=IGNORECASE regex=(?i)abc(?-i)def SPURIOUS: hasParseFailure=
226233
}

0 commit comments

Comments
 (0)