Compare commits

..

23 Commits

Author SHA1 Message Date
Kelvin Harron 088c021cbc Update README.md for SPM instructions
specified the target to select as part of the SPM installation process
2023-06-03 14:39:07 +02:00
Matyáš Kříž 475322e609 Bump version. 2023-04-17 17:30:01 +02:00
nanashiki 9676d7e374 Up DEPLOYMENT_TARGETs 2023-04-17 17:27:11 +02:00
nanashiki 75a209c3ba Fix String index is out of bounds crash 2023-04-17 17:24:25 +02:00
Matyáš Kříž e29f10eac6 Bump version. 2023-04-11 23:19:48 +02:00
Kabir Oberai 4148a6a7ff Support effectful properties 2023-04-11 23:17:51 +02:00
Kabir Oberai a71ba74df1 Fix generator crashing for property wrappers with empty type. 2023-04-01 10:19:13 +02:00
Matyáš Kříž fa66b6a0a0 Bump version. 2023-03-26 14:22:04 +02:00
Seth Deckard 6f41152d83
Fix Generator to handle reserved keywords
Allows for reserved keywords to be used as argument labels / parameters
in mocked types.

Fixes: https://github.com/Brightify/Cuckoo/issues/452

- Moves escaping util function to Utils and makes it internal since it
  now needs to be used outside of `Generator`.
- Uses escaping function in areas affected by the bug.
- Renames set of reserved names to reflect the larger scope (no longer
  used for just function names).
- Some minor clean-up to style and formatting on areas touched.

Example of the problem:

Generate a mock for a protocol with the function:

```
func escape(for: String) -> String
```

This would result in `for` as a function parameter used within the body
of the function for the mock and verification and stubbing proxies,
which would not compile. This change escapes keywords like this so the
generated code will compile.

See `TestedProtocol.withReservedKeywords` for a test example. An example
was added to `TestedClass` as well, but the real motivation for this is
protocols since conforming types can and often do use a different
parameter name so the argument label like `for` would never be used
within the body of the function.
2023-03-23 08:31:12 -04:00
Matyáš Kříž a9469909b7 Bump version. 2023-03-17 16:26:12 +01:00
Matyáš Kříž 7d51beb752 Update CI. 2023-03-17 16:23:34 +01:00
Matyáš Kříž 41a70422fb Update pbxproj. 2023-03-17 16:21:39 +01:00
David Steinacher f0f77397a5 add missing () when closure is an autoclosure 2023-02-12 16:30:21 +01:00
Matyáš Kříž 835c61246a Completely convert project to Tuist. 2023-01-07 18:58:48 +01:00
Farid Mammadov cbb5f5d416 Add support async/await in Protocol with Associated Type. 2023-01-03 16:46:43 +01:00
Matyáš Kříž 102c9b3a10 Add forgotten file to the project. 2023-01-03 16:39:53 +01:00
sk409 8d7b893bc2 Support NSObjectProtocol inheritance for protocol. 2022-09-19 17:39:55 +02:00
Matyáš Kříž 64b1681e37 Bump version. 2022-09-01 17:04:31 +02:00
sk409 5a9301b97c Remove closure argument name. 2022-09-01 17:00:52 +02:00
Matyáš Kříž 4b5a397f58 Bump version. 2022-08-16 19:40:27 +02:00
Antonio J Pallares 55149ddee9 test: add tests with `OCMQuantifier`s 2022-08-16 16:49:01 +02:00
Antonio J Pallares a84978a0c1 feat: enable OCMock's OCMQuantifier for objcVerify function. Fixes #366 2022-08-16 16:48:58 +02:00
Yoji Ueda 0ff327d675 Remove unnecessary await expression in MockTemplate. 2022-08-16 16:42:21 +02:00
136 changed files with 1574 additions and 4200 deletions

View File

@ -33,13 +33,11 @@ platform :mac do
def upload_release release_type def upload_release release_type
# Building Cuckoo Generator # Building Cuckoo Generator
Dir.chdir '../Generator' do sh('../build_generator')
sh '../build_generator', '--arch', 'arm64', '--arch', 'x86_64'
end
# Settings # Settings
binary_name = 'cuckoo_generator' binary_name = 'cuckoo_generator'
cuckoo_gen_path = Dir.glob("../Generator/.build/**/Release/#{binary_name}").first cuckoo_gen_path = "../Generator/bin/#{binary_name}"
# GitHub username # GitHub username
username_var_name = 'GITHUB_USERNAME' username_var_name = 'GITHUB_USERNAME'
@ -100,11 +98,11 @@ platform :mac do
end end
after_all do after_all do
reset_git_repo reset_git_repo(disregard_gitignore: false)
end end
error do |_, exception| error do |_, exception|
reset_git_repo reset_git_repo(disregard_gitignore: false)
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,5 +1,4 @@
# Xcode # Xcode
#
.build/ .build/
build/ build/
*.pbxuser *.pbxuser
@ -19,19 +18,11 @@ 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
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts
Carthage/Build Carthage/Build
.DS_Store .DS_Store
default.profraw default.profraw
Tests/**/Generated/*.swift Tests/**/Generated/*.swift
@ -40,9 +31,20 @@ Generator/*.app
# AppCode # AppCode
.idea/ .idea/
cuckoo_generator cuckoo_generator
Generator/CuckooGenerator.xcodeproj
.fastlane .fastlane
Cuckoo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Generator/CuckooGenerator.xcodeproj
Cuckoo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist Cuckoo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Cuckoo.xcodeproj/project.xcworkspace/contents.xcworkspacedata Cuckoo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Cuckoo.xcworkspace
Cuckoo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
Tuist/Dependencies/graph.json
Tuist/Dependencies/Carthage
Tuist/Dependencies/SwiftPackageManager
Tuist/Dependencies/Cocoapods
Generator/Generator.xcodeproj
Generator/GeneratedMocks.swift

104
.package.resolved Normal file
View File

@ -0,0 +1,104 @@
{
"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
}

1
.tuist-version Normal file
View File

@ -0,0 +1 @@
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.8.1" s.version = "1.10.3"
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).

File diff suppressed because it is too large Load Diff

View File

@ -26,8 +26,7 @@
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

@ -1,96 +0,0 @@
<?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,8 +26,7 @@
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

@ -1,96 +0,0 @@
<?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,8 +26,7 @@
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

@ -1,96 +0,0 @@
<?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

@ -1,96 +0,0 @@
<?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

@ -1,96 +0,0 @@
<?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

@ -1,96 +0,0 @@
<?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

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

View File

@ -1,72 +0,0 @@
{
"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
}

View File

@ -1,106 +0,0 @@
{
"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": "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version": "1.0.1"
}
},
{
"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": "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version": "0.10.1"
}
},
{
"package": "Stencil",
"repositoryURL": "https://github.com/kylef/Stencil.git",
"state": {
"branch": null,
"revision": "ccd9402682f4c07dac9561befd207c8156e80e20",
"version": "0.14.2"
}
},
{
"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
}

View File

@ -1,24 +0,0 @@
// 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.14.2"),
.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"]),
]
)

56
Generator/Project.swift Normal file
View File

@ -0,0 +1,56 @@
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

@ -1,11 +1,3 @@
//
// 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,17 +1,8 @@
// 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)
@ -38,7 +29,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 : mergeInheritance(tokens) let tokensWithInheritance = options.noInheritance ? tokens : inheritNSObject(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]
@ -86,6 +77,43 @@ 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
@ -142,18 +170,19 @@ public struct GenerateMocksCommand: CommandProtocol {
let globEnabled: Bool let globEnabled: Bool
let regex: String let regex: String
public init(output: String, public init(
testableFrameworks: String, output: String,
exclude: String, testableFrameworks: String,
noHeader: Bool, exclude: String,
noTimestamp: Bool, noHeader: Bool,
noInheritance: Bool, noTimestamp: Bool,
filePrefix: String, noInheritance: Bool,
noClassMocking: Bool, filePrefix: String,
debugMode: Bool, noClassMocking: Bool,
globEnabled: Bool, debugMode: Bool,
regex: String, globEnabled: Bool,
files: [String] regex: 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,12 +1,6 @@
//
// 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

@ -1,11 +1,3 @@
//
// 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,12 +1,3 @@
//#!/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

View File

@ -1,36 +0,0 @@
//
// 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,17 +0,0 @@
//
// 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

@ -1,11 +1,3 @@
//
// 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,37 +1,14 @@
//
// 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 static let reservedKeywordsNotAllowedAsMethodName: 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:
"_",
]
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 }
@ -67,10 +44,15 @@ public struct Generator {
guard let parameters = value as? [MethodParameter] else { return value } guard let parameters = value as? [MethodParameter] else { return value }
return self.closeNestedClosure(for: parameters) return self.closeNestedClosure(for: parameters)
} }
ext.registerFilter("escapeReservedKeywords") { (value: Any?) in ext.registerFilter("escapeReservedKeywords") { (value: Any?) in
guard let name = value as? String else { return value } guard let name = value as? String else { return value }
return self.escapeReservedKeywords(for: name) 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])
@ -116,7 +98,13 @@ 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)]"
} }
@ -157,8 +145,12 @@ public struct Generator {
} }
return fullString return fullString
} }
private func escapeReservedKeywords(for name: String) -> String { private func removeClosureArgumentNames(for type: String) -> String {
Self.reservedKeywordsNotAllowedAsMethodName.contains(name) ? "`\(name)`" : name type.replacingOccurrences(
of: "_\\s+?[_a-zA-Z]\\w*?\\s*?:",
with: "",
options: .regularExpression
)
} }
} }

View File

@ -1,10 +1,3 @@
//
// Reference.swift
// CuckooGeneratorFramework
//
// Created by Tyler Thompson on 9/18/20.
//
import Foundation import Foundation
@dynamicMemberLookup @dynamicMemberLookup

View File

@ -1,11 +1,3 @@
//
// 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

@ -1,10 +1,3 @@
//
// MockTemplate.swift
// CuckooGeneratorFramework
//
// Created by Tadeas Kriz on 11/14/17.
//
import Foundation import Foundation
extension Templates { extension Templates {
@ -23,7 +16,7 @@ extension Templates {
extension {{ container.parentFullyQualifiedName }} { extension {{ container.parentFullyQualifiedName }} {
{% endif %} {% endif %}
{{ container.accessibility }} class {{ container.mockName }}{{ container.genericParameters }}: {{ container.name }}{% if container.isImplementation %}{{ container.genericArguments }}{% endif %}, {% if container.isImplementation %}Cuckoo.ClassMock{% else %}Cuckoo.ProtocolMock{% 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 %}
@ -67,15 +60,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 { get{% if property.isAsync %} async{% endif %}{% if property.isThrowing %} throws{% endif %} {
return cuckoo_manager.getter("{{ property.name }}", return {% if property.isThrowing %}try {% endif %}{% if property.isAsync %}await {% endif %}cuckoo_manager.getter{% if property.isThrowing %}Throws{% endif %}("{{ property.name }}",
superclassCall: superclassCall:
{% if container.isImplementation %} {% if container.isImplementation %}
super.{{ property.name }} {% if property.isThrowing %}try {% endif %}{% if property.isAsync %}await {% endif %}super.{{ property.name }}
{% else %} {% else %}
Cuckoo.MockManager.crashOnProtocolSuperclassCall() Cuckoo.MockManager.crashOnProtocolSuperclassCall()
{% endif %}, {% endif %},
defaultCall: __defaultImplStub!.{{property.name}}) defaultCall: {% if property.isThrowing %}try {% endif %}{% if property.isAsync %}await {% endif %} __defaultImplStub!.{{property.name}})
} }
{% ifnot property.isReadOnly %} {% ifnot property.isReadOnly %}
set { set {
@ -131,7 +124,7 @@ extension {{ container.parentFullyQualifiedName }} {
{% if container.isImplementation %} {% if container.isImplementation %}
{% if method.isAsync %}await {% endif %}super.{{method.name}}({{method.call}}) {% if method.isAsync %}await {% endif %}super.{{method.name}}({{method.call}})
{% else %} {% else %}
{% if method.isAsync %}await {% endif %}Cuckoo.MockManager.crashOnProtocolSuperclassCall() Cuckoo.MockManager.crashOnProtocolSuperclassCall()
{% endif %}, {% endif %},
defaultCall: {% if method.isAsync %}await {% endif %}__defaultImplStub!.{{method.name}}{%if method.isOptional %}!{%endif%}({{method.call}})) defaultCall: {% if method.isAsync %}await {% endif %}__defaultImplStub!.{{method.name}}{%if method.isOptional %}!{%endif%}({{method.call}}))
{{ method.parameters|closeNestedClosure }} {{ method.parameters|closeNestedClosure }}

View File

@ -1,16 +1,9 @@
//
// 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 %} {% for attribute in container.attributes %}
{{ attribute.text }} {{ attribute.text }}
{% endfor %} {% endfor %}
{{container.accessibility}} class {{ container.name }}Stub{{ container.genericParameters }}: {{ container.name }}{% if container.isImplementation %}{{ container.genericArguments }}{% endif %} { {{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 }} {{ property.unavailablePlatformsCheck }}
{% if debug %} {% if debug %}
@ -21,7 +14,7 @@ extension Templates {
{% 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}}).self) return DefaultValueRegistry.defaultValue(for: ({{property.type|genericSafe|removeClosureArgumentNames}}).self)
} }
{% ifnot property.isReadOnly %} {% ifnot property.isReadOnly %}
set { } set { }

View File

@ -1,10 +1,3 @@
//
// StubbingProxyTemplate.swift
// CuckooGeneratorFramework
//
// Created by Tadeas Kriz on 11/14/17.
//
import Foundation import Foundation
extension Templates { extension Templates {

View File

@ -1,10 +1,3 @@
//
// Templates.swift
// CuckooGeneratorFramework
//
// Created by Tadeas Kriz on 11/14/17.
//
import Foundation import Foundation
struct Templates { } struct Templates { }

View File

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

View File

@ -1,10 +1,3 @@
//
// VerificationProxyTemplate.swift
// CuckooGeneratorFramework
//
// Created by Tadeas Kriz on 11/14/17.
//
import Foundation import Foundation
extension Templates { extension Templates {

View File

@ -110,7 +110,8 @@ 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:
@ -184,11 +185,19 @@ 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,
@ -517,6 +526,34 @@ public struct Tokenizer {
return ReturnSignature(isAsync: isAsync, throwString: throwString, returnType: returnType ?? WrappableType.type("Void"), whereConstraints: whereConstraints) return ReturnSignature(isAsync: isAsync, 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.
private func fixSourceKittenLastGenericParameterBug(_ genericParameters: [GenericParameter]) -> [GenericParameter] { private func fixSourceKittenLastGenericParameterBug(_ genericParameters: [GenericParameter]) -> [GenericParameter] {
let fixedGenericParameters: [GenericParameter] let fixedGenericParameters: [GenericParameter]

View File

@ -1,11 +1,3 @@
//
// 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,10 +1,3 @@
//
// ChildToken.swift
// CuckooGeneratorFramework
//
// Created by Tyler Thompson on 9/18/20.
//
import Foundation import Foundation
public protocol ChildToken: Token { public protocol ChildToken: Token {

View File

@ -1,11 +1,3 @@
//
// 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

View File

@ -1,11 +1,3 @@
//
// 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,11 +1,3 @@
//
// ContainerToken.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public protocol ContainerToken: ParentToken, ChildToken { public protocol ContainerToken: ParentToken, ChildToken {
var initializers: [Initializer] { get } var initializers: [Initializer] { get }
var implementation: Bool { get } var implementation: Bool { get }
@ -65,6 +57,7 @@ extension ContainerToken {
"genericParameters": isGeneric ? "<\(genericParametersString)>" : "", "genericParameters": isGeneric ? "<\(genericParametersString)>" : "",
"genericArguments": isGeneric ? "<\(genericArgumentsString)>" : "", "genericArguments": isGeneric ? "<\(genericArgumentsString)>" : "",
"genericProtocolIdentity": genericProtocolIdentity, "genericProtocolIdentity": genericProtocolIdentity,
"isNSObjectProtocol": (self as? ProtocolDeclaration)?.isNSObjectProtocol ?? false
] ]
} }
} }

View File

@ -1,11 +1,3 @@
//
// ExtensionDeclaration.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 17.06.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public struct ExtensionDeclaration: ParentToken { public struct ExtensionDeclaration: ParentToken {
// TODO Implement support for extensions // TODO Implement support for extensions
public let name: String public let name: String

View File

@ -1,11 +1,3 @@
//
// 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 {
@ -27,6 +19,10 @@ 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 {
@ -59,6 +55,13 @@ 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,10 +1,3 @@
//
// 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,10 +1,3 @@
//
// HasAccessibility.swift
// CuckooGenerator
//
// Created by Matyáš Kříž on 11/03/2019.
//
import Foundation import Foundation
public protocol HasAccessibility { public protocol HasAccessibility {

View File

@ -1,10 +1,3 @@
//
// HasAccessibility.swift
// CuckooGenerator
//
// Created by Roland Kákonyi on 03/05/2022.
//
import Foundation import Foundation
public protocol HasAttributes { public protocol HasAttributes {
@ -23,4 +16,4 @@ extension HasAttributes {
var unavailablePlatformsCheck: String { var unavailablePlatformsCheck: String {
return hasUnavailablePlatforms ? "#if !os(\(unavailablePlatforms.joined(separator: ") && !os(")))" : "" return hasUnavailablePlatforms ? "#if !os(\(unavailablePlatforms.joined(separator: ") && !os(")))" : ""
} }
} }

View File

@ -1,11 +1,3 @@
//
// 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,11 +1,3 @@
//
// 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
@ -14,4 +6,4 @@ public struct InheritanceDeclaration: Token {
guard let other = other as? InheritanceDeclaration else { return false } guard let other = other as? InheritanceDeclaration else { return false }
return self.name == other.name return self.name == other.name
} }
} }

View File

@ -1,11 +1,3 @@
//
// 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,16 +1,14 @@
//
// InstanceVariable.swift
// CuckooGenerator
//
// Created by Filip Dolnik on 30.05.16.
// Copyright © 2016 Brightify. All rights reserved.
//
public struct InstanceVariable: Token, HasAccessibility, HasAttributes { public struct InstanceVariable: Token, HasAccessibility, HasAttributes {
public struct Effects {
public var isThrowing = false
public var isAsync = false
}
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
@ -30,8 +28,10 @@ public struct InstanceVariable: Token, HasAccessibility, HasAttributes {
} }
public func serialize() -> [String : Any] { public func serialize() -> [String : Any] {
let readOnlyString = readOnly ? "ReadOnly" : "" let readOnlyVerifyString = 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,
@ -39,8 +39,10 @@ public struct InstanceVariable: Token, HasAccessibility, HasAttributes {
"nonOptionalType": type.unoptionaled.sugarized, "nonOptionalType": type.unoptionaled.sugarized,
"accessibility": accessibility.sourceName, "accessibility": accessibility.sourceName,
"isReadOnly": readOnly, "isReadOnly": readOnly,
"stubType": (overriding ? "Class" : "Protocol") + "ToBeStubbed\(readOnlyString)\(optionalString)Property", "isAsync": effects.isAsync,
"verifyType": "Verify\(readOnlyString)\(optionalString)Property", "isThrowing": effects.isThrowing,
"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, "hasUnavailablePlatforms": hasUnavailablePlatforms,
"unavailablePlatformsCheck": unavailablePlatformsCheck, "unavailablePlatformsCheck": unavailablePlatformsCheck,

View File

@ -1,11 +1,3 @@
//
// 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,11 +1,3 @@
//
// 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"

View File

@ -1,11 +1,3 @@
//
// 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, HasAttributes {
@ -46,11 +38,11 @@ public extension Method {
.map { $0 + ": " + $1 } .map { $0 + ": " + $1 }
.joined(separator: ", ") + lastNamePart + returnSignatureString .joined(separator: ", ") + lastNamePart + returnSignatureString
} }
var isAsync: Bool { var isAsync: Bool {
return returnSignature.isAsync 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
@ -75,7 +67,9 @@ public extension Method {
func serialize() -> [String : Any] { func serialize() -> [String : Any] {
let call = parameters.map { let call = parameters.map {
let referencedName = "\($0.isInout ? "&" : "")\($0.name)" let name = escapeReservedKeywords(for: $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 {
@ -103,7 +97,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 parameter.name return escapeReservedKeywords(for: parameter.name)
} }
}.joined(separator: ", ") }.joined(separator: ", ")
@ -116,7 +110,7 @@ public extension Method {
"accessibility": accessibility.sourceName, "accessibility": accessibility.sourceName,
"returnSignature": returnSignature.description, "returnSignature": returnSignature.description,
"parameters": parameters, "parameters": parameters,
"parameterNames": parameters.map { $0.name }.joined(separator: ", "), "parameterNames": parameters.map { escapeReservedKeywords(for: $0.name) }.joined(separator: ", "),
"escapingParameterNames": escapingParameterNames, "escapingParameterNames": escapingParameterNames,
"isInit": isInit, "isInit": isInit,
"returnType": returnType.explicitOptionalOnly.sugarized, "returnType": returnType.explicitOptionalOnly.sugarized,

View File

@ -1,11 +1,3 @@
//
// 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
@ -35,6 +27,10 @@ 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,10 +1,3 @@
//
// ParentToken.swift
// CuckooGeneratorFramework
//
// Created by Tyler Thompson on 9/18/20.
//
import Foundation import Foundation
public protocol ParentToken: Token, HasAccessibility, HasAttributes { public protocol ParentToken: Token, HasAccessibility, HasAttributes {

View File

@ -1,11 +1,3 @@
//
// 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
@ -19,6 +11,7 @@ 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(
@ -32,7 +25,26 @@ 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,11 +1,3 @@
//
// 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,10 +1,3 @@
//
// ReturnSignature.swift
// CuckooGeneratorFramework
//
// Created by Matyáš Kříž on 25/03/2019.
//
import Foundation import Foundation
public struct ReturnSignature { public struct ReturnSignature {

View File

@ -1,10 +1,3 @@
//
// StructDeclaration.swift
// CuckooGeneratorFramework
//
// Created by Tyler Thompson on 9/18/20.
//
import Foundation import Foundation
public struct StructDeclaration: ParentToken { public struct StructDeclaration: ParentToken {

View File

@ -1,10 +1,3 @@
//
// 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,11 +1,3 @@
//
// 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,10 +1,3 @@
//
// 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,15 +1,10 @@
//
// 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,11 +1,3 @@
//
// 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
@ -56,6 +48,26 @@ 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,47 +0,0 @@
<?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

@ -1,32 +0,0 @@
<?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,2 +0,0 @@
source 'https://rubygems.org'
gem 'aruba', '~> 0.14.1'

View File

@ -1,44 +0,0 @@
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

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

View File

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

View File

@ -1,38 +0,0 @@
//
// 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

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

View File

@ -1,43 +0,0 @@
// 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

@ -1,47 +0,0 @@
// 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

@ -1,261 +0,0 @@
// 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

@ -1,527 +0,0 @@
// 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

@ -1,57 +0,0 @@
// 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

@ -1,84 +0,0 @@
// 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

@ -1,40 +0,0 @@
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

@ -1,10 +0,0 @@
// 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

@ -1,53 +0,0 @@
// 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

@ -1,263 +0,0 @@
// 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

@ -1,12 +0,0 @@
//
// ImplicitInstanceVariableType.swift
// Cuckoo
//
// Created by Tadeas Kriz on 09/02/16.
// Copyright © 2016 Brightify. All rights reserved.
//
class ImplicitInstanceVariableType {
var variable = 5
}

View File

@ -1,32 +0,0 @@
//
// Imports.swift
// Cuckoo
//
// Created by Tadeas Kriz on 18/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
import c;import d
import a; import b
import e
import
f
import //aaa
g
import /* aaa */h
// Class A
class A {
let text = " import x "
}
import i
import i
extension A {
var text2: String {
return " import y "
}
}

View File

@ -1,13 +0,0 @@
//
// MultipleClasses.swift
// Cuckoo
//
// Created by Tadeas Kriz on 18/01/16.
// Copyright © 2016 Brightify. All rights reserved.
//
class A {
}
class B {
}

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