Skip to content

Commit f978f94

Browse files
authored
Clean up for #1074 (#1128)
- Remove an unused variable. - Calling `JSONDecoder`'s `func decode<T: Decodable>(_ type: T.Type, from data: Data) throws -> T` with `Decimal.FormatStyle.Currency` as the type isn't correct. But for some reason, the compiler allows it incorrectly. Fix it. - Clean up whitespaces while we're here.
1 parent b9852c2 commit f978f94

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Tests/FoundationInternationalizationTests/Formatting/NumberFormatStyleTests.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ final class NumberFormatStyleTests: XCTestCase {
438438
XCTAssertEqual((-3.14159 as Decimal).formatted(.currency(code:"USD")), currencyStyle.format(-3.14159))
439439
XCTAssertEqual((-3000.14159 as Decimal).formatted(.currency(code:"USD")), currencyStyle.format(-3000.14159))
440440
}
441-
441+
442442
#if FOUNDATION_FRAMEWORK
443443
func test_autoupdatingCurrentChangesFormatResults() {
444444
let locale = Locale.autoupdatingCurrent
@@ -450,7 +450,7 @@ final class NumberFormatStyleTests: XCTestCase {
450450
let currency = Decimal(123.45)
451451
let percent = 54.32
452452
let bytes = 1_234_567_890
453-
453+
454454
// Get a formatted result from es-ES
455455
var prefs = LocalePreferences()
456456
prefs.languages = ["es-ES"]
@@ -463,7 +463,7 @@ final class NumberFormatStyleTests: XCTestCase {
463463
let formattedSpanishCurrency = currency.formatted(.currency(code: "USD").locale(locale))
464464
let formattedSpanishPercent = percent.formatted(.percent.locale(locale))
465465
let formattedSpanishBytes = bytes.formatted(.byteCount(style: .decimal).locale(locale))
466-
466+
467467
// Get a formatted result from en-US
468468
prefs.languages = ["en-US"]
469469
prefs.locale = "en_US"
@@ -475,7 +475,7 @@ final class NumberFormatStyleTests: XCTestCase {
475475
let formattedEnglishCurrency = currency.formatted(.currency(code: "USD").locale(locale))
476476
let formattedEnglishPercent = percent.formatted(.percent.locale(locale))
477477
let formattedEnglishBytes = bytes.formatted(.byteCount(style: .decimal).locale(locale))
478-
478+
479479
// Reset to current preferences before any possibility of failing this test
480480
LocaleCache.cache.reset()
481481

@@ -598,7 +598,7 @@ final class NumberFormatStyleTests: XCTestCase {
598598
func testCurrency_Codable() throws {
599599
let gbpInUS = Decimal.FormatStyle.Currency(code: "GBP", locale: enUSLocale)
600600
let encoded = try JSONEncoder().encode(gbpInUS)
601-
let json_gbp = String(data: encoded, encoding: String.Encoding.utf8)!
601+
// Valid JSON presentation of the format style
602602
let previouslyEncoded = """
603603
{
604604
"collection":
@@ -615,14 +615,14 @@ final class NumberFormatStyleTests: XCTestCase {
615615
"identifier": "en_US"
616616
}
617617
}
618-
""".data(using: .utf8)
618+
""".data(using: .utf8)
619619

620620
guard let previouslyEncoded else {
621621
XCTFail()
622622
return
623623
}
624624

625-
let decoded = try JSONDecoder().decode(Decimal.FormatStyle.Currency, from: previouslyEncoded)
625+
let decoded = try JSONDecoder().decode(Decimal.FormatStyle.Currency.self, from: previouslyEncoded)
626626
XCTAssertEqual(decoded, gbpInUS)
627627
}
628628

0 commit comments

Comments
 (0)