Skip to content

Commit 8b17e57

Browse files
committed
Cleanup: Lexicon, tests.
1 parent 30f4b5c commit 8b17e57

File tree

4 files changed

+29
-44
lines changed

4 files changed

+29
-44
lines changed

Sources/DiffableTextStylesXNumeric/Helpers/Lexicon.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,21 @@ extension Lexicon {
8181
signs: signs.components, digits: digits.components, separators: separators.components)
8282
}
8383
}
84+
85+
//=----------------------------------------------------------------------------=
86+
// MARK: + Support
87+
//=----------------------------------------------------------------------------=
88+
89+
extension Lexicon {
90+
91+
//=------------------------------------------------------------------------=
92+
// MARK: Predicates
93+
//=------------------------------------------------------------------------=
94+
95+
/// Used by unit tests.
96+
@inlinable func nonvirtual(_ character: Character) -> Bool {
97+
signs[character] != nil
98+
|| digits[character] != nil
99+
|| separators[character] == .fraction
100+
}
101+
}

Tests/DiffableTextStylesXNumericTests/Extensions.swift

Lines changed: 0 additions & 29 deletions
This file was deleted.

Tests/DiffableTextStylesXNumericTests/Miscellaneous/MiscellaneousTests+Currency.swift

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ import DiffableTestKit
1818
final class MiscellaneousTestsXCurrency: Tests {
1919

2020
//=------------------------------------------------------------------------=
21-
// MARK: Positive
21+
// MARK: Tests
2222
//=------------------------------------------------------------------------=
2323

24-
func testCurrencyLabelDoesNotContainNumbers() throws {
24+
func testCurrencyLabelsAreSometimesReal() throws {
25+
let number = -1234567.89
26+
let currencyCode = "PAB"
27+
let locale = Locale(identifier: "rhg-Rohg_MM")
28+
let formatted = number.formatted(.currency(code: currencyCode).locale(locale))
29+
XCTAssertEqual(formatted, "-B/. 1,234,567.89") // currency contains a fraction separator
30+
}
31+
32+
func testCurrencyLabelsDoNotContainNumbers() throws {
2533
//=--------------------------------------=
2634
// MARK: Locales, Currencies
2735
//=--------------------------------------=
@@ -32,18 +40,6 @@ final class MiscellaneousTestsXCurrency: Tests {
3240
}
3341
}
3442
}
35-
36-
//=------------------------------------------------------------------------=
37-
// MARK: Negative
38-
//=------------------------------------------------------------------------=
39-
40-
func testCurrencyLabelIsSometimesReal() throws {
41-
let number = -1234567.89
42-
let currencyCode = "PAB"
43-
let locale = Locale(identifier: "rhg-Rohg_MM")
44-
let formatted = number.formatted(.currency(code: currencyCode).locale(locale))
45-
XCTAssertEqual(formatted, "-B/. 1,234,567.89") // currency contains a fraction separator
46-
}
4743
}
4844

4945
#endif

Tests/DiffableTextStylesXNumericTests/Miscellaneous/MiscellaneousTests+Percent.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import Foundation
2121
final class MiscellaneousTestsXPercent: Tests {
2222

2323
//=------------------------------------------------------------------------=
24-
// MARK: Positive
24+
// MARK: Tests
2525
//=------------------------------------------------------------------------=
2626

2727
func testPercentLabelIsAlwaysVirtual() throws {

0 commit comments

Comments
 (0)