Swift: Test some edge cases for locations.

This commit is contained in:
Geoffrey White
2023-06-20 16:23:21 +01:00
parent 58c9bf4b12
commit e127030b5c
2 changed files with 37 additions and 1 deletions

View File

@@ -6254,3 +6254,22 @@ regex.swift:
# 157| [RegExpConstant, RegExpEscape] \n
# 158| [RegExpConstant, RegExpEscape] \n
# 168| [RegExpConstant, RegExpNormalChar] aa
# 168| [RegExpAlt] aa|bb
#-----| 0 -> [RegExpConstant, RegExpNormalChar] aa
#-----| 1 -> [RegExpConstant, RegExpNormalChar] bb
# 168| [RegExpConstant, RegExpNormalChar] bb
# 172| [RegExpConstant, RegExpNormalChar]
# 172| bb
# 172| [RegExpConstant, RegExpNormalChar] aa
# 172| [RegExpAlt] aa|
# 172| bb
#-----| 0 -> [RegExpConstant, RegExpNormalChar] aa
#-----| 1 -> [RegExpConstant, RegExpNormalChar]
#-----| bb

View File

@@ -98,7 +98,7 @@ class NSRegularExpression : NSObject {
//
// the focus for these tests is different ways of evaluating regexps.
func myRegexpMethodsTests(b: Bool) throws {
func myRegexpMethodsTests(b: Bool, str_unknown: String) throws {
let input = "abcdef"
let regex = try Regex(".*")
@@ -156,4 +156,21 @@ func myRegexpMethodsTests(b: Bool) throws {
_ = try Regex("\n").firstMatch(in: input) // $ regex=NEWLINE input=input
_ = try Regex("\\n").firstMatch(in: input) // $ regex=\n input=input
_ = try Regex(#"\n"#).firstMatch(in: input) // $ regex=\n input=input
// --- interpolated values ---
let str_constant = "aa"
_ = try Regex("\(str_constant))|bb").firstMatch(in: input) // $ input=input MISSING: regex=aa|bb
_ = try Regex("\(str_unknown))|bb").firstMatch(in: input) // $ input=input
// --- multi-line ---
_ = try Regex("""
aa|bb
""").firstMatch(in: input) // $ input=input regex=aa|bb
_ = try Regex("""
aa|
bb
""").firstMatch(in: input) // $ input=input regex=aa|NEWLINEbb
}