diff --git a/Tests/Public/BoxTests.swift b/Tests/Public/BoxTests.swift index 949a4c90..a0ad12c1 100644 --- a/Tests/Public/BoxTests.swift +++ b/Tests/Public/BoxTests.swift @@ -27,7 +27,9 @@ import Mustache private struct CustomHashableBoxable : MustacheBoxable, Hashable { let int: Int init(_ int: Int) { self.int = int } - var hashValue: Int { return int } + func hash(into hasher: inout Hasher) { + hasher.combine(int) + } var mustacheBox: MustacheBox { // Don't inherit the boolean nature of int return MustacheBox( @@ -588,14 +590,14 @@ class BoxTests: XCTestCase { } do { // Infered element type (won't compile) - let value: Dictionary = ["int": [1, 2], "string": ["foo", "bar"]] + let value: Dictionary = ["int": [1, 2] as [Any], "string": ["foo", "bar"]] let template = try! Template(string: "{{int}}, {{string}}") let rendering = try! template.render(value) XCTAssertEqual(rendering, "12, foobar") } do { // Infered type (won't compile) - let value = ["int": [1, 2], "string": ["foo", "bar"]] + let value = ["int": [1, 2] as [Any], "string": ["foo", "bar"]] let template = try! Template(string: "{{int}}, {{string}}") let rendering = try! template.render(value) XCTAssertEqual(rendering, "12, foobar") @@ -603,7 +605,7 @@ class BoxTests: XCTestCase { do { // Infered type let template = try! Template(string: "{{int}}, {{string}}") - let value = ["int": [1, 2], "string": ["foo", "bar"]] + let value = ["int": [1, 2] as [Any], "string": ["foo", "bar"]] let rendering = try! template.render(value) XCTAssertEqual(rendering, "12, foobar") } @@ -626,14 +628,14 @@ class BoxTests: XCTestCase { } do { // Infered element type (won't compile) - let value: Dictionary = ["int": ["name": 1], "string": ["name": "foo"]] + let value: Dictionary = ["int": ["name": 1] as [String : Any], "string": ["name": "foo"]] let template = try! Template(string: "{{int.name}}, {{string.name}}") let rendering = try! template.render(value) XCTAssertEqual(rendering, "1, foo") } do { // Infered type (won't compile) - let value = ["int": ["name": 1], "string": ["name": "foo"]] + let value = ["int": ["name": 1] as [String : Any], "string": ["name": "foo"]] let template = try! Template(string: "{{int.name}}, {{string.name}}") let rendering = try! template.render(value) XCTAssertEqual(rendering, "1, foo") @@ -641,7 +643,7 @@ class BoxTests: XCTestCase { do { // Infered type let template = try! Template(string: "{{int.name}}, {{string.name}}") - let value = ["int": ["name": 1], "string": ["name": "foo"]] + let value = ["int": ["name": 1] as [String : Any], "string": ["name": "foo"]] let rendering = try! template.render(value) XCTAssertEqual(rendering, "1, foo") } @@ -912,7 +914,7 @@ class BoxTests: XCTestCase { do { // Direct argument let template = try! Template(string: "{{#.}}{{.}}{{/}}") - let rendering = try! template.render([0,"foo"]) + let rendering = try! template.render([0,"foo"] as [Any]) XCTAssertEqual(rendering, "0foo") } do { @@ -927,21 +929,21 @@ class BoxTests: XCTestCase { func testArrayOfArray() { do { // Explicit type - let value: [Any] = [[0,"foo"]] + let value: [Any] = [[0,"foo"] as [Any]] let template = try! Template(string: "{{#.}}{{.}}{{/}}") let rendering = try! template.render(value) XCTAssertEqual(rendering, "0foo") } do { // Infered element type - let value: Array = [[0,"foo"]] + let value: Array = [[0,"foo"] as [Any]] let template = try! Template(string: "{{#.}}{{.}}{{/}}") let rendering = try! template.render(value) XCTAssertEqual(rendering, "0foo") } do { // Infered type - let value = [[0,"foo"]] + let value = [[0,"foo"] as [Any]] let template = try! Template(string: "{{#.}}{{.}}{{/}}") let rendering = try! template.render(value) XCTAssertEqual(rendering, "0foo") @@ -949,12 +951,12 @@ class BoxTests: XCTestCase { do { // Direct argument let template = try! Template(string: "{{#.}}{{.}}{{/}}") - let rendering = try! template.render([[0,"foo"]]) + let rendering = try! template.render([[0,"foo"] as [Any]]) XCTAssertEqual(rendering, "0foo") } do { // Nested - let value: [Any] = [[0,"foo"]] + let value: [Any] = [[0,"foo"] as [Any]] let template = try! Template(string: "{{#nested}}{{#.}}{{.}}{{/}}{{/}}") let rendering = try! template.render(["nested": value]) XCTAssertEqual(rendering, "0foo") @@ -1033,7 +1035,7 @@ class BoxTests: XCTestCase { do { // Direct argument let template = try! Template(string: "{{#.}}{{.}}{{/}}") - let rendering = try! template.render([0, nil, "foo"]) + let rendering = try! template.render([0, nil, "foo"] as [Any?]) XCTAssertEqual(rendering, "0foo") } do { diff --git a/Tests/Public/ContextTests/ContextTests.swift b/Tests/Public/ContextTests/ContextTests.swift index 40ae78ba..28b25df2 100644 --- a/Tests/Public/ContextTests/ContextTests.swift +++ b/Tests/Public/ContextTests/ContextTests.swift @@ -75,7 +75,7 @@ class ContextTests: XCTestCase { } func testSubscript() { - let context = Context(["name": "name1", "a": ["name": "name2"]]) + let context = Context(["name": "name1", "a": ["name": "name2"]] as [String : Any]) // '.' is an expression, not a key XCTAssertTrue(context.mustacheBox(forKey: ".").isEmpty) diff --git a/Tests/Public/ContextTests/ContextValueForMustacheExpressionTests.swift b/Tests/Public/ContextTests/ContextValueForMustacheExpressionTests.swift index 9f1cbf4e..8589f63d 100644 --- a/Tests/Public/ContextTests/ContextValueForMustacheExpressionTests.swift +++ b/Tests/Public/ContextTests/ContextValueForMustacheExpressionTests.swift @@ -51,7 +51,7 @@ class ContextValueForMustacheExpressionTests: XCTestCase { let filter = Filter({ (string: String?) -> Any? in return string!.uppercased() }) - let context = Context(["name": "success", "f": filter]) + let context = Context(["name": "success", "f": filter] as [String : Any]) let box = try! context.mustacheBox(forExpression: "f(name)") let string = box.value as? String XCTAssertEqual(string!, "SUCCESS") diff --git a/Tests/Public/HookFunctionTests.swift b/Tests/Public/HookFunctionTests.swift index b338c28b..268ad1dd 100644 --- a/Tests/Public/HookFunctionTests.swift +++ b/Tests/Public/HookFunctionTests.swift @@ -208,7 +208,7 @@ class HookFunctionTests: XCTestCase { template.baseContext = template.baseContext.extendedContext(willRender) willRenderCount = 0 renderedValue = nil - rendering = try! template.render(["subject": "foo", "filter": Filter(filter)]) + rendering = try! template.render(["subject": "foo", "filter": Filter(filter)] as [String : Any]) XCTAssertEqual(rendering, "FOO") XCTAssertEqual(willRenderCount, 1) XCTAssertEqual((renderedValue!.value as! String), "FOO") @@ -217,7 +217,7 @@ class HookFunctionTests: XCTestCase { template.baseContext = template.baseContext.extendedContext(willRender) willRenderCount = 0 renderedValue = nil - rendering = try! template.render(["subject": "foo", "filter": Filter(filter)]) + rendering = try! template.render(["subject": "foo", "filter": Filter(filter)] as [String : Any]) XCTAssertEqual(rendering, "3") XCTAssertEqual(willRenderCount, 1) XCTAssertEqual((renderedValue!.value as! Int), 3)