From 41de219e543df3e6b80f1b7baeab64b3b49a80e7 Mon Sep 17 00:00:00 2001 From: fummicc1 Date: Sun, 30 Jun 2024 16:12:01 +0900 Subject: [PATCH] Update tests --- .../TestFuncThrow/FixtureFuncThrow.swift | 16 ++++++--------- Tests/TestInit/FixtureInit.swift | 20 +++++++++++++++++++ Tests/TestInit/InitTests.swift | 7 +++++++ 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/Tests/TestFuncs/TestFuncThrow/FixtureFuncThrow.swift b/Tests/TestFuncs/TestFuncThrow/FixtureFuncThrow.swift index b1481c69..ec37388d 100644 --- a/Tests/TestFuncs/TestFuncThrow/FixtureFuncThrow.swift +++ b/Tests/TestFuncs/TestFuncThrow/FixtureFuncThrow.swift @@ -104,16 +104,12 @@ class FuncThrowMock: FuncThrow { let funcTypedThrow = """ import Foundation -enum FuncError: Error { - case foo -} - /// \(String.mockAnnotation) protocol FuncTypedThrow { func f1(arg: Int) throws(any LocalizedError) -> String func f2(arg: Int) throws(any LocalizedError) - func f3(arg: Int) throws(FuncError) -> String - func f4(arg: Int) throws(FuncError) + func f3(arg: Int) throws(SomeError) -> String + func f4(arg: Int) throws(SomeError) } """ let funcTypedThrowMock = """ @@ -146,8 +142,8 @@ class FuncTypedThrowMock: FuncTypedThrow { } private(set) var f3CallCount = 0 - var f3Handler: ((Int) throws(FuncError) -> (String))? - func f3(arg: Int) throws(FuncError) -> String { + var f3Handler: ((Int) throws(SomeError) -> (String))? + func f3(arg: Int) throws(SomeError) -> String { f3CallCount += 1 if let f3Handler = f3Handler { return try f3Handler(arg) @@ -156,8 +152,8 @@ class FuncTypedThrowMock: FuncTypedThrow { } private(set) var f4CallCount = 0 - var f4Handler: ((Int) throws(FuncError) -> ())? - func f4(arg: Int) throws(FuncError) { + var f4Handler: ((Int) throws(SomeError) -> ())? + func f4(arg: Int) throws(SomeError) { f4CallCount += 1 if let f4Handler = f4Handler { try f4Handler(arg) diff --git a/Tests/TestInit/FixtureInit.swift b/Tests/TestInit/FixtureInit.swift index 161d1fe3..56710793 100644 --- a/Tests/TestInit/FixtureInit.swift +++ b/Tests/TestInit/FixtureInit.swift @@ -326,3 +326,23 @@ class MyProtocolMock: MyProtocol { } """ + +let throwableInit = """ +/// \(String.mockAnnotation) +protocol MyProtocol { + init(param: String) throws(SomeError) +} +""" + +let throwableInitMock = """ + + + +class MyProtocolMock: MyProtocol { + private var _param: String! + init() { } + required init(param: String = "") throws(SomeError) { + self._param = param + } +} +""" diff --git a/Tests/TestInit/InitTests.swift b/Tests/TestInit/InitTests.swift index a3c2af90..f5d8af86 100644 --- a/Tests/TestInit/InitTests.swift +++ b/Tests/TestInit/InitTests.swift @@ -41,4 +41,11 @@ class InitTests: MockoloTestCase { dstContent: initWithSameParamNameButDifferentTypeMock ) } + + func testThrowableInit() { + verify( + srcContent: throwableInit, + dstContent: throwableInitMock + ) + } }