Skip to content

Commit

Permalink
Get tests compiling on iOS
Browse files Browse the repository at this point in the history
Tests use sortedKeys option of `JSONSerialization.data` which is unavailable pre iOS 11, so only make tests available iOS 11 and later
  • Loading branch information
adam-fowler committed Jun 8, 2021
1 parent 9095158 commit 3a7d095
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Tests/JMESPathTests/ComplianceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ final class ComplianceTests: XCTestCase {
let cases: [Case]
let comment: String?

@available(iOS 11.0, tvOS 11.0, watchOS 5.0, *)
func run() throws {
for c in self.cases {
if let _ = c.bench {
Expand Down Expand Up @@ -99,6 +100,7 @@ final class ComplianceTests: XCTestCase {
XCTFail("Should throw an error")
}

@available(iOS 11.0, tvOS 11.0, watchOS 5.0, *)
func testResult(_ c: Case, result: Any?) {
do {
let expression = try Expression.compile(c.expression)
Expand All @@ -119,6 +121,7 @@ final class ComplianceTests: XCTestCase {
}
}

@available(iOS 11.0, tvOS 11.0, watchOS 5.0, *)
func output(_ c: Case, expected: String?, result: String?) {
if expected != result {
let data = try! JSONSerialization.data(withJSONObject: self.given.value, options: [.fragmentsAllowed, .sortedKeys])
Expand All @@ -143,8 +146,10 @@ final class ComplianceTests: XCTestCase {
let data = try Data(contentsOf: url)
let tests = try JSONDecoder().decode([ComplianceTest].self, from: data)

for test in tests {
try test.run()
if #available(iOS 11.0, tvOS 11.0, watchOS 5.0, *) {
for test in tests {
try test.run()
}
}
}

Expand Down

0 comments on commit 3a7d095

Please sign in to comment.