Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fummicc1 committed Jun 30, 2024
1 parent f5713af commit 41de219
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 10 deletions.
16 changes: 6 additions & 10 deletions Tests/TestFuncs/TestFuncThrow/FixtureFuncThrow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 = """
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions Tests/TestInit/FixtureInit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
"""
7 changes: 7 additions & 0 deletions Tests/TestInit/InitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,11 @@ class InitTests: MockoloTestCase {
dstContent: initWithSameParamNameButDifferentTypeMock
)
}

func testThrowableInit() {
verify(
srcContent: throwableInit,
dstContent: throwableInitMock
)
}
}

0 comments on commit 41de219

Please sign in to comment.