Skip to content

Commit 72d00a4

Browse files
committed
Variable doesn't convert .other to String
Also got rid of RawRepresentable searches as they are not valid anymore
1 parent 0e70044 commit 72d00a4

File tree

4 files changed

+1
-63
lines changed

4 files changed

+1
-63
lines changed

Sources/JMESPath/Expression.swift

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -38,36 +38,6 @@ public struct Expression {
3838
return try self.search(json: json, runtime: runtime) as? Value
3939
}
4040

41-
/// Search JSON
42-
///
43-
/// - Parameters:
44-
/// - any: Swift type to search
45-
/// - as: Swift type to return
46-
/// - runtime: JMES runtime (includes functions)
47-
/// - Throws: JMESPathError
48-
/// - Returns: Search result
49-
public func search<Value: RawRepresentable>(json: Data, as: Value.Type = Value.self, runtime: JMESRuntime = .init()) throws -> Value? {
50-
if let rawValue = try self.search(json: json, runtime: runtime) as? Value.RawValue {
51-
return Value(rawValue: rawValue)
52-
}
53-
return nil
54-
}
55-
56-
/// Search JSON
57-
///
58-
/// - Parameters:
59-
/// - any: Swift type to search
60-
/// - as: Swift type to return
61-
/// - runtime: JMES runtime (includes functions)
62-
/// - Throws: JMESPathError
63-
/// - Returns: Search result
64-
public func search<Value: RawRepresentable>(json: String, as: Value.Type = Value.self, runtime: JMESRuntime = .init()) throws -> Value? {
65-
if let rawValue = try self.search(json: json, runtime: runtime) as? Value.RawValue {
66-
return Value(rawValue: rawValue)
67-
}
68-
return nil
69-
}
70-
7141
/// Search Swift type
7242
///
7343
/// - Parameters:
@@ -80,21 +50,6 @@ public struct Expression {
8050
return try self.search(any, runtime: runtime) as? Value
8151
}
8252

83-
/// Search Swift type
84-
///
85-
/// - Parameters:
86-
/// - any: Swift type to search
87-
/// - as: Swift type to return
88-
/// - runtime: JMES runtime (includes functions)
89-
/// - Throws: JMESPathError
90-
/// - Returns: Search result
91-
public func search<Value: RawRepresentable>(_ any: Any, as: Value.Type = Value.self, runtime: JMESRuntime = .init()) throws -> Value? {
92-
if let rawValue = try self.search(any, runtime: runtime) as? Value.RawValue {
93-
return Value(rawValue: rawValue)
94-
}
95-
return nil
96-
}
97-
9853
/// Search JSON
9954
///
10055
/// - Parameters:

Sources/JMESPath/Variable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public enum JMESVariable {
7878
case .boolean(let bool): return bool
7979
case .array(let array): return array
8080
case .object(let map): return map
81-
case .other(let any): return String(describing: any)
81+
case .other(let any): return any
8282
case .expRef: return nil
8383
}
8484
}

Tests/JMESPathTests/ErrorTests.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ final class ErrorTests: XCTestCase {
1111
default:
1212
XCTFail("\(error)")
1313
}
14-
print(error)
1514
}
1615
}
1716

@@ -24,7 +23,6 @@ final class ErrorTests: XCTestCase {
2423
default:
2524
XCTFail("\(error)")
2625
}
27-
print(error)
2826
}
2927
}
3028

@@ -37,7 +35,6 @@ final class ErrorTests: XCTestCase {
3735
default:
3836
XCTFail("\(error)")
3937
}
40-
print(error)
4138
}
4239
}
4340

@@ -50,7 +47,6 @@ final class ErrorTests: XCTestCase {
5047
default:
5148
XCTFail("\(error)")
5249
}
53-
print(error)
5450
}
5551
}
5652

@@ -63,7 +59,6 @@ final class ErrorTests: XCTestCase {
6359
default:
6460
XCTFail("\(error)")
6561
}
66-
print(error)
6762
}
6863
}
6964

@@ -76,7 +71,6 @@ final class ErrorTests: XCTestCase {
7671
default:
7772
XCTFail("\(error)")
7873
}
79-
print(error)
8074
}
8175
}
8276
}

Tests/JMESPathTests/MirrorTests.swift

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,6 @@ final class MirrorTests: XCTestCase {
1212
}
1313
}
1414

15-
func testInterpreter<Value: RawRepresentable & Equatable>(_ expression: String, data: Any, result: Value) {
16-
do {
17-
let expression = try Expression.compile(expression)
18-
let value = try XCTUnwrap(expression.search(data, as: Value.self))
19-
XCTAssertEqual(value, result)
20-
} catch {
21-
XCTFail("\(error)")
22-
}
23-
}
24-
2515
func testString() {
2616
struct TestString {
2717
let s: String
@@ -84,6 +74,5 @@ final class MirrorTests: XCTestCase {
8474
}
8575
let test = TestObject(e: .test2)
8676
self.testInterpreter("e", data: test, result: TestEnum.test2)
87-
self.testInterpreter("e", data: test, result: "test2")
8877
}
8978
}

0 commit comments

Comments
 (0)