Compare commits

..

1 Commits

Author SHA1 Message Date
Matyáš Kříž 5bb308952e Add support for `NSObjectProtocol` in ObjC mocking. 2020-07-31 19:34:54 +02:00
177 changed files with 4441 additions and 4850 deletions

View File

@ -33,11 +33,13 @@ platform :mac do
def upload_release release_type def upload_release release_type
# Building Cuckoo Generator # Building Cuckoo Generator
sh('../build_generator') Dir.chdir('../Generator') do
sh('../build_generator')
end
# Settings # Settings
cuckoo_gen_path = '../Generator/.build/release/cuckoo_generator'
binary_name = 'cuckoo_generator' binary_name = 'cuckoo_generator'
cuckoo_gen_path = "../Generator/bin/#{binary_name}"
# GitHub username # GitHub username
username_var_name = 'GITHUB_USERNAME' username_var_name = 'GITHUB_USERNAME'
@ -49,10 +51,10 @@ platform :mac do
# Error Raisins # Error Raisins
unless access_token unless access_token
access_token = UI.input "Please type in your GitHub access token or cancel the release and define enviroment variable \"#{token_var_name}\" with the personal access token to use." access_token = UI.input "Please type in your GitHub access token or cancel the release and define enviroment variable \"#{token_var_name}\" with the personal access token to use."
end end
unless username unless username
username = UI.input "Please type in your GitHub username or cancel the release and define enviroment variable \"#{username_var_name}\" with your GitHub username." username = UI.input "Please type in your GitHub username or cancel the release and define enviroment variable \"#{username_var_name}\" with your GitHub username."
end end
@ -72,9 +74,7 @@ platform :mac do
push_to_git_remote push_to_git_remote
# https://developer.github.com/v3/repos/releases/#create-a-release # https://developer.github.com/v3/repos/releases/#create-a-release
release_title = "#{version}" creation_body = "'{\"tag_name\":\"#{version}\",\"target_commitish\":\"master\", \"name\":\"New Release #{version}\", \"body\":\"#{changelog}\", \"draft\":false, \"prerelease\":false}'"
release_body = "#{changelog}"
creation_body = "'{\"tag_name\":\"#{version}\",\"target_commitish\":\"master\", \"name\":\"#{release_title}\", \"body\":\"#{release_body}\", \"draft\":false, \"prerelease\":false}'"
creation_response = JSON.parse(`curl -X POST -d #{creation_body} -u #{auth_string} #{api_url} -v`) creation_response = JSON.parse(`curl -X POST -d #{creation_body} -u #{auth_string} #{api_url} -v`)
UI.crash! 'Release draft creation failed!' unless creation_response UI.crash! 'Release draft creation failed!' unless creation_response
upload_url = (creation_response['upload_url']).sub(/{.*name.*}/, '') upload_url = (creation_response['upload_url']).sub(/{.*name.*}/, '')
@ -98,11 +98,11 @@ platform :mac do
end end
after_all do after_all do
reset_git_repo(disregard_gitignore: false) reset_git_repo
end end
error do |_, exception| error do |_, exception|
reset_git_repo(disregard_gitignore: false) reset_git_repo
UI.error "Release failed. This might help: #{exception}" UI.error "Release failed. This might help: #{exception}"
end end
end end

26
.gitignore vendored
View File

@ -1,4 +1,5 @@
# Xcode # Xcode
#
.build/ .build/
build/ build/
*.pbxuser *.pbxuser
@ -18,11 +19,19 @@ DerivedData
*.xcuserstate *.xcuserstate
# CocoaPods # CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
Pods Pods
# Carthage # Carthage
Carthage/Build #
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build
.DS_Store .DS_Store
default.profraw default.profraw
Tests/**/Generated/*.swift Tests/**/Generated/*.swift
@ -31,20 +40,7 @@ Generator/*.app
# AppCode # AppCode
.idea/ .idea/
cuckoo_generator cuckoo_generator
.fastlane
Generator/CuckooGenerator.xcodeproj Generator/CuckooGenerator.xcodeproj
Cuckoo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist .fastlane
Cuckoo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Cuckoo.xcworkspace
Cuckoo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist Cuckoo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Tuist/Dependencies/graph.json
Tuist/Dependencies/Carthage
Tuist/Dependencies/SwiftPackageManager
Tuist/Dependencies/Cocoapods
Generator/Generator.xcodeproj
Generator/GeneratedMocks.swift

View File

@ -1,104 +0,0 @@
{
"pins" : [
{
"identity" : "commandant",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Carthage/Commandant.git",
"state" : {
"revision" : "07cad52573bad19d95844035bf0b25acddf6b0f6",
"version" : "0.15.0"
}
},
{
"identity" : "filekit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/nvzqz/FileKit.git",
"state" : {
"branch" : "develop",
"revision" : "6937ec38b0c383b0505caeea6603e62086bf5431"
}
},
{
"identity" : "nimble",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Nimble.git",
"state" : {
"revision" : "e9d769113660769a4d9dd3afb855562c0b7ae7b0",
"version" : "7.3.4"
}
},
{
"identity" : "pathkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/PathKit.git",
"state" : {
"revision" : "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version" : "1.0.1"
}
},
{
"identity" : "quick",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Quick/Quick.git",
"state" : {
"revision" : "f2b5a06440ea87eba1a167cab37bf6496646c52e",
"version" : "1.3.4"
}
},
{
"identity" : "result",
"kind" : "remoteSourceControl",
"location" : "https://github.com/antitypical/Result.git",
"state" : {
"revision" : "2ca499ba456795616fbc471561ff1d963e6ae160",
"version" : "4.1.0"
}
},
{
"identity" : "sourcekitten",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/SourceKitten.git",
"state" : {
"revision" : "79ca340f609adee48defa966e6a3dd0e0acbeb08",
"version" : "0.21.3"
}
},
{
"identity" : "spectre",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/Spectre.git",
"state" : {
"revision" : "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version" : "0.10.1"
}
},
{
"identity" : "stencil",
"kind" : "remoteSourceControl",
"location" : "https://github.com/kylef/Stencil.git",
"state" : {
"revision" : "ccd9402682f4c07dac9561befd207c8156e80e20",
"version" : "0.14.2"
}
},
{
"identity" : "swxmlhash",
"kind" : "remoteSourceControl",
"location" : "https://github.com/drmohundro/SWXMLHash.git",
"state" : {
"revision" : "f43166a8e18fdd0857f29e303b1bb79a5428bca0",
"version" : "4.9.0"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams.git",
"state" : {
"revision" : "b08dba4bcea978bf1ad37703a384097d3efce5af",
"version" : "1.0.2"
}
}
],
"version" : 2
}

View File

@ -1 +0,0 @@
3.11.0

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = "Cuckoo" s.name = "Cuckoo"
s.version = "1.10.3" s.version = "1.4.1"
s.summary = "Cuckoo - first boilerplate-free Swift mocking framework." s.summary = "Cuckoo - first boilerplate-free Swift mocking framework."
s.description = <<-DESC s.description = <<-DESC
Cuckoo is a mocking framework with an easy to use API (inspired by Mockito). Cuckoo is a mocking framework with an easy to use API (inspired by Mockito).
@ -15,8 +15,8 @@ Pod::Spec.new do |s|
:tag => s.version.to_s :tag => s.version.to_s
} }
s.ios.deployment_target = '9.0' s.ios.deployment_target = '8.0'
s.osx.deployment_target = '11.0' s.osx.deployment_target = '10.9'
#s.watchos.deployment_target = '2.0' # watchos does not include XCTest framework :( #s.watchos.deployment_target = '2.0' # watchos does not include XCTest framework :(
s.tvos.deployment_target = '9.0' s.tvos.deployment_target = '9.0'
generator_name = 'cuckoo_generator' generator_name = 'cuckoo_generator'
@ -31,7 +31,7 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = { s.pod_target_xcconfig = {
'ENABLE_BITCODE' => 'NO', 'ENABLE_BITCODE' => 'NO',
'SWIFT_REFLECTION_METADATA_LEVEL' => 'none', 'SWIFT_REFLECTION_METADATA_LEVEL' => 'none',
'OTHER_LDFLAGS' => '$(inherited) -weak-lXCTestSwiftSupport', 'OTHER_LDFLAGS' => '$(inherited) -weak-lswiftXCTest',
} }
s.default_subspec = 'Swift' s.default_subspec = 'Swift'
@ -49,6 +49,6 @@ Pod::Spec.new do |s|
s.subspec 'OCMock' do |sub| s.subspec 'OCMock' do |sub|
sub.source_files = 'OCMock/**/*.{h,m,swift}' sub.source_files = 'OCMock/**/*.{h,m,swift}'
sub.dependency 'Cuckoo/Swift' sub.dependency 'Cuckoo/Swift'
sub.dependency 'OCMock', '3.8.1' sub.dependency 'OCMock', '3.4.3'
end end
end end

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
</Workspace>

View File

@ -26,7 +26,8 @@
buildConfiguration = "Debug" buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"> shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES">
<Testables> <Testables>
<TestableReference <TestableReference
skipped = "NO"> skipped = "NO">

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "92C74015545203C1F4395DD4"
BuildableName = "Cuckoo_iOSTests.xctest"
BlueprintName = "Cuckoo-iOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "92C74015545203C1F4395DD4"
BuildableName = "Cuckoo_iOSTests.xctest"
BlueprintName = "Cuckoo-iOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
disableMainThreadChecker = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "92C74015545203C1F4395DD4"
BuildableName = "Cuckoo_iOSTests.xctest"
BlueprintName = "Cuckoo-iOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "92C74015545203C1F4395DD4"
BuildableName = "Cuckoo_iOSTests.xctest"
BlueprintName = "Cuckoo-iOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -26,7 +26,8 @@
buildConfiguration = "Debug" buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"> shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES">
<Testables> <Testables>
<TestableReference <TestableReference
skipped = "NO"> skipped = "NO">

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DBDB2DD4E7BE487EEB257CC8"
BuildableName = "Cuckoo_macOSTests.xctest"
BlueprintName = "Cuckoo-macOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DBDB2DD4E7BE487EEB257CC8"
BuildableName = "Cuckoo_macOSTests.xctest"
BlueprintName = "Cuckoo-macOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
disableMainThreadChecker = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DBDB2DD4E7BE487EEB257CC8"
BuildableName = "Cuckoo_macOSTests.xctest"
BlueprintName = "Cuckoo-macOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "DBDB2DD4E7BE487EEB257CC8"
BuildableName = "Cuckoo_macOSTests.xctest"
BlueprintName = "Cuckoo-macOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -26,7 +26,8 @@
buildConfiguration = "Debug" buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"> shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES">
<Testables> <Testables>
<TestableReference <TestableReference
skipped = "NO"> skipped = "NO">

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6AD4A9670FA783A1EC213000"
BuildableName = "Cuckoo_tvOSTests.xctest"
BlueprintName = "Cuckoo-tvOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6AD4A9670FA783A1EC213000"
BuildableName = "Cuckoo_tvOSTests.xctest"
BlueprintName = "Cuckoo-tvOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
disableMainThreadChecker = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6AD4A9670FA783A1EC213000"
BuildableName = "Cuckoo_tvOSTests.xctest"
BlueprintName = "Cuckoo-tvOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6AD4A9670FA783A1EC213000"
BuildableName = "Cuckoo_tvOSTests.xctest"
BlueprintName = "Cuckoo-tvOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "362F98B48959E1D7172FD65B"
BuildableName = "Cuckoo_OCMock_iOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-iOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "362F98B48959E1D7172FD65B"
BuildableName = "Cuckoo_OCMock_iOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-iOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
disableMainThreadChecker = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "362F98B48959E1D7172FD65B"
BuildableName = "Cuckoo_OCMock_iOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-iOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "362F98B48959E1D7172FD65B"
BuildableName = "Cuckoo_OCMock_iOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-iOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D9ED40B0DCFD564F7B741F"
BuildableName = "Cuckoo_OCMock_macOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-macOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D9ED40B0DCFD564F7B741F"
BuildableName = "Cuckoo_OCMock_macOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-macOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
disableMainThreadChecker = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D9ED40B0DCFD564F7B741F"
BuildableName = "Cuckoo_OCMock_macOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-macOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D1D9ED40B0DCFD564F7B741F"
BuildableName = "Cuckoo_OCMock_macOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-macOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,96 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1010"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "05F906FDC36D67A5E1CB8CF6"
BuildableName = "Cuckoo_OCMock_tvOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-tvOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
disableMainThreadChecker = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "05F906FDC36D67A5E1CB8CF6"
BuildableName = "Cuckoo_OCMock_tvOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-tvOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES"
disableMainThreadChecker = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "05F906FDC36D67A5E1CB8CF6"
BuildableName = "Cuckoo_OCMock_tvOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-tvOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<CommandLineArguments>
</CommandLineArguments>
<EnvironmentVariables>
</EnvironmentVariables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "05F906FDC36D67A5E1CB8CF6"
BuildableName = "Cuckoo_OCMock_tvOSTests.xctest"
BlueprintName = "Cuckoo_OCMock-tvOSTests"
ReferencedContainer = "container:Cuckoo.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -1,280 +1,208 @@
GEM GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
CFPropertyList (3.0.5) CFPropertyList (3.0.1)
rexml activesupport (4.2.11.1)
activesupport (6.1.4.1) i18n (~> 0.7)
concurrent-ruby (~> 1.0, >= 1.0.2) minitest (~> 5.1)
i18n (>= 1.6, < 2) thread_safe (~> 0.3, >= 0.3.4)
minitest (>= 5.1) tzinfo (~> 1.1)
tzinfo (~> 2.0) addressable (2.7.0)
zeitwerk (~> 2.3)
addressable (2.8.0)
public_suffix (>= 2.0.2, < 5.0) public_suffix (>= 2.0.2, < 5.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
artifactory (3.0.15)
atomos (0.1.3) atomos (0.1.3)
aws-eventstream (1.2.0) babosa (1.0.3)
aws-partitions (1.600.0) claide (1.0.3)
aws-sdk-core (3.131.2) cocoapods (1.7.5)
aws-eventstream (~> 1, >= 1.0.2) activesupport (>= 4.0.2, < 5)
aws-partitions (~> 1, >= 1.525.0)
aws-sigv4 (~> 1.1)
jmespath (~> 1, >= 1.6.1)
aws-sdk-kms (1.57.0)
aws-sdk-core (~> 3, >= 3.127.0)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.114.0)
aws-sdk-core (~> 3, >= 3.127.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.4)
aws-sigv4 (1.5.0)
aws-eventstream (~> 1, >= 1.0.2)
babosa (1.0.4)
claide (1.1.0)
cocoapods (1.11.2)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0) claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.11.2) cocoapods-core (= 1.7.5)
cocoapods-deintegrate (>= 1.0.3, < 2.0) cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.4.0, < 2.0) cocoapods-downloader (>= 1.2.2, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0) cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0) cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.4.0, < 2.0) cocoapods-stats (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.3.1, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0) cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1) colored2 (~> 3.1)
escape (~> 0.0.4) escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0) fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0) gh_inspector (~> 1.0)
molinillo (~> 0.8.0) molinillo (~> 0.6.6)
nap (~> 1.0) nap (~> 1.0)
ruby-macho (>= 1.0, < 3.0) ruby-macho (~> 1.4)
xcodeproj (>= 1.21.0, < 2.0) xcodeproj (>= 1.10.0, < 2.0)
cocoapods-core (1.11.2) cocoapods-core (1.7.5)
activesupport (>= 5.0, < 7) activesupport (>= 4.0.2, < 6)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4) fuzzy_match (~> 2.0.4)
nap (~> 1.0) nap (~> 1.0)
netrc (~> 0.11) cocoapods-deintegrate (1.0.4)
public_suffix (~> 4.0) cocoapods-downloader (1.2.2)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.5.1)
cocoapods-plugins (1.0.0) cocoapods-plugins (1.0.0)
nap nap
cocoapods-search (1.0.1) cocoapods-search (1.0.0)
cocoapods-trunk (1.6.0) cocoapods-stats (1.1.0)
cocoapods-trunk (1.4.0)
nap (>= 0.8, < 2.0) nap (>= 0.8, < 2.0)
netrc (~> 0.11) netrc (~> 0.11)
cocoapods-try (1.2.0) cocoapods-try (1.1.0)
colored (1.2) colored (1.2)
colored2 (3.1.2) colored2 (3.1.2)
commander (4.6.0) commander-fastlane (4.4.6)
highline (~> 2.0.0) highline (~> 1.7.2)
concurrent-ruby (1.1.9) concurrent-ruby (1.1.5)
declarative (0.0.20) declarative (0.0.10)
digest-crc (0.6.4) declarative-option (0.1.0)
rake (>= 12.0.0, < 14.0.0) digest-crc (0.4.1)
domain_name (0.5.20190701) domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0) unf (>= 0.0.5, < 1.0.0)
dotenv (2.7.6) dotenv (2.7.5)
emoji_regex (3.2.3) emoji_regex (1.0.1)
escape (0.0.4) escape (0.0.4)
ethon (0.15.0) excon (0.71.0)
ffi (>= 1.15.0) faraday (0.17.0)
excon (0.92.3) multipart-post (>= 1.2, < 3)
faraday (1.10.0) faraday-cookie_jar (0.0.6)
faraday-em_http (~> 1.0) faraday (>= 0.7.4)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-cookie_jar (0.0.7)
faraday (>= 0.8.0)
http-cookie (~> 1.0.0) http-cookie (~> 1.0.0)
faraday-em_http (1.0.0) faraday_middleware (0.13.1)
faraday-em_synchrony (1.0.0) faraday (>= 0.7.4, < 1.0)
faraday-excon (1.1.0) fastimage (2.1.7)
faraday-httpclient (1.0.1) fastlane (2.134.0)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
faraday_middleware (1.2.0)
faraday (~> 1.0)
fastimage (2.2.6)
fastlane (2.206.2)
CFPropertyList (>= 2.3, < 4.0.0) CFPropertyList (>= 2.3, < 4.0.0)
addressable (>= 2.8, < 3.0.0) addressable (>= 2.3, < 3.0.0)
artifactory (~> 3.0) babosa (>= 1.0.2, < 2.0.0)
aws-sdk-s3 (~> 1.0)
babosa (>= 1.0.3, < 2.0.0)
bundler (>= 1.12.0, < 3.0.0) bundler (>= 1.12.0, < 3.0.0)
colored colored
commander (~> 4.6) commander-fastlane (>= 4.4.6, < 5.0.0)
dotenv (>= 2.1.1, < 3.0.0) dotenv (>= 2.1.1, < 3.0.0)
emoji_regex (>= 0.1, < 4.0) emoji_regex (>= 0.1, < 2.0)
excon (>= 0.71.0, < 1.0.0) excon (>= 0.45.0, < 1.0.0)
faraday (~> 1.0) faraday (~> 0.17)
faraday-cookie_jar (~> 0.0.6) faraday-cookie_jar (~> 0.0.6)
faraday_middleware (~> 1.0) faraday_middleware (~> 0.13.1)
fastimage (>= 2.1.0, < 3.0.0) fastimage (>= 2.1.0, < 3.0.0)
gh_inspector (>= 1.1.2, < 2.0.0) gh_inspector (>= 1.1.2, < 2.0.0)
google-apis-androidpublisher_v3 (~> 0.3) google-api-client (>= 0.21.2, < 0.24.0)
google-apis-playcustomapp_v1 (~> 0.1) google-cloud-storage (>= 1.15.0, < 2.0.0)
google-cloud-storage (~> 1.31) highline (>= 1.7.2, < 2.0.0)
highline (~> 2.0)
json (< 3.0.0) json (< 3.0.0)
jwt (>= 2.1.0, < 3) jwt (~> 2.1.0)
mini_magick (>= 4.9.4, < 5.0.0) mini_magick (>= 4.9.4, < 5.0.0)
multi_xml (~> 0.5)
multipart-post (~> 2.0.0) multipart-post (~> 2.0.0)
naturally (~> 2.2)
optparse (~> 0.1.1)
plist (>= 3.1.0, < 4.0.0) plist (>= 3.1.0, < 4.0.0)
rubyzip (>= 2.0.0, < 3.0.0) public_suffix (~> 2.0.0)
rubyzip (>= 1.3.0, < 2.0.0)
security (= 0.1.3) security (= 0.1.3)
simctl (~> 1.6.3) simctl (~> 1.6.3)
slack-notifier (>= 2.0.0, < 3.0.0)
terminal-notifier (>= 2.0.0, < 3.0.0) terminal-notifier (>= 2.0.0, < 3.0.0)
terminal-table (>= 1.4.5, < 2.0.0) terminal-table (>= 1.4.5, < 2.0.0)
tty-screen (>= 0.6.3, < 1.0.0) tty-screen (>= 0.6.3, < 1.0.0)
tty-spinner (>= 0.8.0, < 1.0.0) tty-spinner (>= 0.8.0, < 1.0.0)
word_wrap (~> 1.0.0) word_wrap (~> 1.0.0)
xcodeproj (>= 1.13.0, < 2.0.0) xcodeproj (>= 1.8.1, < 2.0.0)
xcpretty (~> 0.3.0) xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3) xcpretty-travis-formatter (>= 0.0.3)
ffi (1.15.4)
fourflusher (2.3.1) fourflusher (2.3.1)
fuzzy_match (2.0.4) fuzzy_match (2.0.4)
gh_inspector (1.1.3) gh_inspector (1.1.3)
google-apis-androidpublisher_v3 (0.22.0) google-api-client (0.23.9)
google-apis-core (>= 0.5, < 2.a)
google-apis-core (0.6.0)
addressable (~> 2.5, >= 2.5.1) addressable (~> 2.5, >= 2.5.1)
googleauth (>= 0.16.2, < 2.a) googleauth (>= 0.5, < 0.7.0)
httpclient (>= 2.8.1, < 3.a) httpclient (>= 2.8.1, < 3.0)
mini_mime (~> 1.0) mime-types (~> 3.0)
representable (~> 3.0) representable (~> 3.0)
retriable (>= 2.0, < 4.a) retriable (>= 2.0, < 4.0)
rexml signet (~> 0.9)
webrick google-cloud-core (1.4.1)
google-apis-iamcredentials_v1 (0.12.0)
google-apis-core (>= 0.6, < 2.a)
google-apis-playcustomapp_v1 (0.9.0)
google-apis-core (>= 0.6, < 2.a)
google-apis-storage_v1 (0.15.0)
google-apis-core (>= 0.5, < 2.a)
google-cloud-core (1.6.0)
google-cloud-env (~> 1.0) google-cloud-env (~> 1.0)
google-cloud-errors (~> 1.0) google-cloud-env (1.3.0)
google-cloud-env (1.6.0) faraday (~> 0.11)
faraday (>= 0.17.3, < 3.0) google-cloud-storage (1.16.0)
google-cloud-errors (1.2.0)
google-cloud-storage (1.36.2)
addressable (~> 2.8)
digest-crc (~> 0.4) digest-crc (~> 0.4)
google-apis-iamcredentials_v1 (~> 0.1) google-api-client (~> 0.23)
google-apis-storage_v1 (~> 0.1) google-cloud-core (~> 1.2)
google-cloud-core (~> 1.6) googleauth (>= 0.6.2, < 0.10.0)
googleauth (>= 0.16.2, < 2.a) googleauth (0.6.7)
mini_mime (~> 1.0) faraday (~> 0.12)
googleauth (1.1.3)
faraday (>= 0.17.3, < 3.a)
jwt (>= 1.4, < 3.0) jwt (>= 1.4, < 3.0)
memoist (~> 0.16) memoist (~> 0.16)
multi_json (~> 1.11) multi_json (~> 1.11)
os (>= 0.9, < 2.0) os (>= 0.9, < 2.0)
signet (>= 0.16, < 2.a) signet (~> 0.7)
highline (2.0.3) highline (1.7.10)
http-cookie (1.0.5) http-cookie (1.0.3)
domain_name (~> 0.5) domain_name (~> 0.5)
httpclient (2.8.3) httpclient (2.8.3)
i18n (1.8.11) i18n (0.9.5)
concurrent-ruby (~> 1.0) concurrent-ruby (~> 1.0)
jmespath (1.6.1) json (2.3.0)
json (2.6.2) jwt (2.1.0)
jwt (2.4.1) memoist (0.16.0)
memoist (0.16.2) mime-types (3.3)
mini_magick (4.11.0) mime-types-data (~> 3.2015)
mini_mime (1.1.2) mime-types-data (3.2019.1009)
minitest (5.14.4) mini_magick (4.9.5)
molinillo (0.8.0) minitest (5.11.3)
multi_json (1.15.0) molinillo (0.6.6)
multi_json (1.14.1)
multi_xml (0.6.0)
multipart-post (2.0.0) multipart-post (2.0.0)
nanaimo (0.3.0) nanaimo (0.2.6)
nap (1.1.0) nap (1.1.0)
naturally (2.2.1) naturally (2.2.0)
netrc (0.11.0) netrc (0.11.0)
optparse (0.1.1) os (1.0.1)
os (1.1.4) plist (3.5.0)
plist (3.6.0) public_suffix (2.0.5)
public_suffix (4.0.7) representable (3.0.4)
rake (13.0.6)
representable (3.2.0)
declarative (< 0.1.0) declarative (< 0.1.0)
trailblazer-option (>= 0.1.1, < 0.2.0) declarative-option (< 0.2.0)
uber (< 0.2.0) uber (< 0.2.0)
retriable (3.1.2) retriable (3.1.2)
rexml (3.2.5)
rouge (2.0.7) rouge (2.0.7)
ruby-macho (2.5.1) ruby-macho (1.4.0)
ruby2_keywords (0.0.5) rubyzip (1.3.0)
rubyzip (2.3.2)
security (0.1.3) security (0.1.3)
signet (0.16.1) signet (0.12.0)
addressable (~> 2.8) addressable (~> 2.3)
faraday (>= 0.17.5, < 3.0) faraday (~> 0.9)
jwt (>= 1.5, < 3.0) jwt (>= 1.5, < 3.0)
multi_json (~> 1.10) multi_json (~> 1.10)
simctl (1.6.8) simctl (1.6.6)
CFPropertyList CFPropertyList
naturally naturally
slack-notifier (2.3.2)
terminal-notifier (2.0.0) terminal-notifier (2.0.0)
terminal-table (1.8.0) terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1) unicode-display_width (~> 1.1, >= 1.1.1)
trailblazer-option (0.1.2) thread_safe (0.3.6)
tty-cursor (0.7.1) tty-cursor (0.7.0)
tty-screen (0.8.1) tty-screen (0.7.0)
tty-spinner (0.9.3) tty-spinner (0.9.1)
tty-cursor (~> 0.7) tty-cursor (~> 0.7)
typhoeus (1.4.0) tzinfo (1.2.5)
ethon (>= 0.9.0) thread_safe (~> 0.1)
tzinfo (2.0.4)
concurrent-ruby (~> 1.0)
uber (0.1.0) uber (0.1.0)
unf (0.1.4) unf (0.1.4)
unf_ext unf_ext
unf_ext (0.0.8.2) unf_ext (0.0.7.6)
unicode-display_width (1.8.0) unicode-display_width (1.6.0)
webrick (1.7.0)
word_wrap (1.0.0) word_wrap (1.0.0)
xcodeproj (1.21.0) xcodeproj (1.13.0)
CFPropertyList (>= 2.3.3, < 4.0) CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3) atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0) claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1) colored2 (~> 3.1)
nanaimo (~> 0.3.0) nanaimo (~> 0.2.6)
rexml (~> 3.2.4)
xcpretty (0.3.0) xcpretty (0.3.0)
rouge (~> 2.0.7) rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1) xcpretty-travis-formatter (1.0.0)
xcpretty (~> 0.2, >= 0.0.7) xcpretty (~> 0.2, >= 0.0.7)
zeitwerk (2.5.1)
PLATFORMS PLATFORMS
arm64-darwin-21 ruby
DEPENDENCIES DEPENDENCIES
cocoapods cocoapods
@ -282,4 +210,4 @@ DEPENDENCIES
json json
BUNDLED WITH BUNDLED WITH
2.2.32 1.17.3

72
Generator/Package.pins Normal file
View File

@ -0,0 +1,72 @@
{
"autoPin": true,
"pins": [
{
"package": "Clang_C",
"reason": null,
"repositoryURL": "https://github.com/norio-nomura/Clang_C.git",
"version": "1.0.2"
},
{
"package": "Commandant",
"reason": null,
"repositoryURL": "https://github.com/Carthage/Commandant.git",
"version": "0.12.0"
},
{
"package": "FileKit",
"reason": null,
"repositoryURL": "https://github.com/TadeasKriz/FileKit.git",
"version": "4.0.2"
},
{
"package": "PathKit",
"reason": null,
"repositoryURL": "https://github.com/kylef/PathKit.git",
"version": "0.8.0"
},
{
"package": "Result",
"reason": null,
"repositoryURL": "https://github.com/antitypical/Result.git",
"version": "3.2.1"
},
{
"package": "SWXMLHash",
"reason": null,
"repositoryURL": "https://github.com/drmohundro/SWXMLHash.git",
"version": "3.0.4"
},
{
"package": "SourceKit",
"reason": null,
"repositoryURL": "https://github.com/norio-nomura/SourceKit.git",
"version": "1.0.1"
},
{
"package": "SourceKitten",
"reason": null,
"repositoryURL": "https://github.com/jpsim/SourceKitten.git",
"version": "0.17.2"
},
{
"package": "Spectre",
"reason": null,
"repositoryURL": "https://github.com/kylef/Spectre.git",
"version": "0.7.2"
},
{
"package": "Stencil",
"reason": null,
"repositoryURL": "https://github.com/kylef/Stencil.git",
"version": "0.8.0"
},
{
"package": "Yams",
"reason": null,
"repositoryURL": "https://github.com/jpsim/Yams.git",
"version": "0.3.2"
}
],
"version": 1
}

106
Generator/Package.resolved Normal file
View File

@ -0,0 +1,106 @@
{
"object": {
"pins": [
{
"package": "Commandant",
"repositoryURL": "https://github.com/Carthage/Commandant.git",
"state": {
"branch": null,
"revision": "07cad52573bad19d95844035bf0b25acddf6b0f6",
"version": "0.15.0"
}
},
{
"package": "FileKit",
"repositoryURL": "https://github.com/nvzqz/FileKit.git",
"state": {
"branch": "develop",
"revision": "48b5ddb287f131a5c628badc819b880453f94449",
"version": null
}
},
{
"package": "Nimble",
"repositoryURL": "https://github.com/Quick/Nimble.git",
"state": {
"branch": null,
"revision": "e9d769113660769a4d9dd3afb855562c0b7ae7b0",
"version": "7.3.4"
}
},
{
"package": "PathKit",
"repositoryURL": "https://github.com/kylef/PathKit.git",
"state": {
"branch": null,
"revision": "e2f5be30e4c8f531c9c1e8765aa7b71c0a45d7a0",
"version": "0.9.2"
}
},
{
"package": "Quick",
"repositoryURL": "https://github.com/Quick/Quick.git",
"state": {
"branch": null,
"revision": "f2b5a06440ea87eba1a167cab37bf6496646c52e",
"version": "1.3.4"
}
},
{
"package": "Result",
"repositoryURL": "https://github.com/antitypical/Result.git",
"state": {
"branch": null,
"revision": "2ca499ba456795616fbc471561ff1d963e6ae160",
"version": "4.1.0"
}
},
{
"package": "SourceKitten",
"repositoryURL": "https://github.com/jpsim/SourceKitten.git",
"state": {
"branch": null,
"revision": "79ca340f609adee48defa966e6a3dd0e0acbeb08",
"version": "0.21.3"
}
},
{
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "f14ff47f45642aa5703900980b014c2e9394b6e5",
"version": "0.9.0"
}
},
{
"package": "Stencil",
"repositoryURL": "https://github.com/kylef/Stencil.git",
"state": {
"branch": null,
"revision": "0e9a78d6584e3812cd9c09494d5c7b483e8f533c",
"version": "0.13.1"
}
},
{
"package": "SWXMLHash",
"repositoryURL": "https://github.com/drmohundro/SWXMLHash.git",
"state": {
"branch": null,
"revision": "f43166a8e18fdd0857f29e303b1bb79a5428bca0",
"version": "4.9.0"
}
},
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams.git",
"state": {
"branch": null,
"revision": "b08dba4bcea978bf1ad37703a384097d3efce5af",
"version": "1.0.2"
}
}
]
},
"version": 1
}

24
Generator/Package.swift Normal file
View File

@ -0,0 +1,24 @@
// swift-tools-version:4.2
import PackageDescription
let package = Package(
name: "CuckooGenerator",
products: [
.library(name: "CuckooGeneratorFramework", targets:["CuckooGeneratorFramework", "cuckoo_generator"]),
.executable(name: "cuckoo_generator", targets: ["cuckoo_generator"])
],
dependencies: [
.package(url: "https://github.com/jpsim/SourceKitten.git", .upToNextMinor(from: "0.21.2")),
.package(url: "https://github.com/nvzqz/FileKit.git", .branch("develop")),
.package(url: "https://github.com/kylef/Stencil.git", from: "0.13.1"),
.package(url: "https://github.com/Carthage/Commandant.git", from: "0.12.0")
],
targets: [
.target(name: "CuckooGeneratorFramework", dependencies: [
"FileKit", "SourceKittenFramework", "Stencil", "Commandant"], exclude: ["Tests"]),
.target(name: "cuckoo_generator", dependencies: [
.target(name: "CuckooGeneratorFramework")], exclude: ["Tests"]),
]
)

View File

@ -1,56 +0,0 @@
import ProjectDescription
import ProjectDescriptionHelpers
// MARK: project definition
let project = Project(
name: "Generator",
options: .options(automaticSchemesOptions: .disabled, disableSynthesizedResourceAccessors: true),
packages: [
.package(url: "https://github.com/jpsim/SourceKitten.git", .upToNextMinor(from: "0.21.2")),
.package(url: "https://github.com/nvzqz/FileKit.git", .branch("develop")),
.package(url: "https://github.com/kylef/Stencil.git", .exact("0.14.2")),
.package(url: "https://github.com/Carthage/Commandant.git", .exact("0.15.0")),
],
targets: [
Target(
name: "CuckooGenerator",
platform: .macOS,
product: .commandLineTool,
productName: "cuckoo_generator",
bundleId: "CuckooGenerator",
deploymentTarget: DeploymentTarget.macOS(targetVersion: "10.13"),
sources: "Source/**",
dependencies: ["FileKit", "SourceKittenFramework", "Stencil", "Commandant"].map(TargetDependency.package(product:))
),
],
schemes: [
Scheme(
name: "Generator",
buildAction: BuildAction.buildAction(
targets: ["CuckooGenerator"],
postActions: [
ExecutionAction(
title: "Copy executable",
scriptText: #"\cp "$BUILT_PRODUCTS_DIR/$EXECUTABLE_NAME" "$PROJECT_DIR/bin/cuckoo_generator""#,
target: "CuckooGenerator"
)
],
runPostActionsOnFailure: false
),
runAction: RunAction.runAction(
executable: "CuckooGenerator",
arguments: Arguments(
launchArguments: [
// Any changes here should be reflected in `../Project.swift` as well.
LaunchArgument(name: "generate", isEnabled: true),
LaunchArgument(name: "--testable Cuckoo", isEnabled: true),
LaunchArgument(name: "--exclude ExcludedTestClass,ExcludedProtocol", isEnabled: true),
LaunchArgument(name: #"--output "$PROJECT_DIR"/GeneratedMocks.swift"#, isEnabled: true),
// This is the input file(s) glob.
LaunchArgument(name: #"--glob "$PROJECT_DIR"/../Tests/Swift/Source/*.swift"#, isEnabled: true),
]
)
)
),
]
)

View File

@ -0,0 +1,36 @@
//
// CodeBuilder.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 06.07.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public class CodeBuilder {
fileprivate static let Tab = " "
public fileprivate(set) var code = ""
fileprivate var nesting = 0
public func clear() {
code = ""
}
public func nest(_ closure: () -> ()) {
nesting += 1
closure()
nesting -= 1
}
public func nest(_ line: String) {
nest { self += line }
}
}
public func +=(left: CodeBuilder, right: String) {
(0..<left.nesting).forEach { _ in left.code += CodeBuilder.Tab }
left.code += right
left.code += "\n"
}

View File

@ -1,3 +1,11 @@
//
// FileHeaderHandler.swift
// CuckooGenerator
//
// Created by Tadeas Kriz on 12/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Foundation import Foundation
import FileKit import FileKit

View File

@ -1,14 +1,26 @@
//
// Generator.swift
// CuckooGenerator
//
// Created by Tadeas Kriz on 13/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Foundation import Foundation
import Stencil import Stencil
public struct Generator { public struct Generator {
private let declarations: [Token] private let declarations: [Token]
private let code = CodeBuilder()
public init(file: FileRepresentation) { public init(file: FileRepresentation) {
declarations = file.declarations declarations = file.declarations
} }
public func generate(debug: Bool = false) throws -> String { public func generate(debug: Bool = false) throws -> String {
code.clear()
let ext = Extension() let ext = Extension()
ext.registerFilter("genericSafe") { (value: Any?) in ext.registerFilter("genericSafe") { (value: Any?) in
guard let string = value as? String else { return value } guard let string = value as? String else { return value }
@ -45,22 +57,10 @@ public struct Generator {
return self.closeNestedClosure(for: parameters) return self.closeNestedClosure(for: parameters)
} }
ext.registerFilter("escapeReservedKeywords") { (value: Any?) in
guard let name = value as? String else { return value }
return escapeReservedKeywords(for: name)
}
ext.registerFilter("removeClosureArgumentNames") { (value: Any?) in
guard let type = value as? String else { return value }
return self.removeClosureArgumentNames(for: type)
}
let environment = Environment(extensions: [ext]) let environment = Environment(extensions: [ext])
let containers = declarations.compactMap { $0 as? ContainerToken } let containers = declarations.compactMap { $0 as? ContainerToken }
.filter { .filter { $0.accessibility.isAccessible }
$0.parent?.areAllHierarchiesAccessible ?? true && $0.accessibility.isAccessible
}
.map { $0.serializeWithType() } .map { $0.serializeWithType() }
return try environment.renderTemplate(string: Templates.mock, context: ["containers": containers, "debug": debug]) return try environment.renderTemplate(string: Templates.mock, context: ["containers": containers, "debug": debug])
@ -98,13 +98,7 @@ public struct Generator {
guard parameters.isEmpty == false else { return "let matchers: [Cuckoo.ParameterMatcher<Void>] = []" } guard parameters.isEmpty == false else { return "let matchers: [Cuckoo.ParameterMatcher<Void>] = []" }
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 { index, parameter in
let name = escapeReservedKeywords(for: parameter.name)
return "wrap(matchable: \(name)) { $0\(parameters.count > 1 ? ".\(index)" : "") }"
}
.joined(separator: ", ")
return "let matchers: [Cuckoo.ParameterMatcher<(\(genericSafeType(from: tupleType)))>] = [\(matchers)]" return "let matchers: [Cuckoo.ParameterMatcher<(\(genericSafeType(from: tupleType)))>] = [\(matchers)]"
} }
@ -118,7 +112,6 @@ public struct Generator {
if parameter.isClosure && !parameter.isEscaping { if parameter.isClosure && !parameter.isEscaping {
let indents = String(repeating: "\t", count: index) let indents = String(repeating: "\t", count: index)
let tries = method.isThrowing ? "try " : "" let tries = method.isThrowing ? "try " : ""
let awaits = method.isAsync ? "await " : ""
let sugarizedReturnType = method.returnType.sugarized let sugarizedReturnType = method.returnType.sugarized
let returnSignature: String let returnSignature: String
@ -128,7 +121,7 @@ public struct Generator {
returnSignature = " -> \(sugarizedReturnType)" returnSignature = " -> \(sugarizedReturnType)"
} }
fullString += "\(indents)return \(tries)\(awaits)withoutActuallyEscaping(\(parameter.name), do: { (\(parameter.name): @escaping \(parameter.type))\(returnSignature) in\n" fullString += "\(indents)return \(tries)withoutActuallyEscaping(\(parameter.name), do: { (\(parameter.name): @escaping \(parameter.type))\(returnSignature) in\n"
} }
} }
@ -145,12 +138,4 @@ public struct Generator {
} }
return fullString return fullString
} }
private func removeClosureArgumentNames(for type: String) -> String {
type.replacingOccurrences(
of: "_\\s+?[_a-zA-Z]\\w*?\\s*?:",
with: "",
options: .regularExpression
)
}
} }

View File

@ -1,3 +1,11 @@
//
// StderrPrint.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 18.12.16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Foundation import Foundation
public private(set) var stderrUsed = false public private(set) var stderrUsed = false

View File

@ -0,0 +1,17 @@
//
// CuckooGeneratorFramework.h
// CuckooGeneratorFramework
//
// Created by Tadeas Kriz on 13/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
#import <Foundation/Foundation.h>
//! Project version number for CuckooGeneratorFramework.
FOUNDATION_EXPORT double CuckooGeneratorFrameworkVersionNumber;
//! Project version string for CuckooGeneratorFramework.
FOUNDATION_EXPORT const unsigned char CuckooGeneratorFrameworkVersionString[];
// In this header, you should import all the public headers of your framework using statements like #import <CuckooGeneratorFramework/PublicHeader.h>

View File

@ -3,7 +3,7 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string> <string>en</string>
<key>CFBundleExecutable</key> <key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string> <string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
@ -12,11 +12,17 @@
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string> <string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.0</string> <string>0.8.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>1</string> <string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Copyright ©. All rights reserved.</string> <string>Copyright © 2016 Brightify. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict> </dict>
</plist> </plist>

View File

@ -1,3 +1,10 @@
//
// MockTemplate.swift
// CuckooGeneratorFramework
//
// Created by Tadeas Kriz on 11/14/17.
//
import Foundation import Foundation
extension Templates { extension Templates {
@ -5,18 +12,10 @@ extension Templates {
static let typeErasureClassName = "DefaultImplCaller" static let typeErasureClassName = "DefaultImplCaller"
static let mock = """ static let mock = """
{% for container in containers %} {% for container in containers %}
{% if debug %}
// {{ container }}
{% endif %}
{{ container.unavailablePlatformsCheck }}
{% for attribute in container.attributes %} {% for attribute in container.attributes %}
{{ attribute.text }} {{ attribute.text }}
{% endfor %} {% endfor %}
{% if container.hasParent %} {{ container.accessibility }} class {{ container.mockName }}{{ container.genericParameters }}: {{ container.name }}{% if container.isImplementation %}{{ container.genericArguments }}{% endif %}, {% if container.isImplementation %}Cuckoo.ClassMock{% else %}Cuckoo.ProtocolMock{% endif %} {
extension {{ container.parentFullyQualifiedName }} {
{% endif %}
{{ container.accessibility }} class {{ container.mockName }}{{ container.genericParameters }}: {% if container.isNSObjectProtocol %}NSObject, {% endif %}{{ container.name }}{% if container.isImplementation %}{{ container.genericArguments }}{% endif %}, {% if container.isImplementation %}Cuckoo.ClassMock{% else %}Cuckoo.ProtocolMock{% endif %} {
{% if container.isGeneric and not container.isImplementation %} {% if container.isGeneric and not container.isImplementation %}
{{ container.accessibility }} typealias MocksType = \(typeErasureClassName){{ container.genericArguments }} {{ container.accessibility }} typealias MocksType = \(typeErasureClassName){{ container.genericArguments }}
{% else %} {% else %}
@ -52,7 +51,6 @@ extension {{ container.parentFullyQualifiedName }} {
{% endif %} {% endif %}
{% for property in container.properties %} {% for property in container.properties %}
{{ property.unavailablePlatformsCheck }}
{% if debug %} {% if debug %}
// {{property}} // {{property}}
{% endif %} {% endif %}
@ -60,15 +58,15 @@ extension {{ container.parentFullyQualifiedName }} {
{{ attribute.text }} {{ attribute.text }}
{% endfor %} {% endfor %}
{{ property.accessibility }}{% if container.isImplementation %} override{% endif %} var {{ property.name }}: {{ property.type }} { {{ property.accessibility }}{% if container.isImplementation %} override{% endif %} var {{ property.name }}: {{ property.type }} {
get{% if property.isAsync %} async{% endif %}{% if property.isThrowing %} throws{% endif %} { get {
return {% if property.isThrowing %}try {% endif %}{% if property.isAsync %}await {% endif %}cuckoo_manager.getter{% if property.isThrowing %}Throws{% endif %}("{{ property.name }}", return cuckoo_manager.getter("{{ property.name }}",
superclassCall: superclassCall:
{% if container.isImplementation %} {% if container.isImplementation %}
{% if property.isThrowing %}try {% endif %}{% if property.isAsync %}await {% endif %}super.{{ property.name }} super.{{ property.name }}
{% else %} {% else %}
Cuckoo.MockManager.crashOnProtocolSuperclassCall() Cuckoo.MockManager.crashOnProtocolSuperclassCall()
{% endif %}, {% endif %},
defaultCall: {% if property.isThrowing %}try {% endif %}{% if property.isAsync %}await {% endif %} __defaultImplStub!.{{property.name}}) defaultCall: __defaultImplStub!.{{property.name}})
} }
{% ifnot property.isReadOnly %} {% ifnot property.isReadOnly %}
set { set {
@ -84,13 +82,9 @@ extension {{ container.parentFullyQualifiedName }} {
} }
{% endif %} {% endif %}
} }
{% if property.hasUnavailablePlatforms %}
#endif
{% endif %}
{% endfor %} {% endfor %}
{% for initializer in container.initializers %} {% for initializer in container.initializers %}
{{ initializer.unavailablePlatformsCheck }}
{% if debug %} {% if debug %}
// {{initializer}} // {{initializer}}
{% endif %} {% endif %}
@ -99,39 +93,29 @@ extension {{ container.parentFullyQualifiedName }} {
super.init({{initializer.call}}) super.init({{initializer.call}})
{% endif %} {% endif %}
} }
{% if initializer.hasUnavailablePlatforms %}
#endif
{% endif %}
{% endfor %} {% endfor %}
{% for method in container.methods %} {% for method in container.methods %}
{{ method.unavailablePlatformsCheck }}
{% if debug %} {% if debug %}
// {{method}} // {{method}}
{% endif %} {% endif %}
{% for attribute in method.attributes %} {% for attribute in method.attributes %}
{{ attribute.text }} {{ attribute.text }}
{% endfor %} {% endfor %}
{{ method.accessibility }}{% if container.isImplementation and method.isOverriding %} override{% endif %} func {{ method.name|escapeReservedKeywords }}{{ method.genericParameters }}({{ method.parameterSignature }}) {{ method.returnSignature }} { {{ method.accessibility }}{% if container.isImplementation and method.isOverriding %} override{% endif %} func {{ method.name }}{{ method.genericParameters }}({{ method.parameterSignature }}) {{ method.returnSignature }} {
{{ method.self|openNestedClosure }} {{ method.self|openNestedClosure }}
return{% if method.isThrowing %} try{% endif %}{% if method.isAsync %} await{% endif %} cuckoo_manager.call{% if method.isThrowing %}{{ method.throwType|capitalize }}{% endif %}( return{% if method.isThrowing %} try{% endif %} cuckoo_manager.call{% if method.isThrowing %}{{ method.throwType|capitalize }}{% endif %}("{{method.fullyQualifiedName}}",
\"\"\"
{{method.fullyQualifiedName}}
\"\"\",
parameters: ({{method.parameterNames}}), parameters: ({{method.parameterNames}}),
escapingParameters: ({{method.escapingParameterNames}}), escapingParameters: ({{method.escapingParameterNames}}),
superclassCall: superclassCall:
{% if container.isImplementation %} {% if container.isImplementation %}
{% if method.isAsync %}await {% endif %}super.{{method.name}}({{method.call}}) super.{{method.name}}({{method.call}})
{% else %} {% else %}
Cuckoo.MockManager.crashOnProtocolSuperclassCall() Cuckoo.MockManager.crashOnProtocolSuperclassCall()
{% endif %}, {% endif %},
defaultCall: {% if method.isAsync %}await {% endif %}__defaultImplStub!.{{method.name}}{%if method.isOptional %}!{%endif%}({{method.call}})) defaultCall: __defaultImplStub!.{{method.name}}{%if method.isOptional %}!{%endif%}({{method.call}}))
{{ method.parameters|closeNestedClosure }} {{ method.parameters|closeNestedClosure }}
} }
{% if method.hasUnavailablePlatforms %}
#endif
{% endif %}
{% endfor %} {% endfor %}
\(Templates.stubbingProxy.indented()) \(Templates.stubbingProxy.indented())
@ -141,13 +125,6 @@ extension {{ container.parentFullyQualifiedName }} {
\(Templates.noImplStub) \(Templates.noImplStub)
{% if container.hasParent %}
}
{% endif %}
{% if container.hasUnavailablePlatforms %}
#endif
{% endif %}
{% endfor %} {% endfor %}
""" """
} }

View File

@ -1,56 +1,39 @@
//
// NopImplStubTemplate.swift
// CuckooGeneratorFramework
//
// Created by Tadeas Kriz on 11/14/17.
//
extension Templates { extension Templates {
static let noImplStub = """ static let noImplStub = """
{% for attribute in container.attributes %} {{container.accessibility}} class {{ container.name }}Stub{{ container.genericParameters }}: {{ container.name }}{% if container.isImplementation %}{{ container.genericArguments }}{% endif %} {
{{ attribute.text }}
{% endfor %}
{{container.accessibility}} class {{ container.name }}Stub{{ container.genericParameters }}: {% if container.isNSObjectProtocol %}NSObject, {% endif %}{{ container.name }}{% if container.isImplementation %}{{ container.genericArguments }}{% endif %} {
{% for property in container.properties %} {% for property in container.properties %}
{{ property.unavailablePlatformsCheck }}
{% if debug %}
// {{property}}
{% endif %}
{% for attribute in property.attributes %} {% for attribute in property.attributes %}
{{ attribute.text }} {{ attribute.text }}
{% endfor %} {% endfor %}
{{ property.accessibility }}{% if container.@type == "ClassDeclaration" %} override{% endif %} var {{ property.name }}: {{ property.type }} { {{ property.accessibility }}{% if container.@type == "ClassDeclaration" %} override{% endif %} var {{ property.name }}: {{ property.type }} {
get { get {
return DefaultValueRegistry.defaultValue(for: ({{property.type|genericSafe|removeClosureArgumentNames}}).self) return DefaultValueRegistry.defaultValue(for: ({{property.type|genericSafe}}).self)
} }
{% ifnot property.isReadOnly %} {% ifnot property.isReadOnly %}
set { } set { }
{% endif %} {% endif %}
} }
{% if property.hasUnavailablePlatforms %}
#endif
{% endif %}
{% endfor %} {% endfor %}
{% for initializer in container.initializers %} {% for initializer in container.initializers %}
{{ initializer.unavailablePlatformsCheck }}
{{ initializer.accessibility }}{% if container.@type == "ClassDeclaration" %} override{% endif %}{% if initializer.@type == "ProtocolMethod" %} required{%endif%} init({{initializer.parameterSignature}}) { {{ initializer.accessibility }}{% if container.@type == "ClassDeclaration" %} override{% endif %}{% if initializer.@type == "ProtocolMethod" %} required{%endif%} init({{initializer.parameterSignature}}) {
{% if container.@type == "ClassDeclaration" %} {% if container.@type == "ClassDeclaration" %}
super.init({{initializer.call}}) super.init({{initializer.call}})
{% endif %} {% endif %}
} }
{% if initializer.hasUnavailablePlatforms %}
#endif
{% endif %}
{% endfor %} {% endfor %}
{% for method in container.methods %} {% for method in container.methods %}
{{ method.unavailablePlatformsCheck }} {{ method.accessibility }}{% if container.@type == "ClassDeclaration" and method.isOverriding %} override{% endif %} func {{ method.name }}{{ method.genericParameters }}({{ method.parameterSignature }}) {{ method.returnSignature }} {{ method.whereClause }} {
{% if debug %}
// {{method}}
{% endif %}
{% for attribute in method.attributes %}
{{ attribute.text }}
{% endfor %}
{{ method.accessibility }}{% if container.@type == "ClassDeclaration" and method.isOverriding %} override{% endif %} func {{ method.name|escapeReservedKeywords }}{{ method.genericParameters }}({{ method.parameterSignature }}) {{ method.returnSignature }} {{ method.whereClause }} {
return DefaultValueRegistry.defaultValue(for: ({{method.returnType|genericSafe}}).self) return DefaultValueRegistry.defaultValue(for: ({{method.returnType|genericSafe}}).self)
} }
{% if method.hasUnavailablePlatforms %}
#endif
{% endif %}
{% endfor %} {% endfor %}
} }
""" """

View File

@ -1,3 +1,10 @@
//
// StubbingProxyTemplate.swift
// CuckooGeneratorFramework
//
// Created by Tadeas Kriz on 11/14/17.
//
import Foundation import Foundation
extension Templates { extension Templates {
@ -9,32 +16,18 @@ extension Templates {
self.cuckoo_manager = manager self.cuckoo_manager = manager
} }
{% for property in container.properties %} {% for property in container.properties %}
{{ property.unavailablePlatformsCheck }}
{% for attribute in property.attributes %} {% for attribute in property.attributes %}
{{ attribute.text }} {{ attribute.text }}
{% endfor %} {% endfor %}
var {{property.name}}: Cuckoo.{{ property.stubType }}<{{ container.mockName }}, {% if property.isReadOnly %}{{property.type|genericSafe}}{% else %}{{property.nonOptionalType|genericSafe}}{% endif %}> { var {{property.name}}: Cuckoo.{{ property.stubType }}<{{ container.mockName }}, {% if property.isReadOnly %}{{property.type|genericSafe}}{% else %}{{property.nonOptionalType|genericSafe}}{% endif %}> {
return .init(manager: cuckoo_manager, name: "{{property.name}}") return .init(manager: cuckoo_manager, name: "{{property.name}}")
} }
{% if property.hasUnavailablePlatforms %}
#endif
{% endif %}
{% endfor %} {% endfor %}
{% for method in container.methods %} {% for method in container.methods %}
{{ method.unavailablePlatformsCheck }} func {{method.name}}{{method.self|matchableGenericNames}}({{method.parameters|matchableParameterSignature}}) -> {{method.stubFunction}}<({{method.inputTypes|genericSafe}}){%if method.returnType != "Void" %}, {{method.returnType|genericSafe}}{%endif%}>{{method.self|matchableGenericWhereClause}} {
{% for attribute in method.attributes %}
{{ attribute.text }}
{% endfor %}
func {{method.name|escapeReservedKeywords}}{{method.self|matchableGenericNames}}({{method.parameters|matchableParameterSignature}}) -> {{method.stubFunction}}<({{method.inputTypes|genericSafe}}){%if method.returnType != "Void" %}, {{method.returnType|genericSafe}}{%endif%}>{{method.self|matchableGenericWhereClause}} {
{{method.parameters|parameterMatchers}} {{method.parameters|parameterMatchers}}
return .init(stub: cuckoo_manager.createStub(for: {{ container.mockName }}.self, method: return .init(stub: cuckoo_manager.createStub(for: {{ container.mockName }}.self, method: "{{method.fullyQualifiedName}}", parameterMatchers: matchers))
\"\"\"
{{method.fullyQualifiedName}}
\"\"\", parameterMatchers: matchers))
} }
{% if method.hasUnavailablePlatforms %}
#endif
{% endif %}
{% endfor %} {% endfor %}
} }
""" """

View File

@ -1,10 +1,17 @@
//
// Templates.swift
// CuckooGeneratorFramework
//
// Created by Tadeas Kriz on 11/14/17.
//
import Foundation import Foundation
struct Templates { } struct Templates { }
extension String { extension String {
func indented(times: Int = 1) -> String { func indented(times: Int = 1) -> String {
let indentation = String(repeating: " ", count: times) let indentation = String(repeating: "\t", count: times)
return self.components(separatedBy: CharacterSet.newlines).map { return self.components(separatedBy: CharacterSet.newlines).map {
indentation + $0 indentation + $0

View File

@ -1,3 +1,10 @@
//
// TypeErasureTemplate.swift
// CuckooGeneratorFramework
//
// Created by Matyáš Kříž on 26/11/2018.
//
import Foundation import Foundation
extension Templates { extension Templates {
@ -32,9 +39,9 @@ extension Templates {
{% endfor %} {% endfor %}
{% for method in container.methods %} {% for method in container.methods %}
private let _storage${{ forloop.counter }}${{ method.name }}: ({{ method.inputTypes }}) {% if method.isAsync %} async{% endif %} -> {{ method.returnType }} private let _storage${{ forloop.counter }}${{ method.name }}: ({{ method.inputTypes }}) -> {{ method.returnType }}
{{ container.accessibility }} func {{ method.name|escapeReservedKeywords }}({{ method.parameterSignature }}) {{ method.returnSignature }} { {{ container.accessibility }} func {{ method.name }}({{ method.parameterSignature }}) {{ method.returnSignature }} {
return {% if method.isAsync %} await{% endif %} _storage${{ forloop.counter }}${{ method.name }}({{ method.parameterNames }}) return _storage${{ forloop.counter }}${{ method.name }}({{ method.parameterNames }})
} }
{% endfor %} {% endfor %}
} }

View File

@ -1,3 +1,10 @@
//
// VerificationProxyTemplate.swift
// CuckooGeneratorFramework
//
// Created by Tadeas Kriz on 11/14/17.
//
import Foundation import Foundation
extension Templates { extension Templates {
@ -14,34 +21,20 @@ extension Templates {
} }
{% for property in container.properties %} {% for property in container.properties %}
{{ property.unavailablePlatformsCheck }}
{% for attribute in property.attributes %} {% for attribute in property.attributes %}
{{ attribute.text }} {{ attribute.text }}
{% endfor %} {% endfor %}
var {{property.name}}: Cuckoo.{{property.verifyType}}<{% if property.isReadOnly %}{{property.type|genericSafe}}{% else %}{{property.nonOptionalType|genericSafe}}{% endif %}> { var {{property.name}}: Cuckoo.{{property.verifyType}}<{% if property.isReadOnly %}{{property.type|genericSafe}}{% else %}{{property.nonOptionalType|genericSafe}}{% endif %}> {
return .init(manager: cuckoo_manager, name: "{{property.name}}", callMatcher: callMatcher, sourceLocation: sourceLocation) return .init(manager: cuckoo_manager, name: "{{property.name}}", callMatcher: callMatcher, sourceLocation: sourceLocation)
} }
{% if property.hasUnavailablePlatforms %}
#endif
{% endif %}
{% endfor %} {% endfor %}
{% for method in container.methods %} {% for method in container.methods %}
{{ method.unavailablePlatformsCheck }}
{% for attribute in method.attributes %}
{{ attribute.text }}
{% endfor %}
@discardableResult @discardableResult
func {{method.name|escapeReservedKeywords}}{{method.self|matchableGenericNames}}({{method.parameters|matchableParameterSignature}}) -> Cuckoo.__DoNotUse<({{method.inputTypes|genericSafe}}), {{method.returnType|genericSafe}}>{{method.self|matchableGenericWhereClause}} { func {{method.name}}{{method.self|matchableGenericNames}}({{method.parameters|matchableParameterSignature}}) -> Cuckoo.__DoNotUse<({{method.inputTypes|genericSafe}}), {{method.returnType|genericSafe}}>{{method.self|matchableGenericWhereClause}} {
{{method.parameters|parameterMatchers}} {{method.parameters|parameterMatchers}}
return cuckoo_manager.verify( return cuckoo_manager.verify("{{method.fullyQualifiedName}}", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
\"\"\"
{{method.fullyQualifiedName}}
\"\"\", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
} }
{% if method.hasUnavailablePlatforms %}
#endif
{% endif %}
{% endfor %} {% endfor %}
} }
""" """

View File

@ -1,3 +1,11 @@
//
// Tokenizer.swift
// CuckooGenerator
//
// Created by Tadeas Kriz on 12/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Foundation import Foundation
import SourceKittenFramework import SourceKittenFramework
@ -18,11 +26,6 @@ public struct Tokenizer {
let structure = try Structure(file: file) let structure = try Structure(file: file)
let declarations = tokenize(structure.dictionary[Key.Substructure.rawValue] as? [SourceKitRepresentable] ?? []) let declarations = tokenize(structure.dictionary[Key.Substructure.rawValue] as? [SourceKitRepresentable] ?? [])
.flatMap { declaration -> [Token] in
guard let parent = declaration as? ParentToken else { return [declaration] }
return [parent] + parent.adoptAllYoungerGenerations()
}
let imports = tokenize(imports: declarations) let imports = tokenize(imports: declarations)
return FileRepresentation(sourceFile: file, declarations: declarations + imports) return FileRepresentation(sourceFile: file, declarations: declarations + imports)
@ -62,7 +65,7 @@ public struct Tokenizer {
let bodyRange = extractRange(from: dictionary, offset: .BodyOffset, length: .BodyLength) let bodyRange = extractRange(from: dictionary, offset: .BodyOffset, length: .BodyLength)
// Attributes // Attributes
let attributes = (NSOrderedSet(array: (dictionary[Key.Attributes.rawValue] as? [SourceKitRepresentable] ?? []) let attributes = (dictionary[Key.Attributes.rawValue] as? [SourceKitRepresentable] ?? [])
.compactMap { attribute -> Attribute? in .compactMap { attribute -> Attribute? in
guard let attribute = attribute as? [String: SourceKitRepresentable], guard let attribute = attribute as? [String: SourceKitRepresentable],
let stringKind = attribute[Key.Attribute.rawValue] as? String, let stringKind = attribute[Key.Attribute.rawValue] as? String,
@ -73,7 +76,6 @@ public struct Tokenizer {
guard let text = String(source.utf8[startIndex..<endIndex]) else { return nil } guard let text = String(source.utf8[startIndex..<endIndex]) else { return nil }
return Attribute(kind: kind, text: text) return Attribute(kind: kind, text: text)
} }
).array as? [Attribute]) ?? []
guard !attributes.map({ $0.kind }).contains(.final) else { guard !attributes.map({ $0.kind }).contains(.final) else {
if debugMode { if debugMode {
@ -110,9 +112,7 @@ public struct Tokenizer {
children: children, children: children,
inheritedTypes: tokenizedInheritedTypes, inheritedTypes: tokenizedInheritedTypes,
attributes: attributes, attributes: attributes,
genericParameters: fixedGenericParameters, genericParameters: fixedGenericParameters)
isNSObjectProtocol: false
)
case Kinds.ClassDeclaration.rawValue: case Kinds.ClassDeclaration.rawValue:
let subtokens = tokenize(dictionary[Key.Substructure.rawValue] as? [SourceKitRepresentable] ?? []) let subtokens = tokenize(dictionary[Key.Substructure.rawValue] as? [SourceKitRepresentable] ?? [])
@ -140,36 +140,10 @@ public struct Tokenizer {
children: children, children: children,
inheritedTypes: tokenizedInheritedTypes, inheritedTypes: tokenizedInheritedTypes,
attributes: attributes, attributes: attributes,
genericParameters: fixedGenericParameters genericParameters: fixedGenericParameters)
)
case Kinds.StructDeclaration.rawValue:
let subtokens = tokenize(dictionary[Key.Substructure.rawValue] as? [SourceKitRepresentable] ?? [])
let children = subtokens.only(ContainerToken.self)
return StructDeclaration(
name: name,
accessibility: accessibility,
range: range!,
nameRange: nameRange!,
bodyRange: bodyRange!,
attributes: attributes,
children: children
)
case Kinds.ExtensionDeclaration.rawValue: case Kinds.ExtensionDeclaration.rawValue:
let subtokens = tokenize(dictionary[Key.Substructure.rawValue] as? [SourceKitRepresentable] ?? []) return ExtensionDeclaration(range: range!)
let children = subtokens.only(ContainerToken.self)
return ExtensionDeclaration(
name: name,
accessibility: accessibility,
range: range!,
nameRange: nameRange!,
bodyRange: bodyRange!,
attributes: attributes,
children: children
)
case Kinds.InstanceVariable.rawValue: case Kinds.InstanceVariable.rawValue:
let setterAccessibility = (dictionary[Key.SetterAccessibility.rawValue] as? String).flatMap(Accessibility.init) let setterAccessibility = (dictionary[Key.SetterAccessibility.rawValue] as? String).flatMap(Accessibility.init)
@ -185,24 +159,15 @@ public struct Tokenizer {
guessedType = type guessedType = type
} }
let effects: InstanceVariable.Effects
if let bodyRange = bodyRange {
effects = parseEffects(source: source.utf8[bodyRange])
} else {
effects = .init()
}
return InstanceVariable( return InstanceVariable(
name: name, name: name,
type: guessedType ?? .type("__UnknownType"), type: guessedType ?? .type("__UnknownType"),
accessibility: accessibility, accessibility: accessibility,
setterAccessibility: setterAccessibility, setterAccessibility: setterAccessibility,
effects: effects,
range: range!, range: range!,
nameRange: nameRange!, nameRange: nameRange!,
overriding: false, overriding: false,
attributes: attributes attributes: attributes)
)
case Kinds.InstanceMethod.rawValue: case Kinds.InstanceMethod.rawValue:
let genericParameters = tokenize(dictionary[Key.Substructure.rawValue] as? [SourceKitRepresentable] ?? []).only(GenericParameter.self) let genericParameters = tokenize(dictionary[Key.Substructure.rawValue] as? [SourceKitRepresentable] ?? []).only(GenericParameter.self)
@ -226,7 +191,7 @@ public struct Tokenizer {
} }
} }
// FIXME: Remove when SourceKit fixes the off-by-one error that includes the ending `>` in the last inherited type. // FIXME: Remove when SourceKitten fixes the off-by-one error that includes the ending `>` in the last inherited type.
let fixedGenericParameters = fixSourceKittenLastGenericParameterBug(genericParameters) let fixedGenericParameters = fixSourceKittenLastGenericParameterBug(genericParameters)
// When bodyRange != nil, we need to create `ClassMethod` instead of `ProtocolMethod` // When bodyRange != nil, we need to create `ClassMethod` instead of `ProtocolMethod`
@ -240,8 +205,7 @@ public struct Tokenizer {
parameters: namedParameters, parameters: namedParameters,
bodyRange: bodyRange, bodyRange: bodyRange,
attributes: attributes, attributes: attributes,
genericParameters: fixedGenericParameters genericParameters: fixedGenericParameters)
)
} else { } else {
return ProtocolMethod( return ProtocolMethod(
name: name, name: name,
@ -251,8 +215,7 @@ public struct Tokenizer {
nameRange: nameRange!, nameRange: nameRange!,
parameters: namedParameters, parameters: namedParameters,
attributes: attributes, attributes: attributes,
genericParameters: fixedGenericParameters genericParameters: fixedGenericParameters)
)
} }
case Kinds.GenericParameter.rawValue: case Kinds.GenericParameter.rawValue:
@ -271,11 +234,7 @@ public struct Tokenizer {
let toIndex = source.index(fromIndex, offsetBy: inheritanceRange.length) let toIndex = source.index(fromIndex, offsetBy: inheritanceRange.length)
let inheritance = String(source[fromIndex..<toIndex]) let inheritance = String(source[fromIndex..<toIndex])
let fullRange = range.lowerBound..<(range.upperBound + inheritanceMatch.range.length) let fullRange = range.lowerBound..<(range.upperBound + inheritanceMatch.range.length)
return GenericParameter( return GenericParameter(name: name, range: fullRange, inheritedType: InheritanceDeclaration(name: inheritance))
name: name,
range: fullRange,
inheritedType: InheritanceDeclaration(name: inheritance)
)
default: default:
// Do not log anything, until the parser contains all known cases. // Do not log anything, until the parser contains all known cases.
@ -336,7 +295,7 @@ public struct Tokenizer {
let wrappableType = WrappableType(parsing: inoutSeparatedType) let wrappableType = WrappableType(parsing: inoutSeparatedType)
return MethodParameter(label: parameterLabel, name: name, type: wrappableType, range: range!, nameRange: nameRange, isInout: isInout) return MethodParameter(label: parameterLabel, name: name, type: wrappableType, range: range!, nameRange: nameRange!, isInout: isInout)
case Kinds.GenericParameter.rawValue: case Kinds.GenericParameter.rawValue:
let inheritedTypeElement = (dictionary[Key.InheritedTypes.rawValue] as? [SourceKitRepresentable] ?? []).first let inheritedTypeElement = (dictionary[Key.InheritedTypes.rawValue] as? [SourceKitRepresentable] ?? []).first
@ -484,7 +443,6 @@ public struct Tokenizer {
/// - parameter source: A trimmed string containing only the method return signature excluding the trailing brace /// - parameter source: A trimmed string containing only the method return signature excluding the trailing brace
/// - returns: ReturnSignature structure containing the parsed throwString, return type, and where constraints /// - returns: ReturnSignature structure containing the parsed throwString, return type, and where constraints
private func parseReturnSignature(source: String) -> ReturnSignature { private func parseReturnSignature(source: String) -> ReturnSignature {
var isAsync = false
var throwString = nil as String? var throwString = nil as String?
var returnType: WrappableType? var returnType: WrappableType?
var whereConstraints = [] as [String] var whereConstraints = [] as [String]
@ -493,11 +451,6 @@ public struct Tokenizer {
parseLoop: while index != source.endIndex { parseLoop: while index != source.endIndex {
let character = source[index] let character = source[index]
switch character { switch character {
case "a":
isAsync = true
let asyncString = "async"
index = source.index(index, offsetBy: asyncString.count)
continue
case "r" where returnType == nil: case "r" where returnType == nil:
throwString = "rethrows" throwString = "rethrows"
index = source.index(index, offsetBy: throwString!.count) index = source.index(index, offsetBy: throwString!.count)
@ -523,35 +476,7 @@ public struct Tokenizer {
index = source.index(after: index) index = source.index(after: index)
} }
return ReturnSignature(isAsync: isAsync, throwString: throwString, returnType: returnType ?? WrappableType.type("Void"), whereConstraints: whereConstraints) return ReturnSignature(throwString: throwString, returnType: returnType ?? WrappableType.type("Void"), whereConstraints: whereConstraints)
}
private func parseEffects(source: String) -> InstanceVariable.Effects {
var effects = InstanceVariable.Effects()
let trimmed = source.drop(while: { $0.isWhitespace })
guard trimmed.hasPrefix("get") else { return effects }
let afterGet = trimmed.dropFirst("get".count).drop(while: { $0.isWhitespace })
var index = afterGet.startIndex
parseLoop: while index != afterGet.endIndex {
let character = afterGet[index]
switch character {
case "a":
effects.isAsync = true
index = source.index(index, offsetBy: "async".count)
case "t":
effects.isThrowing = true
index = source.index(index, offsetBy: "throws".count)
case let c where c.isWhitespace:
break
default:
break parseLoop
}
index = source.index(after: index)
}
return effects
} }
// FIXME: Remove when SourceKitten fixes the off-by-one error that includes the ending `>` in the last inherited type. // FIXME: Remove when SourceKitten fixes the off-by-one error that includes the ending `>` in the last inherited type.

View File

@ -1,3 +1,11 @@
//
// Accessibility.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public enum Accessibility: String { public enum Accessibility: String {
case Open = "source.lang.swift.accessibility.open" case Open = "source.lang.swift.accessibility.open"
case Public = "source.lang.swift.accessibility.public" case Public = "source.lang.swift.accessibility.public"

View File

@ -1,7 +1,13 @@
import Foundation //
// Attribute.swift
// CuckooGenerator
//
// Created by Tadeas Kriz on 2/25/17.
//
//
public struct Attribute: Hashable { public struct Attribute {
public enum Kind: String, Hashable { public enum Kind: String {
case objc = "source.decl.attribute.objc" case objc = "source.decl.attribute.objc"
case optional = "source.decl.attribute.optional" case optional = "source.decl.attribute.optional"
case lazy = "source.decl.attribute.lazy" case lazy = "source.decl.attribute.lazy"
@ -26,26 +32,6 @@ public struct Attribute: Hashable {
return true return true
} }
} }
public var unavailablePlatform: String? {
guard kind == .available,
text.hasPrefix("@available(") else {
return nil
}
let parameters = text
.dropFirst("@available(".count)
.dropLast()
.split(separator: ",")
.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
guard parameters.count >= 2,
parameters[1] == "unavailable" else {
return nil
}
return String(parameters[0])
}
} }
extension Attribute: Token { extension Attribute: Token {

View File

@ -1,7 +1,14 @@
//
// ClassDeclaration.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public struct ClassDeclaration: ContainerToken, HasAccessibility { public struct ClassDeclaration: ContainerToken, HasAccessibility {
public let implementation: Bool = true public let implementation: Bool = true
public var name: String public var name: String
public var parent: Reference<ParentToken>?
public var accessibility: Accessibility public var accessibility: Accessibility
public var range: CountableRange<Int> public var range: CountableRange<Int>
public var nameRange: CountableRange<Int> public var nameRange: CountableRange<Int>
@ -18,7 +25,6 @@ public struct ClassDeclaration: ContainerToken, HasAccessibility {
public func replace(children tokens: [Token]) -> ClassDeclaration { public func replace(children tokens: [Token]) -> ClassDeclaration {
return ClassDeclaration( return ClassDeclaration(
name: self.name, name: self.name,
parent: self.parent,
accessibility: self.accessibility, accessibility: self.accessibility,
range: self.range, range: self.range,
nameRange: self.nameRange, nameRange: self.nameRange,

View File

@ -1,3 +1,11 @@
//
// ClassMethod.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public struct ClassMethod: Method { public struct ClassMethod: Method {
public var name: String public var name: String
public var accessibility: Accessibility public var accessibility: Accessibility

View File

@ -1,7 +1,21 @@
public protocol ContainerToken: ParentToken, ChildToken { //
// ContainerToken.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public protocol ContainerToken: Token, HasAccessibility {
var name: String { get }
var range: CountableRange<Int> { get }
var nameRange: CountableRange<Int> { get }
var bodyRange: CountableRange<Int> { get }
var initializers: [Initializer] { get } var initializers: [Initializer] { get }
var children: [Token] { get }
var implementation: Bool { get } var implementation: Bool { get }
var inheritedTypes: [InheritanceDeclaration] { get } var inheritedTypes: [InheritanceDeclaration] { get }
var attributes: [Attribute] { get }
var genericParameters: [GenericParameter] { get } var genericParameters: [GenericParameter] { get }
} }
@ -41,8 +55,6 @@ extension ContainerToken {
"name": name, "name": name,
"accessibility": accessibility.sourceName, "accessibility": accessibility.sourceName,
"isAccessible": accessibility.isAccessible, "isAccessible": accessibility.isAccessible,
"hasParent": parent != nil,
"parentFullyQualifiedName": parent?.fullyQualifiedName ?? "",
"children": accessibilityAdjustedChildren.map { $0.serializeWithType() }, "children": accessibilityAdjustedChildren.map { $0.serializeWithType() },
"properties": properties, "properties": properties,
"methods": methods, "methods": methods,
@ -51,13 +63,10 @@ extension ContainerToken {
"mockName": "Mock\(name)", "mockName": "Mock\(name)",
"inheritedTypes": inheritedTypes, "inheritedTypes": inheritedTypes,
"attributes": attributes.filter { $0.isSupported }, "attributes": attributes.filter { $0.isSupported },
"hasUnavailablePlatforms": hasUnavailablePlatforms,
"unavailablePlatformsCheck": unavailablePlatformsCheck,
"isGeneric": isGeneric, "isGeneric": isGeneric,
"genericParameters": isGeneric ? "<\(genericParametersString)>" : "", "genericParameters": isGeneric ? "<\(genericParametersString)>" : "",
"genericArguments": isGeneric ? "<\(genericArgumentsString)>" : "", "genericArguments": isGeneric ? "<\(genericArgumentsString)>" : "",
"genericProtocolIdentity": genericProtocolIdentity, "genericProtocolIdentity": genericProtocolIdentity,
"isNSObjectProtocol": (self as? ProtocolDeclaration)?.isNSObjectProtocol ?? false
] ]
} }
} }

View File

@ -0,0 +1,17 @@
//
// ExtensionDeclaration.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 17.06.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public struct ExtensionDeclaration: Token {
// TODO Implement support for extensions
public let range: CountableRange<Int>
public func isEqual(to other: Token) -> Bool {
guard let other = other as? ExtensionDeclaration else { return false }
return self.range == other.range
}
}

View File

@ -1,3 +1,11 @@
//
// FileRepresentation.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
import SourceKittenFramework import SourceKittenFramework
public struct FileRepresentation { public struct FileRepresentation {
@ -19,10 +27,6 @@ public extension FileRepresentation {
return FileRepresentation(sourceFile: self.sourceFile, declarations: tokens) return FileRepresentation(sourceFile: self.sourceFile, declarations: tokens)
} }
func inheritNSObject(subjects: [ProtocolDeclaration]) -> FileRepresentation {
FileRepresentation(sourceFile: self.sourceFile, declarations: self.declarations.map { $0.inheritNSObject(subjects: subjects) })
}
} }
extension Token { extension Token {
@ -55,13 +59,6 @@ extension Token {
} }
} }
func inheritNSObject(subjects: [ProtocolDeclaration]) -> Token {
guard let protocolToken = self as? ProtocolDeclaration else {
return self
}
return subjects.contains { $0.name == protocolToken.name } ? protocolToken.replace(isNSObjectProtocol: true) : self
}
static func findToken(forClassOrProtocol name: String, in files: [FileRepresentation]) -> Token? { static func findToken(forClassOrProtocol name: String, in files: [FileRepresentation]) -> Token? {
return files.flatMap { $0.declarations } return files.flatMap { $0.declarations }
.filter { $0.isClassOrProtocolDeclaration } .filter { $0.isClassOrProtocolDeclaration }

View File

@ -1,3 +1,10 @@
//
// GenericParameter.swift
// CuckooGeneratorFramework
//
// Created by Matyáš Kříž on 19/11/2018.
//
import Foundation import Foundation
public struct GenericParameter: Token { public struct GenericParameter: Token {

View File

@ -1,3 +1,10 @@
//
// HasAccessibility.swift
// CuckooGenerator
//
// Created by Matyáš Kříž on 11/03/2019.
//
import Foundation import Foundation
public protocol HasAccessibility { public protocol HasAccessibility {

View File

@ -1,3 +1,11 @@
//
// Import.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 17.06.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public struct Import: Token { public struct Import: Token {
public enum Importee: CustomStringConvertible { public enum Importee: CustomStringConvertible {
case library(name: String) case library(name: String)

View File

@ -1,3 +1,11 @@
//
// InheritanceDeclaration.swift
// CuckooGenerator
//
// Created by Arjan Duijzer on 22/02/2017.
// Copyright (c) 2017 Brightify. All rights reserved.
//
public struct InheritanceDeclaration: Token { public struct InheritanceDeclaration: Token {
public static let empty = InheritanceDeclaration(name: Tokenizer.nameNotSet) public static let empty = InheritanceDeclaration(name: Tokenizer.nameNotSet)
public let name: String public let name: String

View File

@ -1,3 +1,11 @@
//
// Initializer.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public struct Initializer: Method, HasAccessibility { public struct Initializer: Method, HasAccessibility {
public var name: String public var name: String
public var accessibility: Accessibility public var accessibility: Accessibility

View File

@ -1,14 +1,16 @@
public struct InstanceVariable: Token, HasAccessibility, HasAttributes { //
public struct Effects { // InstanceVariable.swift
public var isThrowing = false // CuckooGenerator
public var isAsync = false //
} // Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public struct InstanceVariable: Token, HasAccessibility {
public var name: String public var name: String
public var type: WrappableType public var type: WrappableType
public var accessibility: Accessibility public var accessibility: Accessibility
public var setterAccessibility: Accessibility? public var setterAccessibility: Accessibility?
public var effects: Effects
public var range: CountableRange<Int> public var range: CountableRange<Int>
public var nameRange: CountableRange<Int> public var nameRange: CountableRange<Int>
public var overriding: Bool public var overriding: Bool
@ -28,24 +30,17 @@ public struct InstanceVariable: Token, HasAccessibility, HasAttributes {
} }
public func serialize() -> [String : Any] { public func serialize() -> [String : Any] {
let readOnlyVerifyString = readOnly ? "ReadOnly" : "" let readOnlyString = readOnly ? "ReadOnly" : ""
let readOnlyStubString = effects.isThrowing ? "" : readOnlyVerifyString
let optionalString = type.isOptional && !readOnly ? "Optional" : "" let optionalString = type.isOptional && !readOnly ? "Optional" : ""
let throwingString = effects.isThrowing ? "Throwing" : ""
return [ return [
"name": name, "name": name,
"type": type.sugarized, "type": type.sugarized,
"nonOptionalType": type.unoptionaled.sugarized, "nonOptionalType": type.unoptionaled.sugarized,
"accessibility": accessibility.sourceName, "accessibility": accessibility.sourceName,
"isReadOnly": readOnly, "isReadOnly": readOnly,
"isAsync": effects.isAsync, "stubType": (overriding ? "Class" : "Protocol") + "ToBeStubbed\(readOnlyString)\(optionalString)Property",
"isThrowing": effects.isThrowing, "verifyType": "Verify\(readOnlyString)\(optionalString)Property",
"stubType": (overriding ? "Class" : "Protocol") + "ToBeStubbed\(readOnlyStubString)\(optionalString)\(throwingString)Property",
"verifyType": "Verify\(readOnlyVerifyString)\(optionalString)Property",
"attributes": attributes.filter { $0.isSupported }, "attributes": attributes.filter { $0.isSupported },
"hasUnavailablePlatforms": hasUnavailablePlatforms,
"unavailablePlatformsCheck": unavailablePlatformsCheck,
] ]
} }
} }

View File

@ -1,3 +1,11 @@
//
// Key.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public enum Key: String { public enum Key: String {
case Substructure = "key.substructure" case Substructure = "key.substructure"
case Kind = "key.kind" case Kind = "key.kind"

View File

@ -1,9 +1,16 @@
//
// Kinds.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public enum Kinds: String { public enum Kinds: String {
case ProtocolDeclaration = "source.lang.swift.decl.protocol" case ProtocolDeclaration = "source.lang.swift.decl.protocol"
case InstanceMethod = "source.lang.swift.decl.function.method.instance" case InstanceMethod = "source.lang.swift.decl.function.method.instance"
case MethodParameter = "source.lang.swift.decl.var.parameter" case MethodParameter = "source.lang.swift.decl.var.parameter"
case ClassDeclaration = "source.lang.swift.decl.class" case ClassDeclaration = "source.lang.swift.decl.class"
case StructDeclaration = "source.lang.swift.decl.struct"
case ExtensionDeclaration = "source.lang.swift.decl.extension" case ExtensionDeclaration = "source.lang.swift.decl.extension"
case InstanceVariable = "source.lang.swift.decl.var.instance" case InstanceVariable = "source.lang.swift.decl.var.instance"
case GenericParameter = "source.lang.swift.decl.generic_type_param" case GenericParameter = "source.lang.swift.decl.generic_type_param"

View File

@ -1,6 +1,14 @@
//
// Method.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Foundation import Foundation
public protocol Method: Token, HasAccessibility, HasAttributes { public protocol Method: Token, HasAccessibility {
var name: String { get } var name: String { get }
var returnSignature: ReturnSignature { get } var returnSignature: ReturnSignature { get }
var range: CountableRange<Int> { get } var range: CountableRange<Int> { get }
@ -10,6 +18,7 @@ public protocol Method: Token, HasAccessibility, HasAttributes {
var isOverriding: Bool { get } var isOverriding: Bool { get }
var hasClosureParams: Bool { get } var hasClosureParams: Bool { get }
var hasOptionalParams: Bool { get } var hasOptionalParams: Bool { get }
var attributes: [Attribute] { get }
var genericParameters: [GenericParameter] { get } var genericParameters: [GenericParameter] { get }
} }
@ -39,10 +48,6 @@ public extension Method {
.joined(separator: ", ") + lastNamePart + returnSignatureString .joined(separator: ", ") + lastNamePart + returnSignatureString
} }
var isAsync: Bool {
return returnSignature.isAsync
}
var isThrowing: Bool { var isThrowing: Bool {
guard let throwType = returnSignature.throwType else { return false } guard let throwType = returnSignature.throwType else { return false }
return throwType.isThrowing || throwType.isRethrowing return throwType.isThrowing || throwType.isRethrowing
@ -67,9 +72,7 @@ public extension Method {
func serialize() -> [String : Any] { func serialize() -> [String : Any] {
let call = parameters.map { let call = parameters.map {
let name = escapeReservedKeywords(for: $0.name) let referencedName = "\($0.isInout ? "&" : "")\($0.name)"
let referencedName = "\($0.isInout ? "&" : "")\(name)\($0.isAutoClosure ? "()" : "")"
if let label = $0.label { if let label = $0.label {
return "\(label): \(referencedName)" return "\(label): \(referencedName)"
} else { } else {
@ -97,7 +100,7 @@ public extension Method {
} }
return "{ \(parameterSignature)\(returnSignature) in fatalError(\"This is a stub! It's not supposed to be called!\") }" return "{ \(parameterSignature)\(returnSignature) in fatalError(\"This is a stub! It's not supposed to be called!\") }"
} else { } else {
return escapeReservedKeywords(for: parameter.name) return parameter.name
} }
}.joined(separator: ", ") }.joined(separator: ", ")
@ -110,11 +113,10 @@ public extension Method {
"accessibility": accessibility.sourceName, "accessibility": accessibility.sourceName,
"returnSignature": returnSignature.description, "returnSignature": returnSignature.description,
"parameters": parameters, "parameters": parameters,
"parameterNames": parameters.map { escapeReservedKeywords(for: $0.name) }.joined(separator: ", "), "parameterNames": parameters.map { $0.name }.joined(separator: ", "),
"escapingParameterNames": escapingParameterNames, "escapingParameterNames": escapingParameterNames,
"isInit": isInit, "isInit": isInit,
"returnType": returnType.explicitOptionalOnly.sugarized, "returnType": returnType.explicitOptionalOnly.sugarized,
"isAsync": isAsync,
"isThrowing": isThrowing, "isThrowing": isThrowing,
"throwType": returnSignature.throwType?.description ?? "", "throwType": returnSignature.throwType?.description ?? "",
"fullyQualifiedName": fullyQualifiedName, "fullyQualifiedName": fullyQualifiedName,
@ -129,8 +131,6 @@ public extension Method {
"hasClosureParams": hasClosureParams, "hasClosureParams": hasClosureParams,
"hasOptionalParams": hasOptionalParams, "hasOptionalParams": hasOptionalParams,
"attributes": attributes.filter { $0.isSupported }, "attributes": attributes.filter { $0.isSupported },
"hasUnavailablePlatforms": hasUnavailablePlatforms,
"unavailablePlatformsCheck": unavailablePlatformsCheck,
"genericParameters": isGeneric ? "<\(genericParametersString)>" : "", "genericParameters": isGeneric ? "<\(genericParametersString)>" : "",
] ]
} }

View File

@ -1,9 +1,17 @@
//
// MethodParameter.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public struct MethodParameter: Token, Equatable { public struct MethodParameter: Token, Equatable {
public var label: String? public var label: String?
public var name: String public var name: String
public var type: WrappableType public var type: WrappableType
public var range: CountableRange<Int> public var range: CountableRange<Int>
public var nameRange: CountableRange<Int>? public var nameRange: CountableRange<Int>
public var isInout: Bool public var isInout: Bool
public var labelAndName: String { public var labelAndName: String {
@ -27,10 +35,6 @@ public struct MethodParameter: Token, Equatable {
return typeWithoutAttributes.hasPrefix("(") && typeWithoutAttributes.range(of: "->") != nil return typeWithoutAttributes.hasPrefix("(") && typeWithoutAttributes.range(of: "->") != nil
} }
public var isAutoClosure: Bool {
type.containsAttribute(named: "@autoclosure")
}
public var isOptional: Bool { public var isOptional: Bool {
return type.isOptional return type.isOptional
} }

View File

@ -1,7 +1,14 @@
//
// ProtocolDeclaration.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public struct ProtocolDeclaration: ContainerToken, HasAccessibility { public struct ProtocolDeclaration: ContainerToken, HasAccessibility {
public let implementation: Bool = false public let implementation: Bool = false
public var name: String public var name: String
public var parent: Reference<ParentToken>?
public var accessibility: Accessibility public var accessibility: Accessibility
public var range: CountableRange<Int> public var range: CountableRange<Int>
public var nameRange: CountableRange<Int> public var nameRange: CountableRange<Int>
@ -11,12 +18,10 @@ public struct ProtocolDeclaration: ContainerToken, HasAccessibility {
public var inheritedTypes: [InheritanceDeclaration] public var inheritedTypes: [InheritanceDeclaration]
public var attributes: [Attribute] public var attributes: [Attribute]
public var genericParameters: [GenericParameter] public var genericParameters: [GenericParameter]
public var isNSObjectProtocol: Bool
public func replace(children tokens: [Token]) -> ProtocolDeclaration { public func replace(children tokens: [Token]) -> ProtocolDeclaration {
return ProtocolDeclaration( return ProtocolDeclaration(
name: self.name, name: self.name,
parent: self.parent,
accessibility: self.accessibility, accessibility: self.accessibility,
range: self.range, range: self.range,
nameRange: self.nameRange, nameRange: self.nameRange,
@ -25,26 +30,7 @@ public struct ProtocolDeclaration: ContainerToken, HasAccessibility {
children: tokens, children: tokens,
inheritedTypes: self.inheritedTypes, inheritedTypes: self.inheritedTypes,
attributes: self.attributes, attributes: self.attributes,
genericParameters: self.genericParameters, genericParameters: self.genericParameters)
isNSObjectProtocol: self.isNSObjectProtocol
)
}
public func replace(isNSObjectProtocol: Bool) -> ProtocolDeclaration {
ProtocolDeclaration(
name: self.name,
parent: self.parent,
accessibility: self.accessibility,
range: self.range,
nameRange: self.nameRange,
bodyRange: self.bodyRange,
initializers: self.initializers,
children: self.children,
inheritedTypes: self.inheritedTypes,
attributes: self.attributes,
genericParameters: self.genericParameters,
isNSObjectProtocol: isNSObjectProtocol
)
} }
public func isEqual(to other: Token) -> Bool { public func isEqual(to other: Token) -> Bool {

View File

@ -1,3 +1,11 @@
//
// ProtocolMethod.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public struct ProtocolMethod: Method { public struct ProtocolMethod: Method {
public var name: String public var name: String
public var accessibility: Accessibility public var accessibility: Accessibility

View File

@ -1,13 +1,18 @@
//
// ReturnSignature.swift
// CuckooGeneratorFramework
//
// Created by Matyáš Kříž on 25/03/2019.
//
import Foundation import Foundation
public struct ReturnSignature { public struct ReturnSignature {
public var isAsync: Bool
public var throwType: ThrowType? public var throwType: ThrowType?
public var returnType: WrappableType public var returnType: WrappableType
public var whereConstraints: [String] public var whereConstraints: [String]
public init(isAsync: Bool, throwString: String?, returnType: WrappableType, whereConstraints: [String]) { public init(throwString: String?, returnType: WrappableType, whereConstraints: [String]) {
self.isAsync = isAsync
if let throwString = throwString { if let throwString = throwString {
throwType = ThrowType(string: throwString) throwType = ThrowType(string: throwString)
} else { } else {
@ -20,10 +25,9 @@ public struct ReturnSignature {
extension ReturnSignature: CustomStringConvertible { extension ReturnSignature: CustomStringConvertible {
public var description: String { public var description: String {
let asyncString = isAsync ? "async" : nil
let trimmedReturnType = returnType.explicitOptionalOnly.sugarized.trimmed let trimmedReturnType = returnType.explicitOptionalOnly.sugarized.trimmed
let returnString = trimmedReturnType.isEmpty || trimmedReturnType == "Void" ? nil : "-> \(returnType)" let returnString = trimmedReturnType.isEmpty || trimmedReturnType == "Void" ? nil : "-> \(returnType)"
let whereString = whereConstraints.isEmpty ? nil : "where \(whereConstraints.joined(separator: ", "))" let whereString = whereConstraints.isEmpty ? nil : "where \(whereConstraints.joined(separator: ", "))"
return [asyncString, throwType?.description, returnString, whereString].compactMap { $0 }.joined(separator: " ") return [throwType?.description, returnString, whereString].compactMap { $0 }.joined(separator: " ")
} }
} }

View File

@ -1,3 +1,10 @@
//
// ThrowType.swift
// CuckooGeneratorFramework
//
// Created by Matyáš Kříž on 14/05/2019.
//
public enum ThrowType: CustomStringConvertible { public enum ThrowType: CustomStringConvertible {
case throwing case throwing
case rethrowing case rethrowing

View File

@ -1,3 +1,11 @@
//
// Token.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public protocol Token { public protocol Token {
func isEqual(to other: Token) -> Bool func isEqual(to other: Token) -> Bool

View File

@ -1,3 +1,10 @@
//
// WrappableType.swift
// CuckooGeneratorFramework
//
// Created by Matyáš Kříž on 13/03/2019.
//
public enum WrappableType { public enum WrappableType {
indirect case optional(WrappableType) indirect case optional(WrappableType)
indirect case implicitlyUnwrappedOptional(WrappableType) indirect case implicitlyUnwrappedOptional(WrappableType)

View File

@ -1,10 +1,15 @@
//
// TypeGuesser.swift
// CuckooGeneratorFramework
//
// Created by Matyáš Kříž on 31/05/2019.
//
import Foundation import Foundation
struct TypeGuesser { struct TypeGuesser {
static func guessType(from value: String) -> String? { static func guessType(from value: String) -> String? {
let value = value.trimmed let value = value.trimmed
guard !value.isEmpty else { return nil }
let casting = checkCasting(from: value) let casting = checkCasting(from: value)
guard casting == nil else { return casting } guard casting == nil else { return casting }

View File

@ -1,3 +1,11 @@
//
// String+Utility.swift
// CuckooGenerator
//
// Created by Tadeas Kriz on 12/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Foundation import Foundation
import SourceKittenFramework import SourceKittenFramework
@ -48,26 +56,6 @@ extension Sequence {
} }
} }
/// Reserved keywords that are not allowed as function names, function parameters, or local variables, etc.
fileprivate let reservedKeywordsNotAllowed: Set = [
// Keywords used in declarations:
"associatedtype", "class", "deinit", "enum", "extension", "fileprivate", "func", "import", "init", "inout",
"internal", "let", "operator", "private", "precedencegroup", "protocol", "public", "rethrows", "static",
"struct", "subscript", "typealias", "var",
// Keywords used in statements:
"break", "case", "catch", "continue", "default", "defer", "do", "else", "fallthrough", "for", "guard", "if", "in",
"repeat", "return", "throw", "switch", "where", "while",
// Keywords used in expressions and types:
"Any", "as", "catch", "false", "is", "nil", "rethrows", "self", "super", "throw", "throws", "true", "try",
// Keywords used in patterns:
"_",
]
/// Utility function for escaping reserved keywords for a symbol name.
internal func escapeReservedKeywords(for name: String) -> String {
reservedKeywordsNotAllowed.contains(name) ? "`\(name)`" : name
}
internal func extractRange(from dictionary: [String: SourceKitRepresentable], offset: Key, length: Key) -> CountableRange<Int>? { internal func extractRange(from dictionary: [String: SourceKitRepresentable], offset: Key, length: Key) -> CountableRange<Int>? {
guard let offset = (dictionary[offset.rawValue] as? Int64).map(Int.init), guard let offset = (dictionary[offset.rawValue] as? Int64).map(Int.init),
let length = (dictionary[length.rawValue] as? Int64).map(Int.init) else { return nil } let length = (dictionary[length.rawValue] as? Int64).map(Int.init) else { return nil }

View File

@ -1,19 +0,0 @@
import Foundation
@dynamicMemberLookup
public final class Reference<Value> {
private(set) var value: Value
public init(value: Value) {
self.value = value
}
public subscript<T>(dynamicMember keyPath: KeyPath<Value, T>) -> T {
value[keyPath: keyPath]
}
public subscript<T>(dynamicMember keyPath: WritableKeyPath<Value, T>) -> T {
get { value[keyPath: keyPath] }
set { value[keyPath: keyPath] = newValue }
}
}

View File

@ -1,5 +0,0 @@
import Foundation
public protocol ChildToken: Token {
var parent: Reference<ParentToken>? { get set }
}

View File

@ -1,15 +0,0 @@
public struct ExtensionDeclaration: ParentToken {
// TODO Implement support for extensions
public let name: String
public var accessibility: Accessibility
public let range: CountableRange<Int>
public let nameRange: CountableRange<Int>
public let bodyRange: CountableRange<Int>
public var attributes: [Attribute]
public let children: [Token]
public func isEqual(to other: Token) -> Bool {
guard let other = other as? ExtensionDeclaration else { return false }
return self.range == other.range
}
}

View File

@ -1,19 +0,0 @@
import Foundation
public protocol HasAttributes {
var attributes: [Attribute] { get }
}
extension HasAttributes {
private var unavailablePlatforms: [String] {
return attributes.lazy.compactMap { $0.unavailablePlatform }
}
var hasUnavailablePlatforms: Bool {
return !unavailablePlatforms.isEmpty
}
var unavailablePlatformsCheck: String {
return hasUnavailablePlatforms ? "#if !os(\(unavailablePlatforms.joined(separator: ") && !os(")))" : ""
}
}

View File

@ -1,43 +0,0 @@
import Foundation
public protocol ParentToken: Token, HasAccessibility, HasAttributes {
var name: String { get }
var range: CountableRange<Int> { get }
var nameRange: CountableRange<Int> { get }
var bodyRange: CountableRange<Int> { get }
var children: [Token] { get }
}
extension ParentToken {
var fullyQualifiedName: String {
var names = [name]
var parent: ParentToken? = (self as? ChildToken)?.parent?.value
while let p = parent {
names.insert(p.name, at: 0)
parent = (p as? ChildToken)?.parent?.value
}
return names.joined(separator: ".")
}
var areAllHierarchiesAccessible: Bool {
guard accessibility.isAccessible else { return false }
var parent: ParentToken? = (self as? ChildToken)?.parent?.value
while let p = parent {
guard p.accessibility.isAccessible else { return false }
parent = (p as? ChildToken)?.parent?.value
}
return true
}
func adoptAllYoungerGenerations() -> [ParentToken] {
let parentReference: Reference<ParentToken> = Reference(value: self)
return children
.compactMap { child -> ParentToken? in
guard var c = child as? ContainerToken else { return nil }
c.parent = parentReference
return c
}
.flatMap { [$0] + $0.adoptAllYoungerGenerations() }
}
}

View File

@ -1,17 +0,0 @@
import Foundation
public struct StructDeclaration: ParentToken {
// NOTE: Purely for supporting nested classes, could be any generic parent (like extensions)
public let name: String
public var accessibility: Accessibility
public let range: CountableRange<Int>
public let nameRange: CountableRange<Int>
public let bodyRange: CountableRange<Int>
public var attributes: [Attribute]
public let children: [Token]
public func isEqual(to other: Token) -> Bool {
guard let other = other as? StructDeclaration else { return false }
return self.name == other.name
}
}

View File

@ -1,3 +1,11 @@
//
// CuckooGeneratorError.swift
// CuckooGenerator
//
// Created by Tadeas Kriz on 13/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Foundation import Foundation
import FileKit import FileKit

View File

@ -1,8 +1,17 @@
import Foundation //
// GenerateMocksCommand.swift
// CuckooGenerator
//
// Created by Tadeas Kriz on 12/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Commandant import Commandant
import Result import Result
import SourceKittenFramework import SourceKittenFramework
import FileKit import FileKit
import CuckooGeneratorFramework
import Foundation
private func curry<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, R> private func curry<P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12, R>
(_ f: @escaping (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) -> R) (_ f: @escaping (P1, P2, P3, P4, P5, P6, P7, P8, P9, P10, P11, P12) -> R)
@ -29,7 +38,7 @@ public struct GenerateMocksCommand: CommandProtocol {
} }
let inputFiles = inputPathValues.map { File(path: $0) }.compactMap { $0 } let inputFiles = inputPathValues.map { File(path: $0) }.compactMap { $0 }
let tokens = inputFiles.map { Tokenizer(sourceFile: $0, debugMode: options.debugMode).tokenize() } let tokens = inputFiles.map { Tokenizer(sourceFile: $0, debugMode: options.debugMode).tokenize() }
let tokensWithInheritance = options.noInheritance ? tokens : inheritNSObject(mergeInheritance(tokens)) let tokensWithInheritance = options.noInheritance ? tokens : mergeInheritance(tokens)
// filter classes/protocols based on the settings passed to the generator // filter classes/protocols based on the settings passed to the generator
var typeFilters = [] as [(Token) -> Bool] var typeFilters = [] as [(Token) -> Bool]
@ -54,7 +63,7 @@ public struct GenerateMocksCommand: CommandProtocol {
do { do {
if outputPath.isDirectory { if outputPath.isDirectory {
let inputPaths = inputFiles.compactMap { $0.path }.map { Path($0) } let inputPaths = inputPathValues.map { Path($0) }
for (inputPath, outputText) in zip(inputPaths, mergedFiles) { for (inputPath, outputText) in zip(inputPaths, mergedFiles) {
let fileName = options.filePrefix + inputPath.fileName let fileName = options.filePrefix + inputPath.fileName
let outputFile = TextFile(path: outputPath + fileName) let outputFile = TextFile(path: outputPath + fileName)
@ -77,43 +86,6 @@ public struct GenerateMocksCommand: CommandProtocol {
return filesRepresentation.compactMap { $0.mergeInheritance(with: filesRepresentation) } return filesRepresentation.compactMap { $0.mergeInheritance(with: filesRepresentation) }
} }
private func inheritNSObject(_ filesRepresentation: [FileRepresentation]) -> [FileRepresentation] {
func containsRecursively(name: String) -> Bool {
if let protocolDeclaration = protocolDeclarationDictionary[name] {
let collapsedInheritedTypesName = protocolDeclaration
.inheritedTypes
.map({ $0.name.components(separatedBy: "&") })
.joined()
.map({ $0.trimmingCharacters(in: .whitespaces) })
if collapsedInheritedTypesName.contains(where: { $0 == "NSObjectProtocol" }) {
return true
} else {
return protocolDeclaration.inheritedTypes.contains(where: { inheritanceType in
containsRecursively(name: inheritanceType.name)
})
}
} else {
return false
}
}
let protocolDeclarationDictionary: [String: ProtocolDeclaration] = Dictionary(
uniqueKeysWithValues: filesRepresentation.flatMap { file in
file.declarations.compactMap { token -> (name: String, protocolDeclaration: ProtocolDeclaration)? in
guard let protocolDeclaration = token as? ProtocolDeclaration else { return nil }
return (name: protocolDeclaration.name, protocolDeclaration: protocolDeclaration)
}
}
)
let nsObjectProtocols: [ProtocolDeclaration] = protocolDeclarationDictionary.values.reduce(into: []) { accumulator, protocolDeclaration in
guard containsRecursively(name: protocolDeclaration.name) else { return }
accumulator.append(protocolDeclaration)
}
return filesRepresentation.map { $0.inheritNSObject(subjects: nsObjectProtocols) }
}
private func removeTypes(from files: [FileRepresentation], using filters: [(Token) -> Bool]) -> [FileRepresentation] { private func removeTypes(from files: [FileRepresentation], using filters: [(Token) -> Bool]) -> [FileRepresentation] {
// Only keep those that pass all filters // Only keep those that pass all filters
let filter: (Token) -> Bool = { token in let filter: (Token) -> Bool = { token in
@ -170,19 +142,18 @@ public struct GenerateMocksCommand: CommandProtocol {
let globEnabled: Bool let globEnabled: Bool
let regex: String let regex: String
public init( public init(output: String,
output: String, testableFrameworks: String,
testableFrameworks: String, exclude: String,
exclude: String, noHeader: Bool,
noHeader: Bool, noTimestamp: Bool,
noTimestamp: Bool, noInheritance: Bool,
noInheritance: Bool, filePrefix: String,
filePrefix: String, noClassMocking: Bool,
noClassMocking: Bool, debugMode: Bool,
debugMode: Bool, globEnabled: Bool,
globEnabled: Bool, regex: String,
regex: String, files: [String]
files: [String]
) { ) {
self.output = output self.output = output
self.testableFrameworks = testableFrameworks.components(separatedBy: ",").filter { !$0.isEmpty } self.testableFrameworks = testableFrameworks.components(separatedBy: ",").filter { !$0.isEmpty }

View File

@ -1,6 +1,12 @@
//
// Created by Eric Firestone on 3/22/16.
// Copyright © 2016 Square, Inc. All rights reserved.
// Released under the Apache v2 License.
//
// Adapted from https://gist.github.com/blakemerryman/76312e1cbf8aec248167
import Foundation import Foundation
// Adapted from https://gist.github.com/blakemerryman/76312e1cbf8aec248167
/** /**
Finds files on the file system using pattern matching. Finds files on the file system using pattern matching.
*/ */

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>BundleIsVersionChecked</key>
<false/>
<key>BundleOverwriteAction</key>
<string>upgrade</string>
<key>ChildBundles</key>
<array>
<dict>
<key>BundleOverwriteAction</key>
<string></string>
<key>RootRelativeBundlePath</key>
<string>/usr/local/Frameworks/CuckooGeneratorFramework.framework/Versions/A/Frameworks/FileKit.framework</string>
</dict>
<dict>
<key>BundleOverwriteAction</key>
<string></string>
<key>RootRelativeBundlePath</key>
<string>/usr/local/Frameworks/CuckooGeneratorFramework.framework/Versions/A/Frameworks/Result.framework</string>
</dict>
<dict>
<key>BundleOverwriteAction</key>
<string></string>
<key>RootRelativeBundlePath</key>
<string>/usr/local/Frameworks/CuckooGeneratorFramework.framework/Versions/A/Frameworks/Commandant.framework</string>
</dict>
<dict>
<key>BundleOverwriteAction</key>
<string></string>
<key>RootRelativeBundlePath</key>
<string>/usr/local/Frameworks/CuckooGeneratorFramework.framework/Versions/A/Frameworks/SWXMLHash.framework</string>
</dict>
<dict>
<key>BundleOverwriteAction</key>
<string></string>
<key>RootRelativeBundlePath</key>
<string>/usr/local/Frameworks/CuckooGeneratorFramework.framework/Versions/A/Frameworks/SourceKittenFramework.framework</string>
</dict>
</array>
<key>RootRelativeBundlePath</key>
<string>/usr/local/Frameworks/CuckooGeneratorFramework.framework</string>
</dict>
</array>
</plist>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.8.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 Brightify. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>

View File

@ -1,3 +1,11 @@
//
// VersionCommand.swift
// CuckooGenerator
//
// Created by Tadeas Kriz on 17/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Foundation import Foundation
import Commandant import Commandant
import Result import Result

View File

@ -1,3 +1,12 @@
//#!/usr/bin/swift -F Carthage/Build/Mac
//
// main.swift
// SwiftMockGenerator
//
// Created by Tadeas Kriz on 12/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Foundation import Foundation
import Commandant import Commandant

2
Generator/Tests/Gemfile Normal file
View File

@ -0,0 +1,2 @@
source 'https://rubygems.org'
gem 'aruba', '~> 0.14.1'

View File

@ -0,0 +1,44 @@
GEM
remote: https://rubygems.org/
specs:
aruba (0.14.1)
childprocess (~> 0.5.6)
contracts (~> 0.9)
cucumber (>= 1.3.19)
ffi (~> 1.9.10)
rspec-expectations (>= 2.99)
thor (~> 0.19)
builder (3.2.2)
childprocess (0.5.9)
ffi (~> 1.0, >= 1.0.11)
contracts (0.14.0)
cucumber (2.4.0)
builder (>= 2.1.2)
cucumber-core (~> 1.5.0)
cucumber-wire (~> 0.0.1)
diff-lcs (>= 1.1.3)
gherkin (~> 4.0)
multi_json (>= 1.7.5, < 2.0)
multi_test (>= 0.1.2)
cucumber-core (1.5.0)
gherkin (~> 4.0)
cucumber-wire (0.0.1)
diff-lcs (1.2.5)
ffi (1.9.25)
gherkin (4.0.0)
multi_json (1.12.1)
multi_test (0.1.2)
rspec-expectations (3.4.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.4.0)
rspec-support (3.4.1)
thor (0.19.1)
PLATFORMS
ruby
DEPENDENCIES
aruba (~> 0.14.1)
BUNDLED WITH
1.12.5

View File

@ -0,0 +1,7 @@
/* Multi
line
comment */
@objc
public class ClassWithAttributes {
}

View File

@ -0,0 +1,14 @@
//
// ClassWithInit.swift
// Cuckoo
//
// Created by Tadeas Kriz on 09/02/16.
// Copyright © 2016 Brightify. All rights reserved.
//
class ClassWithInit {
init(parameter: String) {
}
}

View File

@ -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!) {
}
}

View File

@ -0,0 +1,12 @@
//
// EmptyClass.swift
// Cuckoo
//
// Created by Tadeas Kriz on 09/02/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Foundation
class EmptyClass {
}

View File

@ -0,0 +1,43 @@
// MARK: - Mocks generated from file: SourceFiles/ClassWithAttributes.swift
/* Multi
line
comment */
import Cuckoo
public class MockClassWithAttributes: ClassWithAttributes, Cuckoo.Mock {
public typealias MocksType = ClassWithAttributes
public typealias Stubbing = __StubbingProxy_ClassWithAttributes
public typealias Verification = __VerificationProxy_ClassWithAttributes
public let cuckoo_manager = Cuckoo.MockManager()
private var observed: ClassWithAttributes?
public func spy(on victim: ClassWithAttributes) -> Self {
observed = victim
return self
}
public struct __StubbingProxy_ClassWithAttributes: Cuckoo.StubbingProxy {
private let cuckoo_manager: Cuckoo.MockManager
public init(manager: Cuckoo.MockManager) {
self.manager = cuckoo_manager
}
}
public struct __VerificationProxy_ClassWithAttributes: Cuckoo.VerificationProxy {
private let cuckoo_manager: Cuckoo.MockManager
private let callMatcher: Cuckoo.CallMatcher
private let sourceLocation: Cuckoo.SourceLocation
public init(manager: Cuckoo.MockManager, callMatcher: Cuckoo.CallMatcher, sourceLocation: Cuckoo.SourceLocation) {
self.manager = cuckoo_manager
self.callMatcher = callMatcher
self.sourceLocation = sourceLocation
}
}
}
public class ClassWithAttributesStub: ClassWithAttributes {
}

View File

@ -0,0 +1,47 @@
// MARK: - Mocks generated from file: SourceFiles/ClassWithInit.swift
//
// ClassWithInit.swift
// Cuckoo
//
// Created by Tadeas Kriz on 09/02/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Cuckoo
class MockClassWithInit: ClassWithInit, Cuckoo.Mock {
typealias MocksType = ClassWithInit
typealias Stubbing = __StubbingProxy_ClassWithInit
typealias Verification = __VerificationProxy_ClassWithInit
let cuckoo_manager = Cuckoo.MockManager()
private var observed: ClassWithInit?
func spy(on victim: ClassWithInit) -> Self {
observed = victim
return self
}
struct __StubbingProxy_ClassWithInit: Cuckoo.StubbingProxy {
private let cuckoo_manager: Cuckoo.MockManager
init(manager: Cuckoo.MockManager) {
self.manager = cuckoo_manager
}
}
struct __VerificationProxy_ClassWithInit: Cuckoo.VerificationProxy {
private let cuckoo_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 = cuckoo_manager
self.callMatcher = callMatcher
self.sourceLocation = sourceLocation
}
}
}
class ClassWithInitStub: ClassWithInit {
}

View File

@ -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 cuckoo_manager = Cuckoo.MockManager()
private var observed: ClassWithOptionals?
func spy(on victim: ClassWithOptionals) -> Self {
observed = victim
return self
}
override var value: Int? {
get {
return cuckoo_manager.getter("value", original: observed.map { o in return { () -> Int? in o.value } })
}
set {
cuckoo_manager.setter("value", value: newValue, original: observed != nil ? { self.observed?.value = $0 } : nil)
}
}
override var uValue: Int! {
get {
return cuckoo_manager.getter("uValue", original: observed.map { o in return { () -> Int! in o.uValue } })
}
set {
cuckoo_manager.setter("uValue", value: newValue, original: observed != nil ? { self.observed?.uValue = $0 } : nil)
}
}
override var array: [Int?] {
get {
return cuckoo_manager.getter("array", original: observed.map { o in return { () -> [Int?] in o.array } })
}
set {
cuckoo_manager.setter("array", value: newValue, original: observed != nil ? { self.observed?.array = $0 } : nil)
}
}
override var closure: (Int?) -> Void {
get {
return cuckoo_manager.getter("closure", original: observed.map { o in return { () -> (Int?) -> Void in o.closure } })
}
set {
cuckoo_manager.setter("closure", value: newValue, original: observed != nil ? { self.observed?.closure = $0 } : nil)
}
}
override var uClosure: (Int!) -> Void {
get {
return cuckoo_manager.getter("uClosure", original: observed.map { o in return { () -> (Int!) -> Void in o.uClosure } })
}
set {
cuckoo_manager.setter("uClosure", value: newValue, original: observed != nil ? { self.observed?.uClosure = $0 } : nil)
}
}
override func returnValue() -> Int? {
return cuckoo_manager.call("returnValue() -> Int?", parameters: (), original: observed.map { o in return { () -> Int? in o.returnValue() } })
}
override func returnUValue() -> Int! {
return cuckoo_manager.call("returnUValue() -> Int!", parameters: (), original: observed.map { o in return { () -> Int! in o.returnUValue() } })
}
override func returnArray() -> [Int?] {
return cuckoo_manager.call("returnArray() -> [Int?]", parameters: (), original: observed.map { o in return { () -> [Int?] in o.returnArray() } })
}
override func parameter(parameter: Int?) {
return cuckoo_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 cuckoo_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 cuckoo_manager: Cuckoo.MockManager
init(manager: Cuckoo.MockManager) {
self.manager = cuckoo_manager
}
var value: Cuckoo.ToBeStubbedProperty<Int?> {
return Cuckoo.ToBeStubbedProperty(manager: cuckoo_manager, name: "value")
}
var uValue: Cuckoo.ToBeStubbedProperty<Int?> {
return Cuckoo.ToBeStubbedProperty(manager: cuckoo_manager, name: "uValue")
}
var array: Cuckoo.ToBeStubbedProperty<[Int?]> {
return Cuckoo.ToBeStubbedProperty(manager: cuckoo_manager, name: "array")
}
var closure: Cuckoo.ToBeStubbedProperty<(Int?) -> Void> {
return Cuckoo.ToBeStubbedProperty(manager: cuckoo_manager, name: "closure")
}
var uClosure: Cuckoo.ToBeStubbedProperty<(Int?) -> Void> {
return Cuckoo.ToBeStubbedProperty(manager: cuckoo_manager, name: "uClosure")
}
func returnValue() -> Cuckoo.StubFunction<(), Int?> {
return Cuckoo.StubFunction(stub: cuckoo_manager.createStub("returnValue() -> Int?", parameterMatchers: []))
}
func returnUValue() -> Cuckoo.StubFunction<(), Int?> {
return Cuckoo.StubFunction(stub: cuckoo_manager.createStub("returnUValue() -> Int!", parameterMatchers: []))
}
func returnArray() -> Cuckoo.StubFunction<(), [Int?]> {
return Cuckoo.StubFunction(stub: cuckoo_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: cuckoo_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: cuckoo_manager.createStub("uParameter(parameter: Int!)", parameterMatchers: matchers))
}
}
struct __VerificationProxy_ClassWithOptionals: Cuckoo.VerificationProxy {
private let cuckoo_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 = cuckoo_manager
self.callMatcher = callMatcher
self.sourceLocation = sourceLocation
}
var value: Cuckoo.VerifyProperty<Int?> {
return Cuckoo.VerifyProperty(manager: cuckoo_manager, name: "value", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
var uValue: Cuckoo.VerifyProperty<Int?> {
return Cuckoo.VerifyProperty(manager: cuckoo_manager, name: "uValue", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
var array: Cuckoo.VerifyProperty<[Int?]> {
return Cuckoo.VerifyProperty(manager: cuckoo_manager, name: "array", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
var closure: Cuckoo.VerifyProperty<(Int?) -> Void> {
return Cuckoo.VerifyProperty(manager: cuckoo_manager, name: "closure", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
var uClosure: Cuckoo.VerifyProperty<(Int?) -> Void> {
return Cuckoo.VerifyProperty(manager: cuckoo_manager, name: "uClosure", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
@discardableResult
func returnValue() -> Cuckoo.__DoNotUse<Int?> {
return cuckoo_manager.verify("returnValue() -> Int?", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
}
@discardableResult
func returnUValue() -> Cuckoo.__DoNotUse<Int?> {
return cuckoo_manager.verify("returnUValue() -> Int!", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
}
@discardableResult
func returnArray() -> Cuckoo.__DoNotUse<[Int?]> {
return cuckoo_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 cuckoo_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 cuckoo_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)
}
}

View File

@ -0,0 +1,527 @@
// MARK: - Mocks generated from file: SourceFiles/TestedClass.swift
//
// TestedClass.swift
// Cuckoo
//
// Created by Tadeas Kriz on 09/02/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Cuckoo
class MockTestedClass: TestedClass, Cuckoo.Mock {
typealias MocksType = TestedClass
typealias Stubbing = __StubbingProxy_TestedClass
typealias Verification = __VerificationProxy_TestedClass
let cuckoo_manager = Cuckoo.MockManager()
private var observed: TestedClass?
func spy(on victim: TestedClass) -> Self {
observed = victim
return self
}
override var readOnlyProperty: String {
get {
return cuckoo_manager.getter("readOnlyProperty", original: observed.map { o in return { () -> String in o.readOnlyProperty } })
}
}
override var readWriteProperty: Int {
get {
return cuckoo_manager.getter("readWriteProperty", original: observed.map { o in return { () -> Int in o.readWriteProperty } })
}
set {
cuckoo_manager.setter("readWriteProperty", value: newValue, original: observed != nil ? { self.observed?.readWriteProperty = $0 } : nil)
}
}
override var optionalProperty: Int? {
get {
return cuckoo_manager.getter("optionalProperty", original: observed.map { o in return { () -> Int? in o.optionalProperty } })
}
set {
cuckoo_manager.setter("optionalProperty", value: newValue, original: observed != nil ? { self.observed?.optionalProperty = $0 } : nil)
}
}
override func noReturn() {
return cuckoo_manager.call("noReturn()", parameters: (), original: observed.map { o in return { () in o.noReturn() } })
}
override func count(characters: String) -> Int {
return cuckoo_manager.call("count(characters: String) -> Int", parameters: (characters), original: observed.map { o in return { (characters: String) -> Int in o.count(characters: characters) } })
}
override func withThrows() throws -> Int {
return try cuckoo_manager.callThrows("withThrows() throws -> Int", parameters: (), original: observed.map { o in return { () throws -> Int in try o.withThrows() } })
}
override func withNoReturnThrows() throws {
return try cuckoo_manager.callThrows("withNoReturnThrows() throws", parameters: (), original: observed.map { o in return { () throws in try o.withNoReturnThrows() } })
}
override func withClosure(_ closure: (String) -> Int) -> Int {
return cuckoo_manager.call("withClosure(_: (String) -> Int) -> Int", parameters: (closure), original: observed.map { o in return { (closure: (String) -> Int) -> Int in o.withClosure(closure) } })
}
override func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
return cuckoo_manager.call("withEscape(_: String, action: @escaping (String) -> Void)", parameters: (a, closure), original: observed.map { o in return { (a: String, closure: @escaping (String) -> Void) in o.withEscape(a, action: closure) } })
}
override func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
return cuckoo_manager.call("withOptionalClosure(_: String, closure: ((String) -> Void)?)", parameters: (a, closure), original: observed.map { o in return { (a: String, closure: ((String) -> Void)?) in o.withOptionalClosure(a, closure: closure) } })
}
override func withLabelAndUnderscore(labelA a: String, _ b: String) {
return cuckoo_manager.call("withLabelAndUnderscore(labelA: String, _: String)", parameters: (a, b), original: observed.map { o in return { (a: String, b: String) in o.withLabelAndUnderscore(labelA: a, b) } })
}
struct __StubbingProxy_TestedClass: Cuckoo.StubbingProxy {
private let cuckoo_manager: Cuckoo.MockManager
init(manager: Cuckoo.MockManager) {
self.manager = cuckoo_manager
}
var readOnlyProperty: Cuckoo.ToBeStubbedReadOnlyProperty<String> {
return Cuckoo.ToBeStubbedReadOnlyProperty(manager: cuckoo_manager, name: "readOnlyProperty")
}
var readWriteProperty: Cuckoo.ToBeStubbedProperty<Int> {
return Cuckoo.ToBeStubbedProperty(manager: cuckoo_manager, name: "readWriteProperty")
}
var optionalProperty: Cuckoo.ToBeStubbedProperty<Int?> {
return Cuckoo.ToBeStubbedProperty(manager: cuckoo_manager, name: "optionalProperty")
}
func noReturn() -> Cuckoo.StubNoReturnFunction<()> {
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("noReturn()", parameterMatchers: []))
}
func count<M1: Cuckoo.Matchable>(characters: M1) -> Cuckoo.StubFunction<(String), Int> where M1.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String)>] = [wrap(matchable: characters) { $0 }]
return Cuckoo.StubFunction(stub: cuckoo_manager.createStub("count(characters: String) -> Int", parameterMatchers: matchers))
}
func withThrows() -> Cuckoo.StubThrowingFunction<(), Int> {
return Cuckoo.StubThrowingFunction(stub: cuckoo_manager.createStub("withThrows() throws -> Int", parameterMatchers: []))
}
func withNoReturnThrows() -> Cuckoo.StubNoReturnThrowingFunction<()> {
return Cuckoo.StubNoReturnThrowingFunction(stub: cuckoo_manager.createStub("withNoReturnThrows() throws", parameterMatchers: []))
}
func withClosure<M1: Cuckoo.Matchable>(_ closure: M1) -> Cuckoo.StubFunction<((String) -> Int), Int> where M1.MatchedType == (String) -> Int {
let matchers: [Cuckoo.ParameterMatcher<((String) -> Int)>] = [wrap(matchable: closure) { $0 }]
return Cuckoo.StubFunction(stub: cuckoo_manager.createStub("withClosure(_: (String) -> Int) -> Int", parameterMatchers: matchers))
}
func withEscape<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, action closure: M2) -> Cuckoo.StubNoReturnFunction<(String, (String) -> Void)> where M1.MatchedType == String, M2.MatchedType == (String) -> Void {
let matchers: [Cuckoo.ParameterMatcher<(String, (String) -> Void)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("withEscape(_: String, action: @escaping (String) -> Void)", parameterMatchers: matchers))
}
func withOptionalClosure<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, closure: M2) -> Cuckoo.StubNoReturnFunction<(String, ((String) -> Void)?)> where M1.MatchedType == String, M2.MatchedType == ((String) -> Void)? {
let matchers: [Cuckoo.ParameterMatcher<(String, ((String) -> Void)?)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("withOptionalClosure(_: String, closure: ((String) -> Void)?)", parameterMatchers: matchers))
}
func withLabelAndUnderscore<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(labelA a: M1, _ b: M2) -> Cuckoo.StubNoReturnFunction<(String, String)> where M1.MatchedType == String, M2.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String, String)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: b) { $0.1 }]
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("withLabelAndUnderscore(labelA: String, _: String)", parameterMatchers: matchers))
}
}
struct __VerificationProxy_TestedClass: Cuckoo.VerificationProxy {
private let cuckoo_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 = cuckoo_manager
self.callMatcher = callMatcher
self.sourceLocation = sourceLocation
}
var readOnlyProperty: Cuckoo.VerifyReadOnlyProperty<String> {
return Cuckoo.VerifyReadOnlyProperty(manager: cuckoo_manager, name: "readOnlyProperty", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
var readWriteProperty: Cuckoo.VerifyProperty<Int> {
return Cuckoo.VerifyProperty(manager: cuckoo_manager, name: "readWriteProperty", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
var optionalProperty: Cuckoo.VerifyProperty<Int?> {
return Cuckoo.VerifyProperty(manager: cuckoo_manager, name: "optionalProperty", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
@discardableResult
func noReturn() -> Cuckoo.__DoNotUse<Void> {
return cuckoo_manager.verify("noReturn()", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
}
@discardableResult
func count<M1: Cuckoo.Matchable>(characters: M1) -> Cuckoo.__DoNotUse<Int> where M1.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String)>] = [wrap(matchable: characters) { $0 }]
return cuckoo_manager.verify("count(characters: String) -> Int", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withThrows() -> Cuckoo.__DoNotUse<Int> {
return cuckoo_manager.verify("withThrows() throws -> Int", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
}
@discardableResult
func withNoReturnThrows() -> Cuckoo.__DoNotUse<Void> {
return cuckoo_manager.verify("withNoReturnThrows() throws", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
}
@discardableResult
func withClosure<M1: Cuckoo.Matchable>(_ closure: M1) -> Cuckoo.__DoNotUse<Int> where M1.MatchedType == (String) -> Int {
let matchers: [Cuckoo.ParameterMatcher<((String) -> Int)>] = [wrap(matchable: closure) { $0 }]
return cuckoo_manager.verify("withClosure(_: (String) -> Int) -> Int", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withEscape<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, action closure: M2) -> Cuckoo.__DoNotUse<Void> where M1.MatchedType == String, M2.MatchedType == (String) -> Void {
let matchers: [Cuckoo.ParameterMatcher<(String, (String) -> Void)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return cuckoo_manager.verify("withEscape(_: String, action: @escaping (String) -> Void)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withOptionalClosure<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, closure: M2) -> Cuckoo.__DoNotUse<Void> where M1.MatchedType == String, M2.MatchedType == ((String) -> Void)? {
let matchers: [Cuckoo.ParameterMatcher<(String, ((String) -> Void)?)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return cuckoo_manager.verify("withOptionalClosure(_: String, closure: ((String) -> Void)?)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withLabelAndUnderscore<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(labelA a: M1, _ b: M2) -> Cuckoo.__DoNotUse<Void> where M1.MatchedType == String, M2.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String, String)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: b) { $0.1 }]
return cuckoo_manager.verify("withLabelAndUnderscore(labelA: String, _: String)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
}
}
class TestedClassStub: TestedClass {
override var readOnlyProperty: String {
get {
return DefaultValueRegistry.defaultValue(for: (String).self)
}
}
override var readWriteProperty: Int {
get {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
set {
}
}
override var optionalProperty: Int? {
get {
return DefaultValueRegistry.defaultValue(for: (Int?).self)
}
set {
}
}
override func noReturn() {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
override func count(characters: String) -> Int {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
override func withThrows() throws -> Int {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
override func withNoReturnThrows() throws {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
override func withClosure(_ closure: (String) -> Int) -> Int {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
override func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
override func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
override func withLabelAndUnderscore(labelA a: String, _ b: String) {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
}
// MARK: - Mocks generated from file: SourceFiles/TestedProtocol.swift
//
// TestedProtocol.swift
// Cuckoo
//
// Created by Tadeas Kriz on 18/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Cuckoo
class MockTestedProtocol: TestedProtocol, Cuckoo.Mock {
typealias MocksType = TestedProtocol
typealias Stubbing = __StubbingProxy_TestedProtocol
typealias Verification = __VerificationProxy_TestedProtocol
let cuckoo_manager = Cuckoo.MockManager()
private var observed: TestedProtocol?
func spy(on victim: TestedProtocol) -> Self {
observed = victim
return self
}
var readOnlyProperty: String {
get {
return cuckoo_manager.getter("readOnlyProperty", original: observed.map { o in return { () -> String in o.readOnlyProperty } })
}
}
var readWriteProperty: Int {
get {
return cuckoo_manager.getter("readWriteProperty", original: observed.map { o in return { () -> Int in o.readWriteProperty } })
}
set {
cuckoo_manager.setter("readWriteProperty", value: newValue, original: observed != nil ? { self.observed?.readWriteProperty = $0 } : nil)
}
}
var optionalProperty: Int? {
get {
return cuckoo_manager.getter("optionalProperty", original: observed.map { o in return { () -> Int? in o.optionalProperty } })
}
set {
cuckoo_manager.setter("optionalProperty", value: newValue, original: observed != nil ? { self.observed?.optionalProperty = $0 } : nil)
}
}
func noReturn() {
return cuckoo_manager.call("noReturn()", parameters: (), original: observed.map { o in return { () in o.noReturn() } })
}
func count(characters: String) -> Int {
return cuckoo_manager.call("count(characters: String) -> Int", parameters: (characters), original: observed.map { o in return { (characters: String) -> Int in o.count(characters: characters) } })
}
func withThrows() throws -> Int {
return try cuckoo_manager.callThrows("withThrows() throws -> Int", parameters: (), original: observed.map { o in return { () throws -> Int in try o.withThrows() } })
}
func withNoReturnThrows() throws {
return try cuckoo_manager.callThrows("withNoReturnThrows() throws", parameters: (), original: observed.map { o in return { () throws in try o.withNoReturnThrows() } })
}
func withClosure(_ closure: (String) -> Int) -> Int {
return cuckoo_manager.call("withClosure(_: (String) -> Int) -> Int", parameters: (closure), original: observed.map { o in return { (closure: (String) -> Int) -> Int in o.withClosure(closure) } })
}
func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
return cuckoo_manager.call("withEscape(_: String, action: @escaping (String) -> Void)", parameters: (a, closure), original: observed.map { o in return { (a: String, closure: @escaping (String) -> Void) in o.withEscape(a, action: closure) } })
}
func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
return cuckoo_manager.call("withOptionalClosure(_: String, closure: ((String) -> Void)?)", parameters: (a, closure), original: observed.map { o in return { (a: String, closure: ((String) -> Void)?) in o.withOptionalClosure(a, closure: closure) } })
}
func withLabelAndUnderscore(labelA a: String, _ b: String) {
return cuckoo_manager.call("withLabelAndUnderscore(labelA: String, _: String)", parameters: (a, b), original: observed.map { o in return { (a: String, b: String) in o.withLabelAndUnderscore(labelA: a, b) } })
}
struct __StubbingProxy_TestedProtocol: Cuckoo.StubbingProxy {
private let cuckoo_manager: Cuckoo.MockManager
init(manager: Cuckoo.MockManager) {
self.manager = cuckoo_manager
}
var readOnlyProperty: Cuckoo.ToBeStubbedReadOnlyProperty<String> {
return Cuckoo.ToBeStubbedReadOnlyProperty(manager: cuckoo_manager, name: "readOnlyProperty")
}
var readWriteProperty: Cuckoo.ToBeStubbedProperty<Int> {
return Cuckoo.ToBeStubbedProperty(manager: cuckoo_manager, name: "readWriteProperty")
}
var optionalProperty: Cuckoo.ToBeStubbedProperty<Int?> {
return Cuckoo.ToBeStubbedProperty(manager: cuckoo_manager, name: "optionalProperty")
}
func noReturn() -> Cuckoo.StubNoReturnFunction<()> {
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("noReturn()", parameterMatchers: []))
}
func count<M1: Cuckoo.Matchable>(characters: M1) -> Cuckoo.StubFunction<(String), Int> where M1.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String)>] = [wrap(matchable: characters) { $0 }]
return Cuckoo.StubFunction(stub: cuckoo_manager.createStub("count(characters: String) -> Int", parameterMatchers: matchers))
}
func withThrows() -> Cuckoo.StubThrowingFunction<(), Int> {
return Cuckoo.StubThrowingFunction(stub: cuckoo_manager.createStub("withThrows() throws -> Int", parameterMatchers: []))
}
func withNoReturnThrows() -> Cuckoo.StubNoReturnThrowingFunction<()> {
return Cuckoo.StubNoReturnThrowingFunction(stub: cuckoo_manager.createStub("withNoReturnThrows() throws", parameterMatchers: []))
}
func withClosure<M1: Cuckoo.Matchable>(_ closure: M1) -> Cuckoo.StubFunction<((String) -> Int), Int> where M1.MatchedType == (String) -> Int {
let matchers: [Cuckoo.ParameterMatcher<((String) -> Int)>] = [wrap(matchable: closure) { $0 }]
return Cuckoo.StubFunction(stub: cuckoo_manager.createStub("withClosure(_: (String) -> Int) -> Int", parameterMatchers: matchers))
}
func withEscape<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, action closure: M2) -> Cuckoo.StubNoReturnFunction<(String, (String) -> Void)> where M1.MatchedType == String, M2.MatchedType == (String) -> Void {
let matchers: [Cuckoo.ParameterMatcher<(String, (String) -> Void)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("withEscape(_: String, action: @escaping (String) -> Void)", parameterMatchers: matchers))
}
func withOptionalClosure<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, closure: M2) -> Cuckoo.StubNoReturnFunction<(String, ((String) -> Void)?)> where M1.MatchedType == String, M2.MatchedType == ((String) -> Void)? {
let matchers: [Cuckoo.ParameterMatcher<(String, ((String) -> Void)?)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("withOptionalClosure(_: String, closure: ((String) -> Void)?)", parameterMatchers: matchers))
}
func withLabelAndUnderscore<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(labelA a: M1, _ b: M2) -> Cuckoo.StubNoReturnFunction<(String, String)> where M1.MatchedType == String, M2.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String, String)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: b) { $0.1 }]
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("withLabelAndUnderscore(labelA: String, _: String)", parameterMatchers: matchers))
}
}
struct __VerificationProxy_TestedProtocol: Cuckoo.VerificationProxy {
private let cuckoo_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 = cuckoo_manager
self.callMatcher = callMatcher
self.sourceLocation = sourceLocation
}
var readOnlyProperty: Cuckoo.VerifyReadOnlyProperty<String> {
return Cuckoo.VerifyReadOnlyProperty(manager: cuckoo_manager, name: "readOnlyProperty", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
var readWriteProperty: Cuckoo.VerifyProperty<Int> {
return Cuckoo.VerifyProperty(manager: cuckoo_manager, name: "readWriteProperty", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
var optionalProperty: Cuckoo.VerifyProperty<Int?> {
return Cuckoo.VerifyProperty(manager: cuckoo_manager, name: "optionalProperty", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
@discardableResult
func noReturn() -> Cuckoo.__DoNotUse<Void> {
return cuckoo_manager.verify("noReturn()", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
}
@discardableResult
func count<M1: Cuckoo.Matchable>(characters: M1) -> Cuckoo.__DoNotUse<Int> where M1.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String)>] = [wrap(matchable: characters) { $0 }]
return cuckoo_manager.verify("count(characters: String) -> Int", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withThrows() -> Cuckoo.__DoNotUse<Int> {
return cuckoo_manager.verify("withThrows() throws -> Int", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
}
@discardableResult
func withNoReturnThrows() -> Cuckoo.__DoNotUse<Void> {
return cuckoo_manager.verify("withNoReturnThrows() throws", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
}
@discardableResult
func withClosure<M1: Cuckoo.Matchable>(_ closure: M1) -> Cuckoo.__DoNotUse<Int> where M1.MatchedType == (String) -> Int {
let matchers: [Cuckoo.ParameterMatcher<((String) -> Int)>] = [wrap(matchable: closure) { $0 }]
return cuckoo_manager.verify("withClosure(_: (String) -> Int) -> Int", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withEscape<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, action closure: M2) -> Cuckoo.__DoNotUse<Void> where M1.MatchedType == String, M2.MatchedType == (String) -> Void {
let matchers: [Cuckoo.ParameterMatcher<(String, (String) -> Void)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return cuckoo_manager.verify("withEscape(_: String, action: @escaping (String) -> Void)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withOptionalClosure<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, closure: M2) -> Cuckoo.__DoNotUse<Void> where M1.MatchedType == String, M2.MatchedType == ((String) -> Void)? {
let matchers: [Cuckoo.ParameterMatcher<(String, ((String) -> Void)?)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return cuckoo_manager.verify("withOptionalClosure(_: String, closure: ((String) -> Void)?)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withLabelAndUnderscore<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(labelA a: M1, _ b: M2) -> Cuckoo.__DoNotUse<Void> where M1.MatchedType == String, M2.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String, String)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: b) { $0.1 }]
return cuckoo_manager.verify("withLabelAndUnderscore(labelA: String, _: String)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
}
}
class TestedProtocolStub: TestedProtocol {
var readOnlyProperty: String {
get {
return DefaultValueRegistry.defaultValue(for: (String).self)
}
}
var readWriteProperty: Int {
get {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
set {
}
}
var optionalProperty: Int? {
get {
return DefaultValueRegistry.defaultValue(for: (Int?).self)
}
set {
}
}
func noReturn() {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
func count(characters: String) -> Int {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
func withThrows() throws -> Int {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
func withNoReturnThrows() throws {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
func withClosure(_ closure: (String) -> Int) -> Int {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
func withLabelAndUnderscore(labelA a: String, _ b: String) {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
}

View File

@ -0,0 +1,57 @@
// MARK: - Mocks generated from file: SourceFiles/Imports.swift
//
// Imports.swift
// Cuckoo
//
// Created by Tadeas Kriz on 18/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Cuckoo
import a
import b
import c
import d
import e
import f
import g
import h
import i
class MockA: A, Cuckoo.Mock {
typealias MocksType = A
typealias Stubbing = __StubbingProxy_A
typealias Verification = __VerificationProxy_A
let cuckoo_manager = Cuckoo.MockManager()
private var observed: A?
func spy(on victim: A) -> Self {
observed = victim
return self
}
struct __StubbingProxy_A: Cuckoo.StubbingProxy {
private let cuckoo_manager: Cuckoo.MockManager
init(manager: Cuckoo.MockManager) {
self.manager = cuckoo_manager
}
}
struct __VerificationProxy_A: Cuckoo.VerificationProxy {
private let cuckoo_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 = cuckoo_manager
self.callMatcher = callMatcher
self.sourceLocation = sourceLocation
}
}
}
class AStub: A {
}

View File

@ -0,0 +1,84 @@
// MARK: - Mocks generated from file: SourceFiles/MultipleClasses.swift
//
// MultipleClasses.swift
// Cuckoo
//
// Created by Tadeas Kriz on 18/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Cuckoo
class MockA: A, Cuckoo.Mock {
typealias MocksType = A
typealias Stubbing = __StubbingProxy_A
typealias Verification = __VerificationProxy_A
let cuckoo_manager = Cuckoo.MockManager()
private var observed: A?
func spy(on victim: A) -> Self {
observed = victim
return self
}
struct __StubbingProxy_A: Cuckoo.StubbingProxy {
private let cuckoo_manager: Cuckoo.MockManager
init(manager: Cuckoo.MockManager) {
self.manager = cuckoo_manager
}
}
struct __VerificationProxy_A: Cuckoo.VerificationProxy {
private let cuckoo_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 = cuckoo_manager
self.callMatcher = callMatcher
self.sourceLocation = sourceLocation
}
}
}
class AStub: A {
}
class MockB: B, Cuckoo.Mock {
typealias MocksType = B
typealias Stubbing = __StubbingProxy_B
typealias Verification = __VerificationProxy_B
let cuckoo_manager = Cuckoo.MockManager()
private var observed: B?
func spy(on victim: B) -> Self {
observed = victim
return self
}
struct __StubbingProxy_B: Cuckoo.StubbingProxy {
private let cuckoo_manager: Cuckoo.MockManager
init(manager: Cuckoo.MockManager) {
self.manager = cuckoo_manager
}
}
struct __VerificationProxy_B: Cuckoo.VerificationProxy {
private let cuckoo_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 = cuckoo_manager
self.callMatcher = callMatcher
self.sourceLocation = sourceLocation
}
}
}
class BStub: B {
}

View File

@ -0,0 +1,40 @@
import Cuckoo
import Foundation
class MockEmptyClass: EmptyClass, Cuckoo.Mock {
typealias MocksType = EmptyClass
typealias Stubbing = __StubbingProxy_EmptyClass
typealias Verification = __VerificationProxy_EmptyClass
let cuckoo_manager = Cuckoo.MockManager()
private var observed: EmptyClass?
func spy(on victim: EmptyClass) -> Self {
observed = victim
return self
}
struct __StubbingProxy_EmptyClass: Cuckoo.StubbingProxy {
private let cuckoo_manager: Cuckoo.MockManager
init(manager: Cuckoo.MockManager) {
self.manager = cuckoo_manager
}
}
struct __VerificationProxy_EmptyClass: Cuckoo.VerificationProxy {
private let cuckoo_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 = cuckoo_manager
self.callMatcher = callMatcher
self.sourceLocation = sourceLocation
}
}
}
class EmptyClassStub: EmptyClass {
}

View File

@ -0,0 +1,10 @@
// MARK: - Mocks generated from file: SourceFiles/Struct.swift
//
// Struct.swift
// Cuckoo
//
// Created by Tadeas Kriz on 09/02/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Cuckoo

View File

@ -0,0 +1,53 @@
// MARK: - Mocks generated from file: SourceFiles/EmptyClass.swift
//
// EmptyClass.swift
// Cuckoo
//
// Created by Tadeas Kriz on 09/02/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Cuckoo
@testable import Cuckoo
@testable import A_b
@testable import A_c
@testable import A_d
import Foundation
class MockEmptyClass: EmptyClass, Cuckoo.Mock {
typealias MocksType = EmptyClass
typealias Stubbing = __StubbingProxy_EmptyClass
typealias Verification = __VerificationProxy_EmptyClass
let cuckoo_manager = Cuckoo.MockManager()
private var observed: EmptyClass?
func spy(on victim: EmptyClass) -> Self {
observed = victim
return self
}
struct __StubbingProxy_EmptyClass: Cuckoo.StubbingProxy {
private let cuckoo_manager: Cuckoo.MockManager
init(manager: Cuckoo.MockManager) {
self.manager = cuckoo_manager
}
}
struct __VerificationProxy_EmptyClass: Cuckoo.VerificationProxy {
private let cuckoo_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 = cuckoo_manager
self.callMatcher = callMatcher
self.sourceLocation = sourceLocation
}
}
}
class EmptyClassStub: EmptyClass {
}

View File

@ -0,0 +1,263 @@
// MARK: - Mocks generated from file: SourceFiles/TestedProtocol.swift
//
// TestedProtocol.swift
// Cuckoo
//
// Created by Tadeas Kriz on 18/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import Cuckoo
class MockTestedProtocol: TestedProtocol, Cuckoo.Mock {
typealias MocksType = TestedProtocol
typealias Stubbing = __StubbingProxy_TestedProtocol
typealias Verification = __VerificationProxy_TestedProtocol
let cuckoo_manager = Cuckoo.MockManager()
private var observed: TestedProtocol?
func spy(on victim: TestedProtocol) -> Self {
observed = victim
return self
}
var readOnlyProperty: String {
get {
return cuckoo_manager.getter("readOnlyProperty", original: observed.map { o in return { () -> String in o.readOnlyProperty } })
}
}
var readWriteProperty: Int {
get {
return cuckoo_manager.getter("readWriteProperty", original: observed.map { o in return { () -> Int in o.readWriteProperty } })
}
set {
cuckoo_manager.setter("readWriteProperty", value: newValue, original: observed != nil ? { self.observed?.readWriteProperty = $0 } : nil)
}
}
var optionalProperty: Int? {
get {
return cuckoo_manager.getter("optionalProperty", original: observed.map { o in return { () -> Int? in o.optionalProperty } })
}
set {
cuckoo_manager.setter("optionalProperty", value: newValue, original: observed != nil ? { self.observed?.optionalProperty = $0 } : nil)
}
}
func noReturn() {
return cuckoo_manager.call("noReturn()", parameters: (), original: observed.map { o in return { () in o.noReturn() } })
}
func count(characters: String) -> Int {
return cuckoo_manager.call("count(characters: String) -> Int", parameters: (characters), original: observed.map { o in return { (characters: String) -> Int in o.count(characters: characters) } })
}
func withThrows() throws -> Int {
return try cuckoo_manager.callThrows("withThrows() throws -> Int", parameters: (), original: observed.map { o in return { () throws -> Int in try o.withThrows() } })
}
func withNoReturnThrows() throws {
return try cuckoo_manager.callThrows("withNoReturnThrows() throws", parameters: (), original: observed.map { o in return { () throws in try o.withNoReturnThrows() } })
}
func withClosure(_ closure: (String) -> Int) -> Int {
return cuckoo_manager.call("withClosure(_: (String) -> Int) -> Int", parameters: (closure), original: observed.map { o in return { (closure: (String) -> Int) -> Int in o.withClosure(closure) } })
}
func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
return cuckoo_manager.call("withEscape(_: String, action: @escaping (String) -> Void)", parameters: (a, closure), original: observed.map { o in return { (a: String, closure: @escaping (String) -> Void) in o.withEscape(a, action: closure) } })
}
func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
return cuckoo_manager.call("withOptionalClosure(_: String, closure: ((String) -> Void)?)", parameters: (a, closure), original: observed.map { o in return { (a: String, closure: ((String) -> Void)?) in o.withOptionalClosure(a, closure: closure) } })
}
func withLabelAndUnderscore(labelA a: String, _ b: String) {
return cuckoo_manager.call("withLabelAndUnderscore(labelA: String, _: String)", parameters: (a, b), original: observed.map { o in return { (a: String, b: String) in o.withLabelAndUnderscore(labelA: a, b) } })
}
struct __StubbingProxy_TestedProtocol: Cuckoo.StubbingProxy {
private let cuckoo_manager: Cuckoo.MockManager
init(manager: Cuckoo.MockManager) {
self.manager = cuckoo_manager
}
var readOnlyProperty: Cuckoo.ToBeStubbedReadOnlyProperty<String> {
return Cuckoo.ToBeStubbedReadOnlyProperty(manager: cuckoo_manager, name: "readOnlyProperty")
}
var readWriteProperty: Cuckoo.ToBeStubbedProperty<Int> {
return Cuckoo.ToBeStubbedProperty(manager: cuckoo_manager, name: "readWriteProperty")
}
var optionalProperty: Cuckoo.ToBeStubbedProperty<Int?> {
return Cuckoo.ToBeStubbedProperty(manager: cuckoo_manager, name: "optionalProperty")
}
func noReturn() -> Cuckoo.StubNoReturnFunction<()> {
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("noReturn()", parameterMatchers: []))
}
func count<M1: Cuckoo.Matchable>(characters: M1) -> Cuckoo.StubFunction<(String), Int> where M1.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String)>] = [wrap(matchable: characters) { $0 }]
return Cuckoo.StubFunction(stub: cuckoo_manager.createStub("count(characters: String) -> Int", parameterMatchers: matchers))
}
func withThrows() -> Cuckoo.StubThrowingFunction<(), Int> {
return Cuckoo.StubThrowingFunction(stub: cuckoo_manager.createStub("withThrows() throws -> Int", parameterMatchers: []))
}
func withNoReturnThrows() -> Cuckoo.StubNoReturnThrowingFunction<()> {
return Cuckoo.StubNoReturnThrowingFunction(stub: cuckoo_manager.createStub("withNoReturnThrows() throws", parameterMatchers: []))
}
func withClosure<M1: Cuckoo.Matchable>(_ closure: M1) -> Cuckoo.StubFunction<((String) -> Int), Int> where M1.MatchedType == (String) -> Int {
let matchers: [Cuckoo.ParameterMatcher<((String) -> Int)>] = [wrap(matchable: closure) { $0 }]
return Cuckoo.StubFunction(stub: cuckoo_manager.createStub("withClosure(_: (String) -> Int) -> Int", parameterMatchers: matchers))
}
func withEscape<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, action closure: M2) -> Cuckoo.StubNoReturnFunction<(String, (String) -> Void)> where M1.MatchedType == String, M2.MatchedType == (String) -> Void {
let matchers: [Cuckoo.ParameterMatcher<(String, (String) -> Void)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("withEscape(_: String, action: @escaping (String) -> Void)", parameterMatchers: matchers))
}
func withOptionalClosure<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, closure: M2) -> Cuckoo.StubNoReturnFunction<(String, ((String) -> Void)?)> where M1.MatchedType == String, M2.MatchedType == ((String) -> Void)? {
let matchers: [Cuckoo.ParameterMatcher<(String, ((String) -> Void)?)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("withOptionalClosure(_: String, closure: ((String) -> Void)?)", parameterMatchers: matchers))
}
func withLabelAndUnderscore<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(labelA a: M1, _ b: M2) -> Cuckoo.StubNoReturnFunction<(String, String)> where M1.MatchedType == String, M2.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String, String)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: b) { $0.1 }]
return Cuckoo.StubNoReturnFunction(stub: cuckoo_manager.createStub("withLabelAndUnderscore(labelA: String, _: String)", parameterMatchers: matchers))
}
}
struct __VerificationProxy_TestedProtocol: Cuckoo.VerificationProxy {
private let cuckoo_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 = cuckoo_manager
self.callMatcher = callMatcher
self.sourceLocation = sourceLocation
}
var readOnlyProperty: Cuckoo.VerifyReadOnlyProperty<String> {
return Cuckoo.VerifyReadOnlyProperty(manager: cuckoo_manager, name: "readOnlyProperty", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
var readWriteProperty: Cuckoo.VerifyProperty<Int> {
return Cuckoo.VerifyProperty(manager: cuckoo_manager, name: "readWriteProperty", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
var optionalProperty: Cuckoo.VerifyProperty<Int?> {
return Cuckoo.VerifyProperty(manager: cuckoo_manager, name: "optionalProperty", callMatcher: callMatcher, sourceLocation: sourceLocation)
}
@discardableResult
func noReturn() -> Cuckoo.__DoNotUse<Void> {
return cuckoo_manager.verify("noReturn()", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
}
@discardableResult
func count<M1: Cuckoo.Matchable>(characters: M1) -> Cuckoo.__DoNotUse<Int> where M1.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String)>] = [wrap(matchable: characters) { $0 }]
return cuckoo_manager.verify("count(characters: String) -> Int", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withThrows() -> Cuckoo.__DoNotUse<Int> {
return cuckoo_manager.verify("withThrows() throws -> Int", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
}
@discardableResult
func withNoReturnThrows() -> Cuckoo.__DoNotUse<Void> {
return cuckoo_manager.verify("withNoReturnThrows() throws", callMatcher: callMatcher, parameterMatchers: [] as [Cuckoo.ParameterMatcher<Void>], sourceLocation: sourceLocation)
}
@discardableResult
func withClosure<M1: Cuckoo.Matchable>(_ closure: M1) -> Cuckoo.__DoNotUse<Int> where M1.MatchedType == (String) -> Int {
let matchers: [Cuckoo.ParameterMatcher<((String) -> Int)>] = [wrap(matchable: closure) { $0 }]
return cuckoo_manager.verify("withClosure(_: (String) -> Int) -> Int", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withEscape<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, action closure: M2) -> Cuckoo.__DoNotUse<Void> where M1.MatchedType == String, M2.MatchedType == (String) -> Void {
let matchers: [Cuckoo.ParameterMatcher<(String, (String) -> Void)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return cuckoo_manager.verify("withEscape(_: String, action: @escaping (String) -> Void)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withOptionalClosure<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(_ a: M1, closure: M2) -> Cuckoo.__DoNotUse<Void> where M1.MatchedType == String, M2.MatchedType == ((String) -> Void)? {
let matchers: [Cuckoo.ParameterMatcher<(String, ((String) -> Void)?)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: closure) { $0.1 }]
return cuckoo_manager.verify("withOptionalClosure(_: String, closure: ((String) -> Void)?)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
@discardableResult
func withLabelAndUnderscore<M1: Cuckoo.Matchable, M2: Cuckoo.Matchable>(labelA a: M1, _ b: M2) -> Cuckoo.__DoNotUse<Void> where M1.MatchedType == String, M2.MatchedType == String {
let matchers: [Cuckoo.ParameterMatcher<(String, String)>] = [wrap(matchable: a) { $0.0 }, wrap(matchable: b) { $0.1 }]
return cuckoo_manager.verify("withLabelAndUnderscore(labelA: String, _: String)", callMatcher: callMatcher, parameterMatchers: matchers, sourceLocation: sourceLocation)
}
}
}
class TestedProtocolStub: TestedProtocol {
var readOnlyProperty: String {
get {
return DefaultValueRegistry.defaultValue(for: (String).self)
}
}
var readWriteProperty: Int {
get {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
set {
}
}
var optionalProperty: Int? {
get {
return DefaultValueRegistry.defaultValue(for: (Int?).self)
}
set {
}
}
func noReturn() {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
func count(characters: String) -> Int {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
func withThrows() throws -> Int {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
func withNoReturnThrows() throws {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
func withClosure(_ closure: (String) -> Int) -> Int {
return DefaultValueRegistry.defaultValue(for: (Int).self)
}
func withEscape(_ a: String, action closure: @escaping (String) -> Void) {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
func withOptionalClosure(_ a: String, closure: ((String) -> Void)?) {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
func withLabelAndUnderscore(labelA a: String, _ b: String) {
return DefaultValueRegistry.defaultValue(for: (Void).self)
}
}

Some files were not shown because too many files have changed in this diff Show More