Skip to content
Browse files

Upgrade for Mac support

  • Loading branch information...
1 parent 1dad15a commit 2d18949ec16c2fd313288ee91074dec0036e8363 Kevin Malakoff committed Aug 2, 2012
View
12 Lib/Helpers/SS+System.m
@@ -33,17 +33,17 @@
#import "NSString+Versioning.h"
#include "TargetConditionals.h"
-#if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)
+#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#import <UIKit/UIKit.h>
-#elif defined TARGET_OS_MAC
+#elif TARGET_OS_MAC
#import <Cocoa/Cocoa.h>
#endif
@implementation SS (System)
-#if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)
+#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
+ (NSS*)systemVersion { return [[UIDevice currentDevice] systemVersion]; }
-#elif defined TARGET_OS_MAC
+#elif TARGET_OS_MAC
+ (NSS*)systemVersion {
SInt32 versionMajor = 0;
SInt32 versionMinor = 0;
@@ -55,10 +55,10 @@ + (NSS*)systemVersion {
}
#endif
-#if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)
+#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
+ (B)macSystem { return NO; }
+ (B)iOSSystem { return YES; }
-#elif defined TARGET_OS_MAC
+#elif TARGET_OS_MAC
+ (B)macSystem { return YES; }
+ (B)iOSSystem { return NO; }
#endif
View
18 Lib/JavaScript/SS+JavaScript.m
@@ -35,7 +35,12 @@
#import "SS+Types.h"
#import "SSArguments.h"
-//#import <UIKit/UIKit.h> // TODO: make mac compliant and test-safe version
+#import "TargetConditionals.h"
+#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
+#import <UIKit/UIKit.h>
+#elif TARGET_OS_MAC
+#import <Cocoa/Cocoa.h>
+#endif
const NSS* SSJSTypeOfObject = @"object";
const NSS* SSJSTypeOfString = @"string";
@@ -130,10 +135,13 @@ @implementation SS (JavaScript)
+ (void(^)(NSO* message))alert
{
return ^(NSO* message) {
- // TODO: make mac compliant and test-safe version
-// UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"alert" message:message.toString() delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
-// [alertView show];
- NSLog(@"%@", message.toString());
+#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
+ UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"alert" message:message.toString() delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];
+ [alertView show];
+#elif TARGET_OS_MAC
+ NSAlert *alert = [NSAlert alertWithMessageText:@"alert" defaultButton:@"OK" alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@", message.toString()];
+ [alert beginSheetModalForWindow:NSApplication.sharedApplication.mainWindow modalDelegate:nil didEndSelector:nil contextInfo:nil];
+#endif
};
}
View
4 Lib/NSDictionary+NamedProperties.m
@@ -9,9 +9,9 @@
#import "NSDictionary+NamedProperties.h"
#import <objc/runtime.h>
-#if defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR)
+#if TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR
#define BLOCK_TO_IMPL(_b) imp_implementationWithBlock((void*)CFBridgingRetain(_b))
-#elif defined TARGET_OS_MAC
+#elif TARGET_OS_MAC
#define BLOCK_TO_IMPL(_b) imp_implementationWithBlock(_b)
#endif
View
48 SubjectiveScript.m.xcodeproj/project.pbxproj
@@ -7,8 +7,6 @@
objects = {
/* Begin PBXBuildFile section */
- 0A02E1B115C69E70006BD268 /* QUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A02E1AE15C69E70006BD268 /* QUnitTests.m */; };
- 0A02E1B215C69E70006BD268 /* QUWrap.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A02E1B015C69E70006BD268 /* QUWrap.m */; };
0A2A8BB315C7D573002A71DE /* NSString+Versioning.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A2A8B7A15C7D572002A71DE /* NSString+Versioning.h */; };
0A2A8BB415C7D573002A71DE /* NSString+Versioning.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A2A8B7B15C7D572002A71DE /* NSString+Versioning.m */; };
0A2A8BB515C7D573002A71DE /* NSString+Versioning.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A2A8B7B15C7D572002A71DE /* NSString+Versioning.m */; };
@@ -89,6 +87,9 @@
0A2A8C0015C7D573002A71DE /* NSString+SS.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A2A8BB115C7D573002A71DE /* NSString+SS.m */; };
0A2A8C0115C7D573002A71DE /* NSString+SS.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A2A8BB115C7D573002A71DE /* NSString+SS.m */; };
0A2A8C0215C7D573002A71DE /* SSTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A2A8BB215C7D573002A71DE /* SSTypes.h */; };
+ 0A73EB8D15CA2841001E299B /* QUnit.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A73EB8815CA2841001E299B /* QUnit.m */; };
+ 0A73EB8E15CA2841001E299B /* QUnitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A73EB8A15CA2841001E299B /* QUnitTests.m */; };
+ 0A73EB8F15CA2841001E299B /* QUWrap.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A73EB8C15CA2841001E299B /* QUWrap.m */; };
0AC6D60B15C618F6004C3000 /* SS+JavaScriptTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AC6D60A15C618F6004C3000 /* SS+JavaScriptTests.m */; };
0AC6D60E15C6190E004C3000 /* NSObject+JavaScriptTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AC6D60D15C6190E004C3000 /* NSObject+JavaScriptTests.m */; };
0AC6D61115C6192B004C3000 /* Array+JavaScriptTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AC6D61015C6192B004C3000 /* Array+JavaScriptTests.m */; };
@@ -123,11 +124,6 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
- 0A02E1AC15C69E70006BD268 /* QUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QUnit.h; sourceTree = "<group>"; };
- 0A02E1AD15C69E70006BD268 /* QUnitTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QUnitTests.h; sourceTree = "<group>"; };
- 0A02E1AE15C69E70006BD268 /* QUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QUnitTests.m; sourceTree = "<group>"; };
- 0A02E1AF15C69E70006BD268 /* QUWrap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QUWrap.h; sourceTree = "<group>"; };
- 0A02E1B015C69E70006BD268 /* QUWrap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QUWrap.m; sourceTree = "<group>"; };
0A2A8B7A15C7D572002A71DE /* NSString+Versioning.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+Versioning.h"; sourceTree = "<group>"; };
0A2A8B7B15C7D572002A71DE /* NSString+Versioning.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+Versioning.m"; sourceTree = "<group>"; };
0A2A8B7C15C7D572002A71DE /* SS+Functions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SS+Functions.h"; sourceTree = "<group>"; };
@@ -182,6 +178,12 @@
0A2A8BB015C7D573002A71DE /* NSString+SS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+SS.h"; sourceTree = "<group>"; };
0A2A8BB115C7D573002A71DE /* NSString+SS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+SS.m"; sourceTree = "<group>"; };
0A2A8BB215C7D573002A71DE /* SSTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSTypes.h; sourceTree = "<group>"; };
+ 0A73EB8715CA2841001E299B /* QUnit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QUnit.h; sourceTree = "<group>"; };
+ 0A73EB8815CA2841001E299B /* QUnit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QUnit.m; sourceTree = "<group>"; };
+ 0A73EB8915CA2841001E299B /* QUnitTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QUnitTests.h; sourceTree = "<group>"; };
+ 0A73EB8A15CA2841001E299B /* QUnitTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QUnitTests.m; sourceTree = "<group>"; };
+ 0A73EB8B15CA2841001E299B /* QUWrap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = QUWrap.h; sourceTree = "<group>"; };
+ 0A73EB8C15CA2841001E299B /* QUWrap.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = QUWrap.m; sourceTree = "<group>"; };
0AC6D60915C618F6004C3000 /* SS+JavaScriptTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "SS+JavaScriptTests.h"; sourceTree = "<group>"; };
0AC6D60A15C618F6004C3000 /* SS+JavaScriptTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "SS+JavaScriptTests.m"; sourceTree = "<group>"; };
0AC6D60C15C6190E004C3000 /* NSObject+JavaScriptTests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSObject+JavaScriptTests.h"; sourceTree = "<group>"; };
@@ -330,6 +332,19 @@
path = Types;
sourceTree = "<group>";
};
+ 0A73EB8615CA2841001E299B /* QUnit.m */ = {
+ isa = PBXGroup;
+ children = (
+ 0A73EB8715CA2841001E299B /* QUnit.h */,
+ 0A73EB8815CA2841001E299B /* QUnit.m */,
+ 0A73EB8915CA2841001E299B /* QUnitTests.h */,
+ 0A73EB8A15CA2841001E299B /* QUnitTests.m */,
+ 0A73EB8B15CA2841001E299B /* QUWrap.h */,
+ 0A73EB8C15CA2841001E299B /* QUWrap.m */,
+ );
+ path = QUnit.m;
+ sourceTree = "<group>";
+ };
0AC6D60215C618A5004C3000 /* Helpers */ = {
isa = PBXGroup;
children = (
@@ -382,24 +397,12 @@
0AF1939715C54A2000937CC7 /* Vendor */ = {
isa = PBXGroup;
children = (
- 0AF1939815C54A2000937CC7 /* QUnitTestCase.m */,
+ 0A73EB8615CA2841001E299B /* QUnit.m */,
);
name = Vendor;
path = SubjectiveScriptTests/Vendor;
sourceTree = SOURCE_ROOT;
};
- 0AF1939815C54A2000937CC7 /* QUnitTestCase.m */ = {
- isa = PBXGroup;
- children = (
- 0A02E1AC15C69E70006BD268 /* QUnit.h */,
- 0A02E1AD15C69E70006BD268 /* QUnitTests.h */,
- 0A02E1AE15C69E70006BD268 /* QUnitTests.m */,
- 0A02E1AF15C69E70006BD268 /* QUWrap.h */,
- 0A02E1B015C69E70006BD268 /* QUWrap.m */,
- );
- path = QUnitTestCase.m;
- sourceTree = "<group>";
- };
0AFE254515B59CD1008A8BA9 = {
isa = PBXGroup;
children = (
@@ -654,8 +657,6 @@
0AC6D62C15C61A77004C3000 /* Number+SSTests.m in Sources */,
0AC6D62F15C61A86004C3000 /* String+SSTests.m in Sources */,
0AC6D63215C61D72004C3000 /* Functions+JavaScriptTests.m in Sources */,
- 0A02E1B115C69E70006BD268 /* QUnitTests.m in Sources */,
- 0A02E1B215C69E70006BD268 /* QUWrap.m in Sources */,
0A2A8BB515C7D573002A71DE /* NSString+Versioning.m in Sources */,
0A2A8BB815C7D573002A71DE /* SS+Functions.m in Sources */,
0A2A8BBB15C7D573002A71DE /* SS+System.m in Sources */,
@@ -682,6 +683,9 @@
0A2A8BFB15C7D573002A71DE /* NSNumber+SS.m in Sources */,
0A2A8BFE15C7D573002A71DE /* NSObject+SS.m in Sources */,
0A2A8C0115C7D573002A71DE /* NSString+SS.m in Sources */,
+ 0A73EB8D15CA2841001E299B /* QUnit.m in Sources */,
+ 0A73EB8E15CA2841001E299B /* QUnitTests.m in Sources */,
+ 0A73EB8F15CA2841001E299B /* QUWrap.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
0 ...riptTests/Vendor/QUnitTestCase.m/QUWrap.h → ...ectiveScriptTests/Vendor/QUnit.m/QUWrap.h
File renamed without changes.
View
2 ...riptTests/Vendor/QUnitTestCase.m/QUWrap.m → ...ectiveScriptTests/Vendor/QUnit.m/QUWrap.m
@@ -29,7 +29,7 @@ + (id)wrap:(unsigned long long)value type:(char[2])type
case _C_UINT:
case _C_LNG:
case _C_ULNG:
- return [NSNumber numberWithInt:(NSInteger)value];
+ return [NSNumber numberWithInteger:(NSInteger)value];
case _C_CHR:
case _C_BOOL:
return [NSNumber numberWithBool:(BOOL)value];
View
4 ...criptTests/Vendor/QUnitTestCase.m/QUnit.h → SubjectiveScriptTests/Vendor/QUnit.m/QUnit.h
@@ -30,6 +30,10 @@
#import "QUnitTests.h"
#import "QUWrap.h"
+@interface QUnit : NSObject
++ (NSString*)VERSION;
+@end
+
/////////////////////////////
// Equality
/////////////////////////////
View
38 SubjectiveScriptTests/Vendor/QUnit.m/QUnit.m
@@ -0,0 +1,38 @@
+//
+// QUnit.m
+// QUnit.m
+//
+// Created by Kevin Malakoff on 7/23/12.
+// Copyright (c) 2012 Kevin Malakoff. All rights reserved.
+//
+// Permission is hereby granted, free of charge, to any person
+// obtaining a copy of this software and associated documentation
+// files (the "Software"), to deal in the Software without
+// restriction, including without limitation the rights to use,
+// copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following
+// conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+// OTHER DEALINGS IN THE SOFTWARE.
+//
+
+#import "QUnit.h"
+
+static NSString* QUVERSION = @"0.1.0";
+
+@implementation QUnit
+
++ (NSString*)VERSION { return QUVERSION; }
+
+@end
View
10 ...Tests/Vendor/QUnitTestCase.m/QUnitTests.h → ...veScriptTests/Vendor/QUnit.m/QUnitTests.h
@@ -32,13 +32,13 @@
@interface QUnitTests : NSObject
-+ (void)equal:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(NSUInteger)lineNumber strict:(BOOL)strict;
-+ (void)deepEqual:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(NSUInteger)lineNumber;
++ (void)equal:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(int)lineNumber strict:(BOOL)strict;
++ (void)deepEqual:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(int)lineNumber;
-+ (void)notEqual:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(NSUInteger)lineNumber strict:(BOOL)strict;
++ (void)notEqual:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(int)lineNumber strict:(BOOL)strict;
-+ (void)ok:(SenTestCase*)testCase result:(BOOL)result expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(NSUInteger)lineNumber;
++ (void)ok:(SenTestCase*)testCase result:(BOOL)result expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(int)lineNumber;
-+ (void)raises:(SenTestCase*)testCase callback:(void(^)())callback expectedExceptionName:(NSString*)expectedExceptionName expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(NSUInteger)lineNumber;
++ (void)raises:(SenTestCase*)testCase callback:(void(^)())callback expectedExceptionName:(NSString*)expectedExceptionName expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(int)lineNumber;
@end
View
10 ...Tests/Vendor/QUnitTestCase.m/QUnitTests.m → ...veScriptTests/Vendor/QUnit.m/QUnitTests.m
@@ -31,7 +31,7 @@
@implementation QUnitTests
-+ (void)equal:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(NSUInteger)lineNumber strict:(BOOL)strict
++ (void)equal:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(int)lineNumber strict:(BOOL)strict
{
@try {
if (actual == expected)
@@ -56,7 +56,7 @@ + (void)equal:(SenTestCase*)testCase actual:(id)actual expected:(id)expected exp
}
}
-+ (void)deepEqual:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(NSUInteger)lineNumber
++ (void)deepEqual:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(int)lineNumber
{
if ([actual isKindOfClass:[NSArray class]]) {
NSArray *actualArray = actual;
@@ -80,7 +80,7 @@ + (void)deepEqual:(SenTestCase*)testCase actual:(id)actual expected:(id)expected
[QUnitTests equal:testCase actual:actual expected:expected expression:expression description:description filename:filename lineNumber:lineNumber strict:YES];
}
-+ (void)notEqual:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(NSUInteger)lineNumber strict:(BOOL)strict
++ (void)notEqual:(SenTestCase*)testCase actual:(id)actual expected:(id)expected expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(int)lineNumber strict:(BOOL)strict
{
@try {
if (actual != expected)
@@ -105,15 +105,15 @@ + (void)notEqual:(SenTestCase*)testCase actual:(id)actual expected:(id)expected
}
}
-+ (void)ok:(SenTestCase*)testCase result:(BOOL)result expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(NSUInteger)lineNumber
++ (void)ok:(SenTestCase*)testCase result:(BOOL)result expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(int)lineNumber
{
if (result)
return;
[testCase failWithException:([NSException failureInCondition:expression isTrue:result inFile:filename atLine:lineNumber withDescription:description])];
}
-+ (void)raises:(SenTestCase*)testCase callback:(void(^)())callback expectedExceptionName:(NSString*)expectedExceptionName expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(NSUInteger)lineNumber
++ (void)raises:(SenTestCase*)testCase callback:(void(^)())callback expectedExceptionName:(NSString*)expectedExceptionName expression:(NSString*)expression description:(NSString*)description filename:(NSString*)filename lineNumber:(int)lineNumber
{
@try {
callback();

0 comments on commit 2d18949

Please sign in to comment.
Something went wrong with that request. Please try again.