Closed aymanbagabas closed 3 years ago
How about if the value is Codable but not Hashable? These hash value must not equal to others and themselves.
Looking forward to see this PR merged. If I can somehow help, please let me know 🙂
How about if the value is Codable but not Hashable? These hash value must not equal to others and themselves.
This is not possible. If the value is Codable, then it's Hashable. AnyDecodable and AnyEncodable throw when the value is not Codable, meaning it won't reach the default
case when encoding or decoding a value.
https://github.com/Flight-School/AnyCodable/blob/master/Sources/AnyCodable/AnyDecodable.swift#L74-L76 https://github.com/Flight-School/AnyCodable/blob/master/Sources/AnyCodable/AnyEncodable.swift#L101-L104
This is not possible. If the value is Codable, then it's Hashable. AnyDecodable and AnyEncodable throw when the value is not Codable, meaning it won't reach the
default
case when encoding or decoding a value.
You are right. AnyEncodable, AnyDecodable and AnyCodable are implicitly require that values conform to Hashable currently. I am approving it. Let us see test results.
Sorry to bother, but did the CI started? I'm asking because I see the message:
1 workflow awaiting approval
First-time contributors need a maintainer to approve running workflows. Learn more.
I got 500. I think that @mattt can approve and run.
See below.
I ran tests per versions on my machine and every case passed. Merging.
Test Suite 'All tests' started at 2021-05-29 19:29:52.988
Test Suite 'debug.xctest' started at 2021-05-29 19:29:53.035
Test Suite 'AnyCodableTests' started at 2021-05-29 19:29:53.035
Test Case 'AnyCodableTests.testJSONDecoding' started at 2021-05-29 19:29:53.036
Test Case 'AnyCodableTests.testJSONDecoding' passed (0.025 seconds)
Test Case 'AnyCodableTests.testJSONEncoding' started at 2021-05-29 19:29:53.062
Test Case 'AnyCodableTests.testJSONEncoding' passed (0.012 seconds)
Test Suite 'AnyCodableTests' passed at 2021-05-29 19:29:53.073
Executed 2 tests, with 0 failures (0 unexpected) in 0.037 (0.037) seconds
Test Suite 'AnyDecodableTests' started at 2021-05-29 19:29:53.074
Test Case 'AnyDecodableTests.testJSONDecoding' started at 2021-05-29 19:29:53.074
Test Case 'AnyDecodableTests.testJSONDecoding' passed (0.005 seconds)
Test Suite 'AnyDecodableTests' passed at 2021-05-29 19:29:53.079
Executed 1 test, with 0 failures (0 unexpected) in 0.005 (0.005) seconds
Test Suite 'AnyEncodableTests' started at 2021-05-29 19:29:53.079
Test Case 'AnyEncodableTests.testEncodeNSNumber' started at 2021-05-29 19:29:53.079
Test Case 'AnyEncodableTests.testEncodeNSNumber' passed (0.004 seconds)
Test Case 'AnyEncodableTests.testJSONEncoding' started at 2021-05-29 19:29:53.084
Test Case 'AnyEncodableTests.testJSONEncoding' passed (0.004 seconds)
Test Case 'AnyEncodableTests.testStringInterpolationEncoding' started at 2021-05-29 19:29:53.087
Test Case 'AnyEncodableTests.testStringInterpolationEncoding' passed (0.003 seconds)
Test Suite 'AnyEncodableTests' passed at 2021-05-29 19:29:53.090
Executed 3 tests, with 0 failures (0 unexpected) in 0.01 (0.01) seconds
Test Suite 'debug.xctest' passed at 2021-05-29 19:29:53.090
Executed 6 tests, with 0 failures (0 unexpected) in 0.052 (0.052) seconds
Test Suite 'All tests' passed at 2021-05-29 19:29:53.090
Executed 6 tests, with 0 failures (0 unexpected) in 0.052 (0.052) seconds
Test Suite 'All tests' started at 2021-05-29 19:35:06.082
Test Suite 'debug.xctest' started at 2021-05-29 19:35:06.128
Test Suite 'AnyCodableTests' started at 2021-05-29 19:35:06.128
Test Case 'AnyCodableTests.testJSONDecoding' started at 2021-05-29 19:35:06.128
Test Case 'AnyCodableTests.testJSONDecoding' passed (0.024 seconds)
Test Case 'AnyCodableTests.testJSONEncoding' started at 2021-05-29 19:35:06.153
Test Case 'AnyCodableTests.testJSONEncoding' passed (0.011 seconds)
Test Suite 'AnyCodableTests' passed at 2021-05-29 19:35:06.165
Executed 2 tests, with 0 failures (0 unexpected) in 0.035 (0.035) seconds
Test Suite 'AnyDecodableTests' started at 2021-05-29 19:35:06.165
Test Case 'AnyDecodableTests.testJSONDecoding' started at 2021-05-29 19:35:06.165
Test Case 'AnyDecodableTests.testJSONDecoding' passed (0.004 seconds)
Test Suite 'AnyDecodableTests' passed at 2021-05-29 19:35:06.170
Executed 1 test, with 0 failures (0 unexpected) in 0.004 (0.004) seconds
Test Suite 'AnyEncodableTests' started at 2021-05-29 19:35:06.170
Test Case 'AnyEncodableTests.testEncodeNSNumber' started at 2021-05-29 19:35:06.170
Test Case 'AnyEncodableTests.testEncodeNSNumber' passed (0.003 seconds)
Test Case 'AnyEncodableTests.testJSONEncoding' started at 2021-05-29 19:35:06.173
Test Case 'AnyEncodableTests.testJSONEncoding' passed (0.003 seconds)
Test Case 'AnyEncodableTests.testStringInterpolationEncoding' started at 2021-05-29 19:35:06.176
Test Case 'AnyEncodableTests.testStringInterpolationEncoding' passed (0.002 seconds)
Test Suite 'AnyEncodableTests' passed at 2021-05-29 19:35:06.178
Executed 3 tests, with 0 failures (0 unexpected) in 0.008 (0.008) seconds
Test Suite 'debug.xctest' passed at 2021-05-29 19:35:06.178
Executed 6 tests, with 0 failures (0 unexpected) in 0.048 (0.048) seconds
Test Suite 'All tests' passed at 2021-05-29 19:35:06.178
Executed 6 tests, with 0 failures (0 unexpected) in 0.048 (0.048) seconds
Test Suite 'All tests' started at 2021-05-29 19:39:25.727
Test Suite 'debug.xctest' started at 2021-05-29 19:39:25.764
Test Suite 'AnyCodableTests' started at 2021-05-29 19:39:25.765
Test Case 'AnyCodableTests.testJSONDecoding' started at 2021-05-29 19:39:25.765
Test Case 'AnyCodableTests.testJSONDecoding' passed (0.022 seconds)
Test Case 'AnyCodableTests.testJSONEncoding' started at 2021-05-29 19:39:25.788
Test Case 'AnyCodableTests.testJSONEncoding' passed (0.011 seconds)
Test Suite 'AnyCodableTests' passed at 2021-05-29 19:39:25.799
Executed 2 tests, with 0 failures (0 unexpected) in 0.033 (0.033) seconds
Test Suite 'AnyDecodableTests' started at 2021-05-29 19:39:25.800
Test Case 'AnyDecodableTests.testJSONDecoding' started at 2021-05-29 19:39:25.800
Test Case 'AnyDecodableTests.testJSONDecoding' passed (0.005 seconds)
Test Suite 'AnyDecodableTests' passed at 2021-05-29 19:39:25.805
Executed 1 test, with 0 failures (0 unexpected) in 0.005 (0.005) seconds
Test Suite 'AnyEncodableTests' started at 2021-05-29 19:39:25.805
Test Case 'AnyEncodableTests.testEncodeNSNumber' started at 2021-05-29 19:39:25.805
Test Case 'AnyEncodableTests.testEncodeNSNumber' passed (0.004 seconds)
Test Case 'AnyEncodableTests.testJSONEncoding' started at 2021-05-29 19:39:25.809
Test Case 'AnyEncodableTests.testJSONEncoding' passed (0.004 seconds)
Test Case 'AnyEncodableTests.testStringInterpolationEncoding' started at 2021-05-29 19:39:25.812
Test Case 'AnyEncodableTests.testStringInterpolationEncoding' passed (0.003 seconds)
Test Suite 'AnyEncodableTests' passed at 2021-05-29 19:39:25.815
Executed 3 tests, with 0 failures (0 unexpected) in 0.01 (0.01) seconds
Test Suite 'debug.xctest' passed at 2021-05-29 19:39:25.815
Executed 6 tests, with 0 failures (0 unexpected) in 0.048 (0.048) seconds
Test Suite 'All tests' passed at 2021-05-29 19:39:25.815
Executed 6 tests, with 0 failures (0 unexpected) in 0.048 (0.048) seconds
Test Suite 'All tests' started at 2021-05-29 19:42:18.164
Test Suite 'debug.xctest' started at 2021-05-29 19:42:18.201
Test Suite 'AnyCodableTests' started at 2021-05-29 19:42:18.202
Test Case 'AnyCodableTests.testJSONDecoding' started at 2021-05-29 19:42:18.202
Test Case 'AnyCodableTests.testJSONDecoding' passed (0.024 seconds)
Test Case 'AnyCodableTests.testJSONEncoding' started at 2021-05-29 19:42:18.227
Test Case 'AnyCodableTests.testJSONEncoding' passed (0.012 seconds)
Test Suite 'AnyCodableTests' passed at 2021-05-29 19:42:18.239
Executed 2 tests, with 0 failures (0 unexpected) in 0.036 (0.036) seconds
Test Suite 'AnyDecodableTests' started at 2021-05-29 19:42:18.240
Test Case 'AnyDecodableTests.testJSONDecoding' started at 2021-05-29 19:42:18.240
Test Case 'AnyDecodableTests.testJSONDecoding' passed (0.003 seconds)
Test Suite 'AnyDecodableTests' passed at 2021-05-29 19:42:18.243
Executed 1 test, with 0 failures (0 unexpected) in 0.003 (0.003) seconds
Test Suite 'AnyEncodableTests' started at 2021-05-29 19:42:18.243
Test Case 'AnyEncodableTests.testEncodeNSNumber' started at 2021-05-29 19:42:18.243
Test Case 'AnyEncodableTests.testEncodeNSNumber' passed (0.003 seconds)
Test Case 'AnyEncodableTests.testJSONEncoding' started at 2021-05-29 19:42:18.246
Test Case 'AnyEncodableTests.testJSONEncoding' passed (0.003 seconds)
Test Case 'AnyEncodableTests.testStringInterpolationEncoding' started at 2021-05-29 19:42:18.249
Test Case 'AnyEncodableTests.testStringInterpolationEncoding' passed (0.002 seconds)
Test Suite 'AnyEncodableTests' passed at 2021-05-29 19:42:18.252
Executed 3 tests, with 0 failures (0 unexpected) in 0.008 (0.008) seconds
Test Suite 'debug.xctest' passed at 2021-05-29 19:42:18.252
Executed 6 tests, with 0 failures (0 unexpected) in 0.048 (0.048) seconds
Test Suite 'All tests' passed at 2021-05-29 19:42:18.252
Executed 6 tests, with 0 failures (0 unexpected) in 0.048 (0.048) seconds
Fixes: https://github.com/Flight-School/AnyCodable/issues/45