Skip to content

Commit

Permalink
Add times implementation with tests + Empty playground for usage exam…
Browse files Browse the repository at this point in the history
…ples
  • Loading branch information
Jeehut committed Dec 18, 2015
1 parent ae5296a commit 48c0db1
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 41 deletions.
33 changes: 29 additions & 4 deletions HandySwift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
/* Begin PBXBuildFile section */
823B2B351C24AAB7007B3CDD /* HandySwift.h in Headers */ = {isa = PBXBuildFile; fileRef = 823B2B341C24AAB7007B3CDD /* HandySwift.h */; settings = {ATTRIBUTES = (Public, ); }; };
823B2B3C1C24AAB7007B3CDD /* HandySwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 823B2B311C24AAB6007B3CDD /* HandySwift.framework */; };
823B2B411C24AAB7007B3CDD /* HandySwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 823B2B401C24AAB7007B3CDD /* HandySwiftTests.swift */; };
823B2B4D1C24ABA4007B3CDD /* IntegerTypeExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 823B2B4C1C24ABA4007B3CDD /* IntegerTypeExtension.swift */; };
823B2B501C24AC00007B3CDD /* IntegerTypeExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 823B2B4F1C24AC00007B3CDD /* IntegerTypeExtensionTests.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -27,8 +28,9 @@
823B2B341C24AAB7007B3CDD /* HandySwift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HandySwift.h; sourceTree = "<group>"; };
823B2B361C24AAB7007B3CDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
823B2B3B1C24AAB7007B3CDD /* HandySwiftTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = HandySwiftTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
823B2B401C24AAB7007B3CDD /* HandySwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HandySwiftTests.swift; sourceTree = "<group>"; };
823B2B421C24AAB7007B3CDD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
823B2B4C1C24ABA4007B3CDD /* IntegerTypeExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IntegerTypeExtension.swift; path = Extensions/IntegerTypeExtension.swift; sourceTree = "<group>"; };
823B2B4F1C24AC00007B3CDD /* IntegerTypeExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = IntegerTypeExtensionTests.swift; path = Extensions/IntegerTypeExtensionTests.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -71,6 +73,7 @@
823B2B331C24AAB7007B3CDD /* HandySwift */ = {
isa = PBXGroup;
children = (
823B2B4B1C24AB7F007B3CDD /* Extensions */,
823B2B341C24AAB7007B3CDD /* HandySwift.h */,
823B2B361C24AAB7007B3CDD /* Info.plist */,
);
Expand All @@ -80,12 +83,28 @@
823B2B3F1C24AAB7007B3CDD /* HandySwiftTests */ = {
isa = PBXGroup;
children = (
823B2B401C24AAB7007B3CDD /* HandySwiftTests.swift */,
823B2B4E1C24ABD8007B3CDD /* Extensions */,
823B2B421C24AAB7007B3CDD /* Info.plist */,
);
path = HandySwiftTests;
sourceTree = "<group>";
};
823B2B4B1C24AB7F007B3CDD /* Extensions */ = {
isa = PBXGroup;
children = (
823B2B4C1C24ABA4007B3CDD /* IntegerTypeExtension.swift */,
);
name = Extensions;
sourceTree = "<group>";
};
823B2B4E1C24ABD8007B3CDD /* Extensions */ = {
isa = PBXGroup;
children = (
823B2B4F1C24AC00007B3CDD /* IntegerTypeExtensionTests.swift */,
);
name = Extensions;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -194,14 +213,15 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
823B2B4D1C24ABA4007B3CDD /* IntegerTypeExtension.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
823B2B371C24AAB7007B3CDD /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
823B2B411C24AAB7007B3CDD /* HandySwiftTests.swift in Sources */,
823B2B501C24AC00007B3CDD /* IntegerTypeExtensionTests.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -308,6 +328,7 @@
823B2B461C24AAB7007B3CDD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand All @@ -318,12 +339,14 @@
PRODUCT_BUNDLE_IDENTIFIER = com.flinesoft.HandySwift;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
name = Debug;
};
823B2B471C24AAB7007B3CDD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
Expand Down Expand Up @@ -376,6 +399,7 @@
823B2B471C24AAB7007B3CDD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
823B2B481C24AAB7007B3CDD /* Build configuration list for PBXNativeTarget "HandySwiftTests" */ = {
isa = XCConfigurationList;
Expand All @@ -384,6 +408,7 @@
823B2B4A1C24AAB7007B3CDD /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
10 changes: 10 additions & 0 deletions HandySwift.xcworkspace/contents.xcworkspacedata

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions HandySwift/Extensions/IntegerTypeExtension.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// IntegerTypeExtension.swift
// HandySwift
//
// Created by Cihat Gündüz on 18.12.15.
// Copyright © 2015 Flinesoft. All rights reserved.
//

import Foundation

public extension IntegerType {

public func times(closure: () -> ()) {
guard self > 0 else { return }

for _ in 1...self {
closure()
}
}

public func times(closure: (Self) -> ()) {
guard self > 0 else { return }

for i in 1...self {
closure(i)
}
}

}
2 changes: 1 addition & 1 deletion HandySwift/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>0.1</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
48 changes: 48 additions & 0 deletions HandySwiftTests/Extensions/IntegerTypeExtensionTests.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// IntegerTypeExtensionTests.swift
// HandySwift
//
// Created by Cihat Gündüz on 18.12.15.
// Copyright © 2015 Flinesoft. All rights reserved.
//

import XCTest

@testable import HandySwift

class IntegerTypeExtensionTests: XCTestCase {

func testTimesClosureWithoutArgument() {
var testString = ""

0.times {
testString += "."
}

XCTAssertEqual(testString, "")

3.times {
testString += "."
}

XCTAssertEqual(testString, "...")
}

func testTimesClosureWithArgument() {
var testString = ""

0.times { i in
testString += "\(i)"
}

XCTAssertEqual(testString, "")

3.times { i in
testString += "\(i)"
}

XCTAssertEqual(testString, "123")
}


}
36 changes: 0 additions & 36 deletions HandySwiftTests/HandySwiftTests.swift

This file was deleted.

2 changes: 2 additions & 0 deletions UsageExamples.playground/Contents.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import HandySwift

4 changes: 4 additions & 0 deletions UsageExamples.playground/contents.xcplayground
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='ios'>
<timeline fileName='timeline.xctimeline'/>
</playground>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions UsageExamples.playground/timeline.xctimeline
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Timeline
version = "3.0">
<TimelineItems>
</TimelineItems>
</Timeline>

0 comments on commit 48c0db1

Please sign in to comment.