Skip to content

Commit

Permalink
Merge pull request #15 from pvieito/github-actions-ci-2
Browse files Browse the repository at this point in the history
Added cross-platform support and GitHub Actions CI to test Swift package on macOS an Linux
  • Loading branch information
tattn authored Dec 13, 2019
2 parents 121cc53 + f9b1dd7 commit 360a8fc
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 24 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Continuous Integration

on:
- push
- pull_request

jobs:
continuous-integration:
strategy:
matrix:
os:
- ubuntu-latest
- macOS-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
- run: rm .swift-version
- name: Install Swift
uses: YOCKOW/Action-setup-swift@master
with:
swift-version: '5.1'
- name: Test
run: swift test --enable-test-discovery
7 changes: 5 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ let package = Package(
targets: [
.target(
name: "MoreCodable",
path: "Sources")
path: "Sources"),
.testTarget(
name: "MoreCodableTests",
dependencies: ["MoreCodable"],
path: "Tests")
],
swiftLanguageVersions: [.v5]
)

25 changes: 3 additions & 22 deletions Sources/MoreJSONDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// Modifications copyright (c) 2019 Daniil Pendikov

import Foundation
import CoreFoundation

fileprivate protocol _JSONStringDictionaryDecodableMarker {
static var elementType: Decodable.Type { get }
Expand Down Expand Up @@ -1108,36 +1109,16 @@ extension _JSONDecoder {
fileprivate func unbox(_ value: Any, as type: Bool.Type) throws -> Bool? {
guard !(value is NSNull) else { return nil }

#if DEPLOYMENT_RUNTIME_SWIFT
// Bridging differences require us to split implementations here
guard let number = __SwiftValue.store(value) as? NSNumber else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}

// TODO: Add a flag to coerce non-boolean numbers into Bools?
guard number._cfTypeID == CFBooleanGetTypeID() else {
throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
}

return number.boolValue
#else
if let number = value as? NSNumber {
// TODO: Add a flag to coerce non-boolean numbers into Bools?
if number === kCFBooleanTrue as NSNumber {
if number === kCFBooleanTrue {
return true
} else if number === kCFBooleanFalse as NSNumber {
} else if number === kCFBooleanFalse {
return false
}

/* FIXME: If swift-corelibs-foundation doesn't change to use NSNumber, this code path will need to be included and tested:
} else if let bool = value as? Bool {
return bool
*/

}

throw DecodingError._typeMismatch(at: self.codingPath, expectation: type, reality: value)
#endif
}

fileprivate func unbox(_ value: Any, as type: Int.Type) throws -> Int? {
Expand Down

0 comments on commit 360a8fc

Please sign in to comment.