Fix support of closures and unwrapped optionals.
This commit is contained in:
parent
f3064ae797
commit
5094d166d8
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
* Show error in generator in build log.
|
* Show error in generator in build log.
|
||||||
* Fixed crash of generator when instance variable type is not explicitly set.
|
* Fixed crash of generator when instance variable type is not explicitly set.
|
||||||
|
* Fixed support of closures and unwrapped optionals.
|
||||||
|
|
||||||
## 0.8.1
|
## 0.8.1
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
DC70D0D41D2B026200014C5F /* VerificationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC70D0D31D2B026200014C5F /* VerificationTest.swift */; };
|
DC70D0D41D2B026200014C5F /* VerificationTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC70D0D31D2B026200014C5F /* VerificationTest.swift */; };
|
||||||
DC70D0D61D2B9FBE00014C5F /* ParameterMatcherTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC70D0D51D2B9FBE00014C5F /* ParameterMatcherTest.swift */; };
|
DC70D0D61D2B9FBE00014C5F /* ParameterMatcherTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC70D0D51D2B9FBE00014C5F /* ParameterMatcherTest.swift */; };
|
||||||
DC70D0D81D2B9FD400014C5F /* CallMatcherTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC70D0D71D2B9FD400014C5F /* CallMatcherTest.swift */; };
|
DC70D0D81D2B9FD400014C5F /* CallMatcherTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC70D0D71D2B9FD400014C5F /* CallMatcherTest.swift */; };
|
||||||
|
DC78DE2C1E0715BD00279900 /* ClassWithOptionals.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCE2DE0F1E071389006E462C /* ClassWithOptionals.swift */; };
|
||||||
DC9EF9FE1CFAD4F10034DFE5 /* Stub.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC9EF9FD1CFAD4F10034DFE5 /* Stub.swift */; };
|
DC9EF9FE1CFAD4F10034DFE5 /* Stub.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC9EF9FD1CFAD4F10034DFE5 /* Stub.swift */; };
|
||||||
DC9EFA001CFAD5660034DFE5 /* StubCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC9EF9FF1CFAD5660034DFE5 /* StubCall.swift */; };
|
DC9EFA001CFAD5660034DFE5 /* StubCall.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC9EF9FF1CFAD5660034DFE5 /* StubCall.swift */; };
|
||||||
DC9EFA1A1CFADAD70034DFE5 /* Matchable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC9EFA161CFADAD70034DFE5 /* Matchable.swift */; };
|
DC9EFA1A1CFADAD70034DFE5 /* Matchable.swift in Sources */ = {isa = PBXBuildFile; fileRef = DC9EFA161CFADAD70034DFE5 /* Matchable.swift */; };
|
||||||
|
@ -152,6 +153,7 @@
|
||||||
DCD432D11D9277D80023AADA /* ClassForStubTesting.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClassForStubTesting.swift; sourceTree = "<group>"; };
|
DCD432D11D9277D80023AADA /* ClassForStubTesting.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClassForStubTesting.swift; sourceTree = "<group>"; };
|
||||||
DCD432D31D92868C0023AADA /* StubTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StubTest.swift; sourceTree = "<group>"; };
|
DCD432D31D92868C0023AADA /* StubTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StubTest.swift; sourceTree = "<group>"; };
|
||||||
DCD432D71D929B2A0023AADA /* DefaultValueRegistryTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultValueRegistryTest.swift; sourceTree = "<group>"; };
|
DCD432D71D929B2A0023AADA /* DefaultValueRegistryTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DefaultValueRegistryTest.swift; sourceTree = "<group>"; };
|
||||||
|
DCE2DE0F1E071389006E462C /* ClassWithOptionals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ClassWithOptionals.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
|
@ -311,6 +313,7 @@
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
DCD432D11D9277D80023AADA /* ClassForStubTesting.swift */,
|
DCD432D11D9277D80023AADA /* ClassForStubTesting.swift */,
|
||||||
|
DCE2DE0F1E071389006E462C /* ClassWithOptionals.swift */,
|
||||||
DC70D0BB1D2AF40800014C5F /* TestedClass.swift */,
|
DC70D0BB1D2AF40800014C5F /* TestedClass.swift */,
|
||||||
DC70D0BC1D2AF40800014C5F /* TestedProtocol.swift */,
|
DC70D0BC1D2AF40800014C5F /* TestedProtocol.swift */,
|
||||||
);
|
);
|
||||||
|
@ -521,7 +524,7 @@
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
shellPath = /bin/sh;
|
shellPath = /bin/sh;
|
||||||
shellScript = "OUTPUT=\"$PROJECT_DIR/Tests/Generated/GeneratedMocks.swift\"\nINPUT=\"$PROJECT_DIR/Tests/Source/ClassForStubTesting.swift\" # Use seperate variables for each file.\nfor definition in $GCC_PREPROCESSOR_DEFINITIONS; do\n if [ $definition = \"USE_RUN\" ]; then\n use_run=1\n fi\ndone\nif [ $use_run ]; then\n \"$PROJECT_DIR/run\" --clean generate --output \"$OUTPUT\" \"$INPUT\"\nelse\n \"$BUILD_DIR/$CONFIGURATION/cuckoo_generator.app/Contents/MacOS/cuckoo_generator\" generate --output \"$OUTPUT\" \"$INPUT\" \"$PROJECT_DIR/Tests/Source/TestedProtocol.swift\" \"$PROJECT_DIR/Tests/Source/TestedClass.swift\"\nfi";
|
shellScript = "OUTPUT=\"$PROJECT_DIR/Tests/Generated/GeneratedMocks.swift\"\n# Use seperate variables for each file.\nINPUT_STUB=\"$PROJECT_DIR/Tests/Source/ClassForStubTesting.swift\"\nINPUT_OPTIONAL=\"$PROJECT_DIR/Tests/Source/ClassWithOptionals.swift\"\nfor definition in $GCC_PREPROCESSOR_DEFINITIONS; do\n if [ $definition = \"USE_RUN\" ]; then\n use_run=1\n fi\ndone\nif [ $use_run ]; then\n \"$PROJECT_DIR/run\" --clean generate --output \"$OUTPUT\" \"$INPUT_STUB\" \"$INPUT_OPTIONAL\"\nelse\n \"$BUILD_DIR/$CONFIGURATION/cuckoo_generator.app/Contents/MacOS/cuckoo_generator\" generate --output \"$OUTPUT\" \"$INPUT_STUB\" \"$INPUT_OPTIONAL\" \"$PROJECT_DIR/Tests/Source/TestedProtocol.swift\" \"$PROJECT_DIR/Tests/Source/TestedClass.swift\"\nfi";
|
||||||
};
|
};
|
||||||
/* End PBXShellScriptBuildPhase section */
|
/* End PBXShellScriptBuildPhase section */
|
||||||
|
|
||||||
|
@ -582,6 +585,7 @@
|
||||||
DC70D0D61D2B9FBE00014C5F /* ParameterMatcherTest.swift in Sources */,
|
DC70D0D61D2B9FBE00014C5F /* ParameterMatcherTest.swift in Sources */,
|
||||||
DCD432D61D9286D50023AADA /* ClassForStubTesting.swift in Sources */,
|
DCD432D61D9286D50023AADA /* ClassForStubTesting.swift in Sources */,
|
||||||
DC70D0AB1D2AB5F800014C5F /* ClassTest.swift in Sources */,
|
DC70D0AB1D2AB5F800014C5F /* ClassTest.swift in Sources */,
|
||||||
|
DC78DE2C1E0715BD00279900 /* ClassWithOptionals.swift in Sources */,
|
||||||
DC70D0B31D2AB6B900014C5F /* MatchableTest.swift in Sources */,
|
DC70D0B31D2AB6B900014C5F /* MatchableTest.swift in Sources */,
|
||||||
DC70D0BE1D2AF40800014C5F /* TestedClass.swift in Sources */,
|
DC70D0BE1D2AF40800014C5F /* TestedClass.swift in Sources */,
|
||||||
DC70D0D21D2B007300014C5F /* GeneratedMocks.swift in Sources */,
|
DC70D0D21D2B007300014C5F /* GeneratedMocks.swift in Sources */,
|
||||||
|
|
|
@ -149,7 +149,7 @@ public struct Generator {
|
||||||
let propertyType = token.readOnly ? "Cuckoo.ToBeStubbedReadOnlyProperty" : "Cuckoo.ToBeStubbedProperty"
|
let propertyType = token.readOnly ? "Cuckoo.ToBeStubbedReadOnlyProperty" : "Cuckoo.ToBeStubbedProperty"
|
||||||
|
|
||||||
code += ""
|
code += ""
|
||||||
code += "var \(token.name): \(propertyType)<\(token.type)> {"
|
code += "var \(token.name): \(propertyType)<\(genericSafeType(from: token.type))> {"
|
||||||
code.nest("return \(propertyType)(manager: manager, name: \"\(token.name)\")")
|
code.nest("return \(propertyType)(manager: manager, name: \"\(token.name)\")")
|
||||||
code += "}"
|
code += "}"
|
||||||
}
|
}
|
||||||
|
@ -174,10 +174,10 @@ public struct Generator {
|
||||||
}
|
}
|
||||||
|
|
||||||
let inputTypes = token.parameters.map { $0.typeWithoutAttributes }.joined(separator: ", ")
|
let inputTypes = token.parameters.map { $0.typeWithoutAttributes }.joined(separator: ", ")
|
||||||
var returnType = "\(stubFunction)<(\(inputTypes))"
|
var returnType = "\(stubFunction)<(\(genericSafeType(from: inputTypes)))"
|
||||||
if token.returnType != "Void" {
|
if token.returnType != "Void" {
|
||||||
returnType += ", "
|
returnType += ", "
|
||||||
returnType += token.returnType
|
returnType += genericSafeType(from: token.returnType)
|
||||||
}
|
}
|
||||||
returnType += ">"
|
returnType += ">"
|
||||||
|
|
||||||
|
@ -235,7 +235,7 @@ public struct Generator {
|
||||||
let propertyType = token.readOnly ? "Cuckoo.VerifyReadOnlyProperty" : "Cuckoo.VerifyProperty"
|
let propertyType = token.readOnly ? "Cuckoo.VerifyReadOnlyProperty" : "Cuckoo.VerifyProperty"
|
||||||
|
|
||||||
code += ""
|
code += ""
|
||||||
code += "var \(token.name): \(propertyType)<\(token.type)> {"
|
code += "var \(token.name): \(propertyType)<\(genericSafeType(from: token.type))> {"
|
||||||
code.nest("return \(propertyType)(manager: manager, name: \"\(token.name)\", callMatcher: callMatcher, sourceLocation: sourceLocation)")
|
code.nest("return \(propertyType)(manager: manager, name: \"\(token.name)\", callMatcher: callMatcher, sourceLocation: sourceLocation)")
|
||||||
code += "}"
|
code += "}"
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ public struct Generator {
|
||||||
code += ""
|
code += ""
|
||||||
code += "@discardableResult"
|
code += "@discardableResult"
|
||||||
code += ("\(token.accessibility.sourceName)func \(token.rawName)\(matchableGenerics(with: token.parameters))" +
|
code += ("\(token.accessibility.sourceName)func \(token.rawName)\(matchableGenerics(with: token.parameters))" +
|
||||||
"(\(matchableParameterSignature(with: token.parameters))) -> Cuckoo.__DoNotUse<\(token.returnType)>\(matchableGenerics(where: token.parameters)) {")
|
"(\(matchableParameterSignature(with: token.parameters))) -> Cuckoo.__DoNotUse<\(genericSafeType(from: token.returnType))>\(matchableGenerics(where: token.parameters)) {")
|
||||||
let matchers: String
|
let matchers: String
|
||||||
if token.parameters.isEmpty {
|
if token.parameters.isEmpty {
|
||||||
matchers = "[] as [Cuckoo.ParameterMatcher<Void>]"
|
matchers = "[] as [Cuckoo.ParameterMatcher<Void>]"
|
||||||
|
@ -259,7 +259,6 @@ public struct Generator {
|
||||||
code += "}"
|
code += "}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private func generateNoImplStubClass(for token: ContainerToken) {
|
private func generateNoImplStubClass(for token: ContainerToken) {
|
||||||
guard token.accessibility != .Private else { return }
|
guard token.accessibility != .Private else { return }
|
||||||
|
|
||||||
|
@ -289,7 +288,7 @@ public struct Generator {
|
||||||
code += "\(token.accessibility.sourceName)\(token.overriding ? "override " : "")var \(token.name): \(token.type) {"
|
code += "\(token.accessibility.sourceName)\(token.overriding ? "override " : "")var \(token.name): \(token.type) {"
|
||||||
code.nest {
|
code.nest {
|
||||||
code += "get {"
|
code += "get {"
|
||||||
code.nest("return DefaultValueRegistry.defaultValue(for: \(getTypeWithSelfSuffix(for: token.type)))")
|
code.nest("return DefaultValueRegistry.defaultValue(for: (\(token.type)).self)")
|
||||||
code += "}"
|
code += "}"
|
||||||
if token.readOnly == false {
|
if token.readOnly == false {
|
||||||
code += "set {"
|
code += "set {"
|
||||||
|
@ -308,7 +307,7 @@ public struct Generator {
|
||||||
|
|
||||||
code += ""
|
code += ""
|
||||||
code += "\(token.accessibility.sourceName)\(override)func \(token.rawName)(\(parametersSignature))\(token.returnSignature) {"
|
code += "\(token.accessibility.sourceName)\(override)func \(token.rawName)(\(parametersSignature))\(token.returnSignature) {"
|
||||||
code.nest("return DefaultValueRegistry.defaultValue(for: \(getTypeWithSelfSuffix(for: token.returnType)))")
|
code.nest("return DefaultValueRegistry.defaultValue(for: (\(token.returnType)).self)")
|
||||||
code += "}"
|
code += "}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,7 +337,7 @@ public struct Generator {
|
||||||
private func matchableGenerics(where parameters: [MethodParameter]) -> String {
|
private func matchableGenerics(where parameters: [MethodParameter]) -> String {
|
||||||
guard parameters.isEmpty == false else { return "" }
|
guard parameters.isEmpty == false else { return "" }
|
||||||
|
|
||||||
let whereClause = parameters.enumerated().map { "M\($0 + 1).MatchedType == \($1.typeWithoutAttributes)" }.joined(separator: ", ")
|
let whereClause = parameters.enumerated().map { "M\($0 + 1).MatchedType == \(genericSafeType(from: $1.typeWithoutAttributes))" }.joined(separator: ", ")
|
||||||
return " where \(whereClause)"
|
return " where \(whereClause)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,14 +352,10 @@ public struct Generator {
|
||||||
|
|
||||||
let tupleType = parameters.map { $0.typeWithoutAttributes }.joined(separator: ", ")
|
let tupleType = parameters.map { $0.typeWithoutAttributes }.joined(separator: ", ")
|
||||||
let matchers = parameters.enumerated().map { "wrap(matchable: \($1.name)) { $0\(parameters.count > 1 ? ".\($0)" : "") }" }.joined(separator: ", ")
|
let matchers = parameters.enumerated().map { "wrap(matchable: \($1.name)) { $0\(parameters.count > 1 ? ".\($0)" : "") }" }.joined(separator: ", ")
|
||||||
return "let matchers: [Cuckoo.ParameterMatcher<(\(tupleType))>] = [\(matchers)]"
|
return "let matchers: [Cuckoo.ParameterMatcher<(\(genericSafeType(from: tupleType)))>] = [\(matchers)]"
|
||||||
}
|
}
|
||||||
|
|
||||||
private func getTypeWithSelfSuffix(for typeName: String) -> String {
|
private func genericSafeType(from type: String) -> String {
|
||||||
if (typeName.hasSuffix("?")) {
|
return type.replacingOccurrences(of: "!", with: "?")
|
||||||
return "Optional<\(typeName.substring(to: typeName.index(before: typeName.endIndex)))>.self"
|
|
||||||
} else {
|
|
||||||
return typeName + ".self"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
//
|
||||||
|
// ClassWithOptionals.swift
|
||||||
|
// Cuckoo
|
||||||
|
//
|
||||||
|
// Created by Filip Dolnik on 18.12.16.
|
||||||
|
// Copyright © 2016 Brightify. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
class ClassWithOptionals {
|
||||||
|
|
||||||
|
var value: Int? = 0
|
||||||
|
|
||||||
|
var uValue: Int! = 0
|
||||||
|
|
||||||
|
var array: [Int?] = []
|
||||||
|
|
||||||
|
var closure: (Int?) -> Void = { _ in }
|
||||||
|
|
||||||
|
var uClosure: (Int!) -> Void = { _ in }
|
||||||
|
|
||||||
|
func returnValue() -> Int? {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
func returnUValue() -> Int! {
|
||||||
|
return uValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func returnArray() -> [Int?] {
|
||||||
|
return array
|
||||||
|
}
|
||||||
|
|
||||||
|
func parameter(parameter: Int?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func uParameter(parameter: Int!) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,261 @@
|
||||||
|
// MARK: - Mocks generated from file: SourceFiles/ClassWithOptionals.swift
|
||||||
|
//
|
||||||
|
// ClassWithOptionals.swift
|
||||||
|
// Cuckoo
|
||||||
|
//
|
||||||
|
// Created by Filip Dolnik on 18.12.16.
|
||||||
|
// Copyright © 2016 Brightify. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Cuckoo
|
||||||
|
|
||||||
|
class MockClassWithOptionals: ClassWithOptionals, Cuckoo.Mock {
|
||||||
|
typealias MocksType = ClassWithOptionals
|
||||||
|
typealias Stubbing = __StubbingProxy_ClassWithOptionals
|
||||||
|
typealias Verification = __VerificationProxy_ClassWithOptionals
|
||||||
|
let manager = Cuckoo.MockManager()
|
||||||
|
|
||||||
|
private var observed: ClassWithOptionals?
|
||||||
|
|
||||||
|
func spy(on victim: ClassWithOptionals) -> Self {
|
||||||
|
observed = victim
|
||||||
|
return self
|
||||||
|
}
|
||||||
|
|
||||||
|
override var value: Int? {
|
||||||
|
get {
|
||||||
|
return manager.getter("value", original: observed.map { o in return { () -> Int? in o.value } })
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
manager.setter("value", value: newValue, original: observed != nil ? { self.observed?.value = $0 } : nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override var uValue: Int! {
|
||||||
|
get {
|
||||||
|
return manager.getter("uValue", original: observed.map { o in return { () -> Int! in o.uValue } })
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
manager.setter("uValue", value: newValue, original: observed != nil ? { self.observed?.uValue = $0 } : nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override var array: [Int?] {
|
||||||
|
get {
|
||||||
|
return manager.getter("array", original: observed.map { o in return { () -> [Int?] in o.array } })
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
manager.setter("array", value: newValue, original: observed != nil ? { self.observed?.array = $0 } : nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override var closure: (Int?) -> Void {
|
||||||
|
get {
|
||||||
|
return manager.getter("closure", original: observed.map { o in return { () -> (Int?) -> Void in o.closure } })
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
manager.setter("closure", value: newValue, original: observed != nil ? { self.observed?.closure = $0 } : nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override var uClosure: (Int!) -> Void {
|
||||||
|
get {
|
||||||
|
return manager.getter("uClosure", original: observed.map { o in return { () -> (Int!) -> Void in o.uClosure } })
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
manager.setter("uClosure", value: newValue, original: observed != nil ? { self.observed?.uClosure = $0 } : nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override func returnValue() -> Int? {
|
||||||
|
return manager.call("returnValue() -> Int?", parameters: (), original: observed.map { o in return { () -> Int? in o.returnValue() } })
|
||||||
|
}
|
||||||
|
|
||||||
|
override func returnUValue() -> Int! {
|
||||||
|
return manager.call("returnUValue() -> Int!", parameters: (), original: observed.map { o in return { () -> Int! in o.returnUValue() } })
|
||||||
|
}
|
||||||
|
|
||||||
|
override func returnArray() -> [Int?] {
|
||||||
|
return manager.call("returnArray() -> [Int?]", parameters: (), original: observed.map { o in return { () -> [Int?] in o.returnArray() } })
|
||||||
|
}
|
||||||
|
|
||||||
|
override func parameter(parameter: Int?) {
|
||||||
|
return manager.call("parameter(parameter: Int?)", parameters: (parameter), original: observed.map { o in return { (parameter: Int?) in o.parameter(parameter: parameter) } })
|
||||||
|
}
|
||||||
|
|
||||||
|
override func uParameter(parameter: Int!) {
|
||||||
|
return manager.call("uParameter(parameter: Int!)", parameters: (parameter), original: observed.map { o in return { (parameter: Int!) in o.uParameter(parameter: parameter) } })
|
||||||
|
}
|
||||||
|
|
||||||
|
struct __StubbingProxy_ClassWithOptionals: Cuckoo.StubbingProxy {
|
||||||
|
private let manager: Cuckoo.MockManager
|
||||||
|
|
||||||
|
init(manager: Cuckoo.MockManager) {
|
||||||
|
self.manager = manager
|
||||||
|
}
|
||||||
|
|
||||||
|
var value: Cuckoo.ToBeStubbedProperty<Int?> {
|
||||||
|
return Cuckoo.ToBeStubbedProperty(manager: manager, name: "value")
|
||||||
|
}
|
||||||
|
|
||||||
|
var uValue: Cuckoo.ToBeStubbedProperty<Int?> {
|
||||||
|
return Cuckoo.ToBeStubbedProperty(manager: manager, name: "uValue")
|
||||||
|
}
|
||||||
|
|
||||||
|
var array: Cuckoo.ToBeStubbedProperty<[Int?]> {
|
||||||
|
return Cuckoo.ToBeStubbedProperty(manager: manager, name: "array")
|
||||||
|
}
|
||||||
|
|
||||||
|
var closure: Cuckoo.ToBeStubbedProperty<(Int?) -> Void> {
|
||||||
|
return Cuckoo.ToBeStubbedProperty(manager: manager, name: "closure")
|
||||||
|
}
|
||||||
|
|
||||||
|
var uClosure: Cuckoo.ToBeStubbedProperty<(Int?) -> Void> {
|
||||||
|
return Cuckoo.ToBeStubbedProperty(manager: manager, name: "uClosure")
|
||||||
|
}
|
||||||
|
|
||||||
|
func returnValue() -> Cuckoo.StubFunction<(), Int?> {
|
||||||
|
return Cuckoo.StubFunction(stub: manager.createStub("returnValue() -> Int?", parameterMatchers: []))
|
||||||
|
}
|
||||||
|
|
||||||
|
func returnUValue() -> Cuckoo.StubFunction<(), Int?> {
|
||||||
|
return Cuckoo.StubFunction(stub: manager.createStub("returnUValue() -> Int!", parameterMatchers: []))
|
||||||
|
}
|
||||||
|
|
||||||
|
func returnArray() -> Cuckoo.StubFunction<(), [Int?]> {
|
||||||
|
return Cuckoo.StubFunction(stub: manager.createStub("returnArray() -> [Int?]", parameterMatchers: []))
|
||||||
|
}
|
||||||
|
|
||||||
|
func parameter<M1: Cuckoo.Matchable>(parameter: M1) -> Cuckoo.StubNoReturnFunction<(Int?)> where M1.MatchedType == Int? {
|
||||||
|
let matchers: [Cuckoo.ParameterMatcher<(Int?)>] = [wrap(matchable: parameter) { $0 }]
|
||||||
|
return Cuckoo.StubNoReturnFunction(stub: manager.createStub("parameter(parameter: Int?)", parameterMatchers: matchers))
|
||||||
|
}
|
||||||
|
|
||||||
|
func uParameter<M1: Cuckoo.Matchable>(parameter: M1) -> Cuckoo.StubNoReturnFunction<(Int?)> where M1.MatchedType == Int? {
|
||||||
|
let matchers: [Cuckoo.ParameterMatcher<(Int?)>] = [wrap(matchable: parameter) { $0 }]
|
||||||
|
return Cuckoo.StubNoReturnFunction(stub: manager.createStub("uParameter(parameter: Int!)", parameterMatchers: matchers))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct __VerificationProxy_ClassWithOptionals: Cuckoo.VerificationProxy {
|
||||||
|
private let manager: Cuckoo.MockManager
|
||||||
|
private let callMatcher: Cuckoo.CallMatcher
|
||||||
|
private let sourceLocation: Cuckoo.SourceLocation
|
||||||
|
|
||||||
|
init(manager: Cuckoo.MockManager, callMatcher: Cuckoo.CallMatcher, sourceLocation: Cuckoo.SourceLocation) {
|
||||||
|
self.manager = manager
|
||||||
|
self.callMatcher = callMatcher
|
||||||
|
self.sourceLocation = sourceLocation
|
||||||
|
}
|
||||||
|
|
||||||
|
var value: Cuckoo.VerifyProperty<Int?> {
|
||||||
|
return Cuckoo.VerifyProperty(manager: manager, name: "value", callMatcher: callMatcher, sourceLocation: sourceLocation)
|
||||||
|
}
|
||||||
|
|
||||||
|
var uValue: Cuckoo.VerifyProperty<Int?> {
|
||||||
|
return Cuckoo.VerifyProperty(manager: manager, name: "uValue", callMatcher: callMatcher, sourceLocation: sourceLocation)
|
||||||
|
}
|
||||||
|
|
||||||
|
var array: Cuckoo.VerifyProperty<[Int?]> {
|
||||||
|
return Cuckoo.VerifyProperty(manager: manager, name: "array", callMatcher: callMatcher, sourceLocation: sourceLocation)
|
||||||
|
}
|
||||||
|
|
||||||
|
var closure: Cuckoo.VerifyProperty<(Int?) -> Void> {
|
||||||
|
return Cuckoo.VerifyProperty(manager: manager, name: "closure", callMatcher: callMatcher, sourceLocation: sourceLocation)
|
||||||
|
}
|
||||||
|
|
||||||
|
var uClosure: Cuckoo.VerifyProperty<(Int?) -> Void> {
|
||||||
|
return Cuckoo.VerifyProperty(manager: manager, name: "uClosure", callMatcher: callMatcher, sourceLocation: sourceLocation)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
func returnValue() -> Cuckoo.__DoNotUse<Int?> {
|
||||||
|
return manager.verify("returnValue() -> Int?", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
func returnUValue() -> Cuckoo.__DoNotUse<Int?> {
|
||||||
|
return manager.verify("returnUValue() -> Int!", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
func returnArray() -> Cuckoo.__DoNotUse<[Int?]> {
|
||||||
|
return manager.verify("returnArray() -> [Int?]", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
func parameter<M1: Cuckoo.Matchable>(parameter: M1) -> Cuckoo.__DoNotUse<Void> where M1.MatchedType == Int? {
|
||||||
|
let matchers: [Cuckoo.ParameterMatcher<(Int?)>] = [wrap(matchable: parameter) { $0 }]
|
||||||
|
return manager.verify("parameter(parameter: Int?)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
|
||||||
|
}
|
||||||
|
|
||||||
|
@discardableResult
|
||||||
|
func uParameter<M1: Cuckoo.Matchable>(parameter: M1) -> Cuckoo.__DoNotUse<Void> where M1.MatchedType == Int? {
|
||||||
|
let matchers: [Cuckoo.ParameterMatcher<(Int?)>] = [wrap(matchable: parameter) { $0 }]
|
||||||
|
return manager.verify("uParameter(parameter: Int!)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ClassWithOptionalsStub: ClassWithOptionals {
|
||||||
|
|
||||||
|
override var value: Int? {
|
||||||
|
get {
|
||||||
|
return DefaultValueRegistry.defaultValue(for: (Int?).self)
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override var uValue: Int! {
|
||||||
|
get {
|
||||||
|
return DefaultValueRegistry.defaultValue(for: (Int!).self)
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override var array: [Int?] {
|
||||||
|
get {
|
||||||
|
return DefaultValueRegistry.defaultValue(for: ([Int?]).self)
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override var closure: (Int?) -> Void {
|
||||||
|
get {
|
||||||
|
return DefaultValueRegistry.defaultValue(for: ((Int?) -> Void).self)
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override var uClosure: (Int!) -> Void {
|
||||||
|
get {
|
||||||
|
return DefaultValueRegistry.defaultValue(for: ((Int!) -> Void).self)
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override func returnValue() -> Int? {
|
||||||
|
return DefaultValueRegistry.defaultValue(for: (Int?).self)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func returnUValue() -> Int! {
|
||||||
|
return DefaultValueRegistry.defaultValue(for: (Int!).self)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func returnArray() -> [Int?] {
|
||||||
|
return DefaultValueRegistry.defaultValue(for: ([Int?]).self)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func parameter(parameter: Int?) {
|
||||||
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
|
}
|
||||||
|
|
||||||
|
override func uParameter(parameter: Int!) {
|
||||||
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
|
}
|
||||||
|
}
|
|
@ -209,13 +209,13 @@ class TestedClassStub: TestedClass {
|
||||||
|
|
||||||
override var readOnlyProperty: String {
|
override var readOnlyProperty: String {
|
||||||
get {
|
get {
|
||||||
return DefaultValueRegistry.defaultValue(for: String.self)
|
return DefaultValueRegistry.defaultValue(for: (String).self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override var readWriteProperty: Int {
|
override var readWriteProperty: Int {
|
||||||
get {
|
get {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
}
|
}
|
||||||
|
@ -223,42 +223,42 @@ class TestedClassStub: TestedClass {
|
||||||
|
|
||||||
override var optionalProperty: Int? {
|
override var optionalProperty: Int? {
|
||||||
get {
|
get {
|
||||||
return DefaultValueRegistry.defaultValue(for: Optional<Int>.self)
|
return DefaultValueRegistry.defaultValue(for: (Int?).self)
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override func noReturn() {
|
override func noReturn() {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func count(characters: String) -> Int {
|
override func count(characters: String) -> Int {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func withThrows() throws -> Int {
|
override func withThrows() throws -> Int {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func withNoReturnThrows() throws {
|
override func withNoReturnThrows() throws {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func withClosure(_ closure: (String) -> Int) -> Int {
|
override func withClosure(_ closure: (String) -> Int) -> Int {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
|
override func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
|
override func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
override func withLabelAndUnderscore(labelA a: String, _ b: String) {
|
override func withLabelAndUnderscore(labelA a: String, _ b: String) {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,13 +473,13 @@ class TestedProtocolStub: TestedProtocol {
|
||||||
|
|
||||||
var readOnlyProperty: String {
|
var readOnlyProperty: String {
|
||||||
get {
|
get {
|
||||||
return DefaultValueRegistry.defaultValue(for: String.self)
|
return DefaultValueRegistry.defaultValue(for: (String).self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var readWriteProperty: Int {
|
var readWriteProperty: Int {
|
||||||
get {
|
get {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
}
|
}
|
||||||
|
@ -487,41 +487,41 @@ class TestedProtocolStub: TestedProtocol {
|
||||||
|
|
||||||
var optionalProperty: Int? {
|
var optionalProperty: Int? {
|
||||||
get {
|
get {
|
||||||
return DefaultValueRegistry.defaultValue(for: Optional<Int>.self)
|
return DefaultValueRegistry.defaultValue(for: (Int?).self)
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func noReturn() {
|
func noReturn() {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func count(characters: String) -> Int {
|
func count(characters: String) -> Int {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withThrows() throws -> Int {
|
func withThrows() throws -> Int {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withNoReturnThrows() throws {
|
func withNoReturnThrows() throws {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withClosure(_ closure: (String) -> Int) -> Int {
|
func withClosure(_ closure: (String) -> Int) -> Int {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
|
func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
|
func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withLabelAndUnderscore(labelA a: String, _ b: String) {
|
func withLabelAndUnderscore(labelA a: String, _ b: String) {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,13 +209,13 @@ class TestedProtocolStub: TestedProtocol {
|
||||||
|
|
||||||
var readOnlyProperty: String {
|
var readOnlyProperty: String {
|
||||||
get {
|
get {
|
||||||
return DefaultValueRegistry.defaultValue(for: String.self)
|
return DefaultValueRegistry.defaultValue(for: (String).self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var readWriteProperty: Int {
|
var readWriteProperty: Int {
|
||||||
get {
|
get {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
}
|
}
|
||||||
|
@ -223,41 +223,41 @@ class TestedProtocolStub: TestedProtocol {
|
||||||
|
|
||||||
var optionalProperty: Int? {
|
var optionalProperty: Int? {
|
||||||
get {
|
get {
|
||||||
return DefaultValueRegistry.defaultValue(for: Optional<Int>.self)
|
return DefaultValueRegistry.defaultValue(for: (Int?).self)
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func noReturn() {
|
func noReturn() {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func count(characters: String) -> Int {
|
func count(characters: String) -> Int {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withThrows() throws -> Int {
|
func withThrows() throws -> Int {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withNoReturnThrows() throws {
|
func withNoReturnThrows() throws {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withClosure(_ closure: (String) -> Int) -> Int {
|
func withClosure(_ closure: (String) -> Int) -> Int {
|
||||||
return DefaultValueRegistry.defaultValue(for: Int.self)
|
return DefaultValueRegistry.defaultValue(for: (Int).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
|
func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
|
func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withLabelAndUnderscore(labelA a: String, _ b: String) {
|
func withLabelAndUnderscore(labelA a: String, _ b: String) {
|
||||||
return DefaultValueRegistry.defaultValue(for: Void.self)
|
return DefaultValueRegistry.defaultValue(for: (Void).self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,10 @@ Feature: Generate command
|
||||||
When I run `runcuckoo generate --no-timestamp --output ClassWithInit.swift SourceFiles/ClassWithInit.swift`
|
When I run `runcuckoo generate --no-timestamp --output ClassWithInit.swift SourceFiles/ClassWithInit.swift`
|
||||||
Then the file "Expected/ClassWithInit.swift" should be equal to file "ClassWithInit.swift"
|
Then the file "Expected/ClassWithInit.swift" should be equal to file "ClassWithInit.swift"
|
||||||
|
|
||||||
|
Scenario: class with optionals
|
||||||
|
When I run `runcuckoo generate --no-timestamp --output ClassWithOptionals.swift SourceFiles/ClassWithOptionals.swift`
|
||||||
|
Then the file "Expected/ClassWithOptionals.swift" should be equal to file "ClassWithOptionals.swift"
|
||||||
|
|
||||||
Scenario: output not specified
|
Scenario: output not specified
|
||||||
When I run `runcuckoo generate --no-timestamp SourceFiles/TestedClass.swift SourceFiles/TestedProtocol.swift`
|
When I run `runcuckoo generate --no-timestamp SourceFiles/TestedClass.swift SourceFiles/TestedProtocol.swift`
|
||||||
Then the file "Expected/GeneratedMocks.swift" should be equal to file "GeneratedMocks.swift"
|
Then the file "Expected/GeneratedMocks.swift" should be equal to file "GeneratedMocks.swift"
|
||||||
|
@ -41,11 +45,11 @@ Feature: Generate command
|
||||||
# Not recorded tests
|
# Not recorded tests
|
||||||
|
|
||||||
Scenario: success
|
Scenario: success
|
||||||
When I run `runcuckoo generate SourceFiles/EmptyClass.swift`
|
When I run `runcuckoo generate --output Actual.swift SourceFiles/EmptyClass.swift`
|
||||||
Then the exit status should be 0
|
Then the exit status should be 0
|
||||||
|
|
||||||
Scenario: non existing input file
|
Scenario: non existing input file
|
||||||
When I run `runcuckoo generate non_existing_file.swift`
|
When I run `runcuckoo generate --output Actual.swift non_existing_file.swift`
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
Could not read contents of `non_existing_file.swift`
|
Could not read contents of `non_existing_file.swift`
|
||||||
|
@ -53,7 +57,7 @@ Feature: Generate command
|
||||||
And the exit status should be 1
|
And the exit status should be 1
|
||||||
|
|
||||||
Scenario: implicit instance variable type
|
Scenario: implicit instance variable type
|
||||||
When I run `runcuckoo generate SourceFiles/ImplicitInstanceVariableType.swift`
|
When I run `runcuckoo generate --output Actual.swift SourceFiles/ImplicitInstanceVariableType.swift`
|
||||||
Then the output should contain:
|
Then the output should contain:
|
||||||
"""
|
"""
|
||||||
Type of instance variable variable could not be inferred. Please specify it explicitly. (/Users/filip/Documents/Brightify/Cuckoo/Generator/Build/tmp/SourceFiles/ImplicitInstanceVariableType.swift)
|
Type of instance variable variable could not be inferred. Please specify it explicitly. (/Users/filip/Documents/Brightify/Cuckoo/Generator/Build/tmp/SourceFiles/ImplicitInstanceVariableType.swift)
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
//
|
||||||
|
// ClassWithOptionals.swift
|
||||||
|
// Cuckoo
|
||||||
|
//
|
||||||
|
// Created by Filip Dolnik on 18.12.16.
|
||||||
|
// Copyright © 2016 Brightify. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
class ClassWithOptionals {
|
||||||
|
|
||||||
|
var value: Int? = 0
|
||||||
|
|
||||||
|
var uValue: Int! = 0
|
||||||
|
|
||||||
|
var array: [Int?] = []
|
||||||
|
|
||||||
|
var closure: (Int?) -> Void = { _ in }
|
||||||
|
|
||||||
|
var uClosure: (Int!) -> Void = { _ in }
|
||||||
|
|
||||||
|
func returnValue() -> Int? {
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
|
||||||
|
func returnUValue() -> Int! {
|
||||||
|
return uValue
|
||||||
|
}
|
||||||
|
|
||||||
|
func returnArray() -> [Int?] {
|
||||||
|
return array
|
||||||
|
}
|
||||||
|
|
||||||
|
func parameter(parameter: Int?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
func uParameter(parameter: Int!) {
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,6 +7,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
class TestedClass {
|
class TestedClass {
|
||||||
|
|
||||||
let constant: Float = 0.0
|
let constant: Float = 0.0
|
||||||
|
|
||||||
var readOnlyProperty: String {
|
var readOnlyProperty: String {
|
||||||
|
@ -16,7 +17,7 @@ class TestedClass {
|
||||||
lazy var readWriteProperty: Int = 0
|
lazy var readWriteProperty: Int = 0
|
||||||
|
|
||||||
lazy var optionalProperty: Int? = 0
|
lazy var optionalProperty: Int? = 0
|
||||||
|
|
||||||
func noReturn() {
|
func noReturn() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
protocol TestedProtocol {
|
protocol TestedProtocol {
|
||||||
|
|
||||||
var readOnlyProperty: String { get }
|
var readOnlyProperty: String { get }
|
||||||
|
|
||||||
var readWriteProperty: Int { get set }
|
var readWriteProperty: Int { get set }
|
||||||
|
|
Loading…
Reference in New Issue