Skip to content

Commit 0b1dfe7

Browse files
committed
Add tests
1 parent dbb30a4 commit 0b1dfe7

File tree

4 files changed

+368
-0
lines changed

4 files changed

+368
-0
lines changed
Lines changed: 266 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
// !$*UTF8*$!
2+
{
3+
archiveVersion = 1;
4+
classes = {
5+
};
6+
objectVersion = 46;
7+
objects = {
8+
9+
/* Begin PBXBuildFile section */
10+
6EE9C1591B00BB5B00D6B91C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE9C1581B00BB5B00D6B91C /* main.swift */; };
11+
6EE9C1741B00BBB700D6B91C /* SwiftyTimer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6EE9C1731B00BBB700D6B91C /* SwiftyTimer.swift */; };
12+
/* End PBXBuildFile section */
13+
14+
/* Begin PBXFileReference section */
15+
6EE9C1531B00BB5B00D6B91C /* SwiftyTimerTests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftyTimerTests.app; sourceTree = BUILT_PRODUCTS_DIR; };
16+
6EE9C1571B00BB5B00D6B91C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
17+
6EE9C1581B00BB5B00D6B91C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
18+
6EE9C1731B00BBB700D6B91C /* SwiftyTimer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftyTimer.swift; path = ../../Src/SwiftyTimer.swift; sourceTree = "<group>"; };
19+
/* End PBXFileReference section */
20+
21+
/* Begin PBXFrameworksBuildPhase section */
22+
6EE9C1501B00BB5B00D6B91C /* Frameworks */ = {
23+
isa = PBXFrameworksBuildPhase;
24+
buildActionMask = 2147483647;
25+
files = (
26+
);
27+
runOnlyForDeploymentPostprocessing = 0;
28+
};
29+
/* End PBXFrameworksBuildPhase section */
30+
31+
/* Begin PBXGroup section */
32+
6EE9C14A1B00BB5B00D6B91C = {
33+
isa = PBXGroup;
34+
children = (
35+
6EE9C1551B00BB5B00D6B91C /* SwiftyTimerTests */,
36+
6EE9C1541B00BB5B00D6B91C /* Products */,
37+
);
38+
sourceTree = "<group>";
39+
};
40+
6EE9C1541B00BB5B00D6B91C /* Products */ = {
41+
isa = PBXGroup;
42+
children = (
43+
6EE9C1531B00BB5B00D6B91C /* SwiftyTimerTests.app */,
44+
);
45+
name = Products;
46+
sourceTree = "<group>";
47+
};
48+
6EE9C1551B00BB5B00D6B91C /* SwiftyTimerTests */ = {
49+
isa = PBXGroup;
50+
children = (
51+
6EE9C1731B00BBB700D6B91C /* SwiftyTimer.swift */,
52+
6EE9C1581B00BB5B00D6B91C /* main.swift */,
53+
6EE9C1561B00BB5B00D6B91C /* Supporting Files */,
54+
);
55+
path = SwiftyTimerTests;
56+
sourceTree = "<group>";
57+
};
58+
6EE9C1561B00BB5B00D6B91C /* Supporting Files */ = {
59+
isa = PBXGroup;
60+
children = (
61+
6EE9C1571B00BB5B00D6B91C /* Info.plist */,
62+
);
63+
name = "Supporting Files";
64+
sourceTree = "<group>";
65+
};
66+
/* End PBXGroup section */
67+
68+
/* Begin PBXNativeTarget section */
69+
6EE9C1521B00BB5B00D6B91C /* SwiftyTimerTests */ = {
70+
isa = PBXNativeTarget;
71+
buildConfigurationList = 6EE9C16D1B00BB5B00D6B91C /* Build configuration list for PBXNativeTarget "SwiftyTimerTests" */;
72+
buildPhases = (
73+
6EE9C14F1B00BB5B00D6B91C /* Sources */,
74+
6EE9C1501B00BB5B00D6B91C /* Frameworks */,
75+
6EE9C1511B00BB5B00D6B91C /* Resources */,
76+
);
77+
buildRules = (
78+
);
79+
dependencies = (
80+
);
81+
name = SwiftyTimerTests;
82+
productName = SwiftyTimerTests;
83+
productReference = 6EE9C1531B00BB5B00D6B91C /* SwiftyTimerTests.app */;
84+
productType = "com.apple.product-type.application";
85+
};
86+
/* End PBXNativeTarget section */
87+
88+
/* Begin PBXProject section */
89+
6EE9C14B1B00BB5B00D6B91C /* Project object */ = {
90+
isa = PBXProject;
91+
attributes = {
92+
LastUpgradeCheck = 0640;
93+
TargetAttributes = {
94+
6EE9C1521B00BB5B00D6B91C = {
95+
CreatedOnToolsVersion = 6.4;
96+
};
97+
};
98+
};
99+
buildConfigurationList = 6EE9C14E1B00BB5B00D6B91C /* Build configuration list for PBXProject "SwiftyTimerTests" */;
100+
compatibilityVersion = "Xcode 3.2";
101+
developmentRegion = English;
102+
hasScannedForEncodings = 0;
103+
knownRegions = (
104+
en,
105+
Base,
106+
);
107+
mainGroup = 6EE9C14A1B00BB5B00D6B91C;
108+
productRefGroup = 6EE9C1541B00BB5B00D6B91C /* Products */;
109+
projectDirPath = "";
110+
projectRoot = "";
111+
targets = (
112+
6EE9C1521B00BB5B00D6B91C /* SwiftyTimerTests */,
113+
);
114+
};
115+
/* End PBXProject section */
116+
117+
/* Begin PBXResourcesBuildPhase section */
118+
6EE9C1511B00BB5B00D6B91C /* Resources */ = {
119+
isa = PBXResourcesBuildPhase;
120+
buildActionMask = 2147483647;
121+
files = (
122+
);
123+
runOnlyForDeploymentPostprocessing = 0;
124+
};
125+
/* End PBXResourcesBuildPhase section */
126+
127+
/* Begin PBXSourcesBuildPhase section */
128+
6EE9C14F1B00BB5B00D6B91C /* Sources */ = {
129+
isa = PBXSourcesBuildPhase;
130+
buildActionMask = 2147483647;
131+
files = (
132+
6EE9C1591B00BB5B00D6B91C /* main.swift in Sources */,
133+
6EE9C1741B00BBB700D6B91C /* SwiftyTimer.swift in Sources */,
134+
);
135+
runOnlyForDeploymentPostprocessing = 0;
136+
};
137+
/* End PBXSourcesBuildPhase section */
138+
139+
/* Begin XCBuildConfiguration section */
140+
6EE9C16B1B00BB5B00D6B91C /* Debug */ = {
141+
isa = XCBuildConfiguration;
142+
buildSettings = {
143+
ALWAYS_SEARCH_USER_PATHS = NO;
144+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
145+
CLANG_CXX_LIBRARY = "libc++";
146+
CLANG_ENABLE_MODULES = YES;
147+
CLANG_ENABLE_OBJC_ARC = YES;
148+
CLANG_WARN_BOOL_CONVERSION = YES;
149+
CLANG_WARN_CONSTANT_CONVERSION = YES;
150+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
151+
CLANG_WARN_EMPTY_BODY = YES;
152+
CLANG_WARN_ENUM_CONVERSION = YES;
153+
CLANG_WARN_INT_CONVERSION = YES;
154+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
155+
CLANG_WARN_UNREACHABLE_CODE = YES;
156+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
157+
CODE_SIGN_IDENTITY = "-";
158+
COPY_PHASE_STRIP = NO;
159+
DEBUG_INFORMATION_FORMAT = dwarf;
160+
ENABLE_STRICT_OBJC_MSGSEND = YES;
161+
GCC_C_LANGUAGE_STANDARD = gnu99;
162+
GCC_DYNAMIC_NO_PIC = NO;
163+
GCC_NO_COMMON_BLOCKS = YES;
164+
GCC_OPTIMIZATION_LEVEL = 0;
165+
GCC_PREPROCESSOR_DEFINITIONS = (
166+
"DEBUG=1",
167+
"$(inherited)",
168+
);
169+
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
170+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
171+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
172+
GCC_WARN_UNDECLARED_SELECTOR = YES;
173+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
174+
GCC_WARN_UNUSED_FUNCTION = YES;
175+
GCC_WARN_UNUSED_VARIABLE = YES;
176+
MACOSX_DEPLOYMENT_TARGET = 10.10;
177+
MTL_ENABLE_DEBUG_INFO = YES;
178+
ONLY_ACTIVE_ARCH = YES;
179+
SDKROOT = macosx;
180+
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
181+
};
182+
name = Debug;
183+
};
184+
6EE9C16C1B00BB5B00D6B91C /* Release */ = {
185+
isa = XCBuildConfiguration;
186+
buildSettings = {
187+
ALWAYS_SEARCH_USER_PATHS = NO;
188+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
189+
CLANG_CXX_LIBRARY = "libc++";
190+
CLANG_ENABLE_MODULES = YES;
191+
CLANG_ENABLE_OBJC_ARC = YES;
192+
CLANG_WARN_BOOL_CONVERSION = YES;
193+
CLANG_WARN_CONSTANT_CONVERSION = YES;
194+
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
195+
CLANG_WARN_EMPTY_BODY = YES;
196+
CLANG_WARN_ENUM_CONVERSION = YES;
197+
CLANG_WARN_INT_CONVERSION = YES;
198+
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
199+
CLANG_WARN_UNREACHABLE_CODE = YES;
200+
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
201+
CODE_SIGN_IDENTITY = "-";
202+
COPY_PHASE_STRIP = NO;
203+
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
204+
ENABLE_NS_ASSERTIONS = NO;
205+
ENABLE_STRICT_OBJC_MSGSEND = YES;
206+
GCC_C_LANGUAGE_STANDARD = gnu99;
207+
GCC_NO_COMMON_BLOCKS = YES;
208+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
209+
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
210+
GCC_WARN_UNDECLARED_SELECTOR = YES;
211+
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
212+
GCC_WARN_UNUSED_FUNCTION = YES;
213+
GCC_WARN_UNUSED_VARIABLE = YES;
214+
MACOSX_DEPLOYMENT_TARGET = 10.10;
215+
MTL_ENABLE_DEBUG_INFO = NO;
216+
SDKROOT = macosx;
217+
};
218+
name = Release;
219+
};
220+
6EE9C16E1B00BB5B00D6B91C /* Debug */ = {
221+
isa = XCBuildConfiguration;
222+
buildSettings = {
223+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
224+
COMBINE_HIDPI_IMAGES = YES;
225+
INFOPLIST_FILE = SwiftyTimerTests/Info.plist;
226+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
227+
PRODUCT_NAME = "$(TARGET_NAME)";
228+
};
229+
name = Debug;
230+
};
231+
6EE9C16F1B00BB5B00D6B91C /* Release */ = {
232+
isa = XCBuildConfiguration;
233+
buildSettings = {
234+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
235+
COMBINE_HIDPI_IMAGES = YES;
236+
INFOPLIST_FILE = SwiftyTimerTests/Info.plist;
237+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
238+
PRODUCT_NAME = "$(TARGET_NAME)";
239+
};
240+
name = Release;
241+
};
242+
/* End XCBuildConfiguration section */
243+
244+
/* Begin XCConfigurationList section */
245+
6EE9C14E1B00BB5B00D6B91C /* Build configuration list for PBXProject "SwiftyTimerTests" */ = {
246+
isa = XCConfigurationList;
247+
buildConfigurations = (
248+
6EE9C16B1B00BB5B00D6B91C /* Debug */,
249+
6EE9C16C1B00BB5B00D6B91C /* Release */,
250+
);
251+
defaultConfigurationIsVisible = 0;
252+
defaultConfigurationName = Release;
253+
};
254+
6EE9C16D1B00BB5B00D6B91C /* Build configuration list for PBXNativeTarget "SwiftyTimerTests" */ = {
255+
isa = XCConfigurationList;
256+
buildConfigurations = (
257+
6EE9C16E1B00BB5B00D6B91C /* Debug */,
258+
6EE9C16F1B00BB5B00D6B91C /* Release */,
259+
);
260+
defaultConfigurationIsVisible = 0;
261+
defaultConfigurationName = Release;
262+
};
263+
/* End XCConfigurationList section */
264+
};
265+
rootObject = 6EE9C14B1B00BB5B00D6B91C /* Project object */;
266+
}

Tests/SwiftyTimerTests.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Tests/SwiftyTimerTests/Info.plist

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIconFile</key>
10+
<string></string>
11+
<key>CFBundleIdentifier</key>
12+
<string>radex.$(PRODUCT_NAME:rfc1034identifier)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleSignature</key>
22+
<string>????</string>
23+
<key>CFBundleVersion</key>
24+
<string>1</string>
25+
<key>LSMinimumSystemVersion</key>
26+
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
27+
<key>NSPrincipalClass</key>
28+
<string>NSApplication</string>
29+
</dict>
30+
</plist>

Tests/SwiftyTimerTests/main.swift

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import Cocoa
2+
3+
let app = NSApplication.sharedApplication()
4+
5+
class AppDelegate: NSObject, NSApplicationDelegate {
6+
func applicationDidFinishLaunching(aNotification: NSNotification) {
7+
test()
8+
}
9+
10+
func test() {
11+
assert(1.second == 1.0)
12+
assert(1.minute == 60.0)
13+
assert(1.hour == 1.minute * 60)
14+
assert(1.2.seconds == 1.2)
15+
assert(1.5.minutes == 90.0)
16+
assert(1.5.hours == 5400.0)
17+
test2()
18+
}
19+
20+
func test2() {
21+
var fired = false
22+
NSTimer.after(0.1.seconds) {
23+
assert(!fired)
24+
fired = true
25+
self.test3()
26+
}
27+
}
28+
29+
var timer1: NSTimer!
30+
31+
func test3() {
32+
var fired = false
33+
timer1 = NSTimer.every(0.1.seconds) {
34+
if fired {
35+
self.test4()
36+
self.timer1.invalidate()
37+
} else {
38+
fired = true
39+
}
40+
}
41+
}
42+
43+
let timer2 = NSTimer.new(after: 0.1.seconds) { fatalError() }
44+
let timer3 = NSTimer.new(every: 0.1.seconds) { fatalError() }
45+
46+
func test4() {
47+
let timer = NSTimer.new(after: 0.1.seconds) {
48+
self.test5()
49+
}
50+
NSRunLoop.currentRunLoop().addTimer(timer, forMode: NSDefaultRunLoopMode)
51+
}
52+
53+
func test5() {
54+
NSTimer.after(0.1.seconds, done)
55+
}
56+
57+
func done() {
58+
println("All tests passed")
59+
app.terminate(self)
60+
}
61+
}
62+
63+
let delegate = AppDelegate()
64+
app.delegate = delegate
65+
app.run()

0 commit comments

Comments
 (0)