-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Remove swift-corelibs-foundation duplicate implementations of Decimal and JSONEncoder/JSONDecoder #5017
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -237,72 +237,36 @@ class TestJSONEncoder : XCTestCase { | |||
|
|||
func test_encodingOutputFormattingSortedKeys() throws { | |||
let expectedJSON = try XCTUnwrap(""" | |||
{"2":"2","7":"7","25":"25","alice":"alice","bob":"bob","Charlie":"Charlie","中国":"中国","日本":"日本","韓国":"韓国"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The sorting order changed in recent JSONEncoder implementations to be UTF8 byte based instead of a localized sort.
@@ -1286,8 +1286,8 @@ extension TestJSONSerialization { | |||
} | |||
|
|||
func test_serialize_Decimal() { | |||
XCTAssertEqual(try trySerialize([-Decimal.leastNonzeroMagnitude]), "[-0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001]") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now we have reverted to Darwin's Decimal behavior for the size of the mantissa, since it differed between platforms. We will revisit that after the Swift 6.0 release.
9839bda
to
0454f9f
Compare
@@ -835,9 +800,9 @@ class TestJSONEncoder : XCTestCase { | |||
try decode(type, value) | |||
XCTFail("Decode of \(value) to \(type) should not succeed") | |||
} catch DecodingError.dataCorrupted(let context) { | |||
XCTAssertEqual(context.debugDescription, errorMessage) | |||
// Pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really valuable to check the exact message here. Just needs to throw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XCTAssertThrowsError
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Much better, thanks.
swiftlang/swift-foundation#751 @swift-ci please test |
@@ -835,9 +800,9 @@ class TestJSONEncoder : XCTestCase { | |||
try decode(type, value) | |||
XCTFail("Decode of \(value) to \(type) should not succeed") | |||
} catch DecodingError.dataCorrupted(let context) { | |||
XCTAssertEqual(context.debugDescription, errorMessage) | |||
// Pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XCTAssertThrowsError
?
… and JSONEncoder/JSONDecoder
0454f9f
to
acf9154
Compare
@swift-ci test |
swiftlang/swift-foundation#751 @swift-ci please test |
@swift-ci please test windows |
Also adjusts the Decimal tests so that we only test
NSDecimalNumber
here and rely on swift-foundation forDecimal
.Relies on swiftlang/swift-foundation#751