Skip to content

Commit

Permalink
Merge pull request #2704 from daltonclaybrook/dc-number-separator-mor…
Browse files Browse the repository at this point in the history
…e-examples

Add triggering examples with parentheses to the number separator rule tests
  • Loading branch information
marcelofabri authored Apr 2, 2019
2 parents 442a59d + 696cdf8 commit 800ca0e
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 1 deletion.
36 changes: 36 additions & 0 deletions Rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -14010,6 +14010,42 @@ let foo = ↓1_000_000.000000_1
let foo = ↓1000000.000000_1
```

```swift
let foo: Double = ↓-(100000)
```

```swift
let foo: Double = ↓-(10.000000_1)
```

```swift
let foo: Double = ↓-(123456 / ↓447.214214)
```

```swift
let foo: Double = +(↓100000)
```

```swift
let foo: Double = +(↓10.000000_1)
```

```swift
let foo: Double = +(↓123456 / ↓447.214214)
```

```swift
let foo: Double = (↓100000)
```

```swift
let foo: Double = (↓10.000000_1)
```

```swift
let foo: Double = (↓123456 / ↓447.214214)
```

</details>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ internal struct NumberSeparatorRuleExamples {
}
}()

static let triggeringExamples = makeTriggeringExamples(signs: ["↓-", "+↓", ""])
static let triggeringExamples = makeTriggeringExamples(signs: ["↓-", "+↓", ""]) +
makeTriggeringExamplesWithParentheses()

static let corrections = makeCorrections(signs: [("↓-", "-"), ("+↓", "+"), ("", "")])

Expand All @@ -39,6 +40,17 @@ internal struct NumberSeparatorRuleExamples {
}
}

private static func makeTriggeringExamplesWithParentheses() -> [String] {
let signsWithParenthesisAndViolation = ["↓-(", "+(↓", "(↓"]
return signsWithParenthesisAndViolation.flatMap { (sign: String) -> [String] in
[
"let foo: Double = \(sign)100000)",
"let foo: Double = \(sign)10.000000_1)",
"let foo: Double = \(sign)123456 / ↓447.214214)"
]
}
}

private static func makeCorrections(signs: [(String, String)]) -> [String: String] {
var result = [String: String]()

Expand Down

0 comments on commit 800ca0e

Please sign in to comment.