Compare commits

...

23 Commits

Author SHA1 Message Date
Lukas Kubanek 2438623b7c Updated README for 0.6 release 2016-03-27 16:55:29 +02:00
Lukas Kubanek af69193370 Updated README 2016-03-27 16:34:25 +02:00
Lukas Kubanek 20c169a7b8 Updated Travis CI configuration for Xcode 7.3 2016-03-27 16:21:25 +02:00
Lukas Kubanek 87efd44e09 Minor refactoring 2016-03-27 13:17:41 +02:00
Lukas Kubanek e7bba55479 Updated syntax for Swift 2.2 2016-02-16 07:46:01 +01:00
Lukas Kubanek 4dcdf588ee Updated to Xcode 7.3 beta 2016-01-24 11:23:56 +01:00
Lukas Kubanek 4065061d25 Bumped version 2016-01-06 23:51:04 +01:00
Marius Bergmann 60ffb98742 Set iOS deployment target to 8.0
All tests also pass on 8.0. This makes it possible to use the project in
an 8.x application.
2016-01-05 16:56:09 +01:00
Lukas Kubanek d70db906df Fix in the README 2015-12-18 10:19:39 +01:00
Lukas Kubanek 30bb351de2 Updated to Xcode 7.2 2015-12-15 12:20:05 +01:00
Lukas Kubanek 0022833380 Fixed a typo 2015-12-10 10:11:04 +01:00
Lukas Kubanek 1219d6dd8a Updated README and playground 2015-12-06 14:48:50 +01:00
Lukas Kubanek c5e6b63a9c Added support for sorting
Closes #5
2015-12-06 14:30:23 +01:00
Lukas Kubanek a2d0ef2c1b Cleaned up tests 2015-12-06 14:16:42 +01:00
Lukas Kubanek 61729a772b Updated framework search headers 2015-12-06 13:56:39 +01:00
Lukas Kubanek 5e51f91e07 The backing store properties are now initialized in-place 2015-12-04 13:58:55 +01:00
Lukas Kubanek 5acd33d10a Removed the dependency on Nimble for tests 2015-11-27 15:13:04 +01:00
Lukas Kubanek 1a4623ceff And hopefully the last change 2015-11-15 18:45:01 +01:00
Lukas Kubanek 8016abd95b Synxed with an older version of synx and fixed Carthage 2015-11-15 17:52:18 +01:00
Lukas Kubanek e58469f8e4 Synxed the project structure and updated dependencies
- Added Carthage to .gitignore
- Updated Nimble to v3.0
- Added a script for updating the dependencies
2015-11-15 17:01:36 +01:00
Lukas Kubanek 100e077a0d Added a convenience method for inserting new element 2015-11-04 13:51:17 +01:00
Lukas Kubanek 72ccef23af Updated installation section in README 2015-10-21 11:50:19 +02:00
Lukas Kubanek 1a9ac85931 Added properties orderedKeys & orderedValues
Closes #1
2015-10-14 20:48:41 +02:00
47 changed files with 376 additions and 1617 deletions
+1 -2
View File
@@ -26,5 +26,4 @@ DerivedData
*.xctimeline
# Carthage
Carthage/Checkouts
Carthage/**/OrderedDictionary*
Carthage
+5 -5
View File
@@ -1,13 +1,13 @@
language: objective-c
osx_image: xcode7.3
xcode_project: OrderedDictionary.xcodeproj
xcode_scheme: OrderedDictionary-iOS
xcode_sdk: iphonesimulator
branches:
only:
- master
xcode_project: OrderedDictionary.xcodeproj
xcode_scheme: OrderedDictionary-iOS
osx_image: xcode7
xcode_sdk: iphonesimulator
script:
- xcodebuild clean build test -project OrderedDictionary.xcodeproj -scheme OrderedDictionary-iOS -destination "platform=iOS Simulator,name=iPhone 6,OS=9.0"
-1
View File
@@ -1 +0,0 @@
github "Quick/Nimble" "e84623d953d811f74a2afcda4fa0c8121e7dad7d"
-1
View File
@@ -1 +0,0 @@
github "Quick/Nimble" "e84623d953d811f74a2afcda4fa0c8121e7dad7d"
-20
View File
@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.net.jeffhui.Nimble</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Binary file not shown.
-1
View File
@@ -1 +0,0 @@
Versions/Current/Headers
-1
View File
@@ -1 +0,0 @@
Versions/Current/Modules
-1
View File
@@ -1 +0,0 @@
Versions/Current/Nimble
-1
View File
@@ -1 +0,0 @@
Versions/Current/Resources
-129
View File
@@ -1,129 +0,0 @@
#import <Foundation/Foundation.h>
@class NMBExpectation;
@class NMBObjCBeCloseToMatcher;
@class NMBObjCRaiseExceptionMatcher;
@protocol NMBMatcher;
#define NIMBLE_EXPORT FOUNDATION_EXPORT
#ifdef NIMBLE_DISABLE_SHORT_SYNTAX
#define NIMBLE_SHORT(PROTO, ORIGINAL)
#else
#define NIMBLE_SHORT(PROTO, ORIGINAL) FOUNDATION_STATIC_INLINE PROTO { return (ORIGINAL); }
#endif
NIMBLE_EXPORT NMBExpectation *NMB_expect(id(^actualBlock)(), NSString *file, NSUInteger line);
NIMBLE_EXPORT NMBExpectation *NMB_expectAction(void(^actualBlock)(), NSString *file, NSUInteger line);
NIMBLE_EXPORT id<NMBMatcher> NMB_equal(id expectedValue);
NIMBLE_SHORT(id<NMBMatcher> equal(id expectedValue),
NMB_equal(expectedValue));
NIMBLE_EXPORT NMBObjCBeCloseToMatcher *NMB_beCloseTo(NSNumber *expectedValue);
NIMBLE_SHORT(NMBObjCBeCloseToMatcher *beCloseTo(id expectedValue),
NMB_beCloseTo(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_beAnInstanceOf(Class expectedClass);
NIMBLE_SHORT(id<NMBMatcher> beAnInstanceOf(Class expectedClass),
NMB_beAnInstanceOf(expectedClass));
NIMBLE_EXPORT id<NMBMatcher> NMB_beAKindOf(Class expectedClass);
NIMBLE_SHORT(id<NMBMatcher> beAKindOf(Class expectedClass),
NMB_beAKindOf(expectedClass));
NIMBLE_EXPORT id<NMBMatcher> NMB_beginWith(id itemElementOrSubstring);
NIMBLE_SHORT(id<NMBMatcher> beginWith(id itemElementOrSubstring),
NMB_beginWith(itemElementOrSubstring));
NIMBLE_EXPORT id<NMBMatcher> NMB_beGreaterThan(NSNumber *expectedValue);
NIMBLE_SHORT(id<NMBMatcher> beGreaterThan(NSNumber *expectedValue),
NMB_beGreaterThan(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_beGreaterThanOrEqualTo(NSNumber *expectedValue);
NIMBLE_SHORT(id<NMBMatcher> beGreaterThanOrEqualTo(NSNumber *expectedValue),
NMB_beGreaterThanOrEqualTo(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_beIdenticalTo(id expectedInstance);
NIMBLE_SHORT(id<NMBMatcher> beIdenticalTo(id expectedInstance),
NMB_beIdenticalTo(expectedInstance));
NIMBLE_EXPORT id<NMBMatcher> NMB_beLessThan(NSNumber *expectedValue);
NIMBLE_SHORT(id<NMBMatcher> beLessThan(NSNumber *expectedValue),
NMB_beLessThan(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_beLessThanOrEqualTo(NSNumber *expectedValue);
NIMBLE_SHORT(id<NMBMatcher> beLessThanOrEqualTo(NSNumber *expectedValue),
NMB_beLessThanOrEqualTo(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_beTruthy(void);
NIMBLE_SHORT(id<NMBMatcher> beTruthy(void),
NMB_beTruthy());
NIMBLE_EXPORT id<NMBMatcher> NMB_beFalsy(void);
NIMBLE_SHORT(id<NMBMatcher> beFalsy(void),
NMB_beFalsy());
NIMBLE_EXPORT id<NMBMatcher> NMB_beTrue(void);
NIMBLE_SHORT(id<NMBMatcher> beTrue(void),
NMB_beTrue());
NIMBLE_EXPORT id<NMBMatcher> NMB_beFalse(void);
NIMBLE_SHORT(id<NMBMatcher> beFalse(void),
NMB_beFalse());
NIMBLE_EXPORT id<NMBMatcher> NMB_beNil(void);
NIMBLE_SHORT(id<NMBMatcher> beNil(void),
NMB_beNil());
NIMBLE_EXPORT id<NMBMatcher> NMB_beEmpty(void);
NIMBLE_SHORT(id<NMBMatcher> beEmpty(void),
NMB_beEmpty());
NIMBLE_EXPORT id<NMBMatcher> NMB_containWithNilTermination(id itemOrSubstring, ...) NS_REQUIRES_NIL_TERMINATION;
#define NMB_contain(...) NMB_containWithNilTermination(__VA_ARGS__, nil)
#ifndef NIMBLE_DISABLE_SHORT_SYNTAX
#define contain(...) NMB_contain(__VA_ARGS__)
#endif
NIMBLE_EXPORT id<NMBMatcher> NMB_endWith(id itemElementOrSubstring);
NIMBLE_SHORT(id<NMBMatcher> endWith(id itemElementOrSubstring),
NMB_endWith(itemElementOrSubstring));
NIMBLE_EXPORT NMBObjCRaiseExceptionMatcher *NMB_raiseException(void);
NIMBLE_SHORT(NMBObjCRaiseExceptionMatcher *raiseException(void),
NMB_raiseException());
NIMBLE_EXPORT id<NMBMatcher> NMB_match(id expectedValue);
NIMBLE_SHORT(id<NMBMatcher> match(id expectedValue),
NMB_match(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_allPass(id matcher);
NIMBLE_SHORT(id<NMBMatcher> allPass(id matcher),
NMB_allPass(matcher));
// In order to preserve breakpoint behavior despite using macros to fill in __FILE__ and __LINE__,
// define a builder that populates __FILE__ and __LINE__, and returns a block that takes timeout
// and action arguments. See https://github.com/Quick/Quick/pull/185 for details.
typedef void (^NMBWaitUntilTimeoutBlock)(NSTimeInterval timeout, void (^action)(void (^)(void)));
typedef void (^NMBWaitUntilBlock)(void (^action)(void (^)(void)));
NIMBLE_EXPORT NMBWaitUntilTimeoutBlock NMB_waitUntilTimeoutBuilder(NSString *file, NSUInteger line);
NIMBLE_EXPORT NMBWaitUntilBlock NMB_waitUntilBuilder(NSString *file, NSUInteger line);
NIMBLE_EXPORT void NMB_failWithMessage(NSString *msg, NSString *file, NSUInteger line);
#define NMB_waitUntilTimeout NMB_waitUntilTimeoutBuilder(@(__FILE__), __LINE__)
#define NMB_waitUntil NMB_waitUntilBuilder(@(__FILE__), __LINE__)
#ifndef NIMBLE_DISABLE_SHORT_SYNTAX
#define expect(...) NMB_expect(^id{ return (__VA_ARGS__); }, @(__FILE__), __LINE__)
#define expectAction(BLOCK) NMB_expectAction((BLOCK), @(__FILE__), __LINE__)
#define failWithMessage(msg) NMB_failWithMessage(msg, @(__FILE__), __LINE__)
#define fail() failWithMessage(@"fail() always fails")
#define waitUntilTimeout NMB_waitUntilTimeout
#define waitUntil NMB_waitUntil
#endif
@@ -1,8 +0,0 @@
#import <Foundation/Foundation.h>
@interface NMBExceptionCapture : NSObject
- (id)initWithHandler:(void(^)(NSException *))handler finally:(void(^)())finally;
- (void)tryBlock:(void(^)())unsafeBlock;
@end
-364
View File
@@ -1,364 +0,0 @@
// Generated by Apple Swift version 2.0 (swiftlang-700.0.57.3 clang-700.0.72)
#pragma clang diagnostic push
#if defined(__has_include) && __has_include(<swift/objc-prologue.h>)
# include <swift/objc-prologue.h>
#endif
#pragma clang diagnostic ignored "-Wauto-import"
#include <objc/NSObject.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#if defined(__has_include) && __has_include(<uchar.h>)
# include <uchar.h>
#elif !defined(__cplusplus) || __cplusplus < 201103L
typedef uint_least16_t char16_t;
typedef uint_least32_t char32_t;
#endif
typedef struct _NSZone NSZone;
#if !defined(SWIFT_PASTE)
# define SWIFT_PASTE_HELPER(x, y) x##y
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
#endif
#if !defined(SWIFT_METATYPE)
# define SWIFT_METATYPE(X) Class
#endif
#if defined(__has_attribute) && __has_attribute(objc_runtime_name)
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
#else
# define SWIFT_RUNTIME_NAME(X)
#endif
#if defined(__has_attribute) && __has_attribute(swift_name)
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
#else
# define SWIFT_COMPILE_NAME(X)
#endif
#if !defined(SWIFT_CLASS_EXTRA)
# define SWIFT_CLASS_EXTRA
#endif
#if !defined(SWIFT_PROTOCOL_EXTRA)
# define SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_ENUM_EXTRA)
# define SWIFT_ENUM_EXTRA
#endif
#if !defined(SWIFT_CLASS)
# if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted)
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# else
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# endif
#endif
#if !defined(SWIFT_PROTOCOL)
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_EXTENSION)
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
#endif
#if !defined(OBJC_DESIGNATED_INITIALIZER)
# if defined(__has_attribute) && __has_attribute(objc_designated_initializer)
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
# else
# define OBJC_DESIGNATED_INITIALIZER
# endif
#endif
#if !defined(SWIFT_ENUM)
# define SWIFT_ENUM(_type, _name) enum _name : _type _name; enum SWIFT_ENUM_EXTRA _name : _type
#endif
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
#if defined(__has_feature) && __has_feature(modules)
@import ObjectiveC;
@import Foundation;
#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
/// Encapsulates the failure message that matchers can report to the end user.
///
/// This is shared state between Nimble and matchers that mutate this value.
SWIFT_CLASS("_TtC6Nimble14FailureMessage")
@interface FailureMessage : NSObject
@property (nonatomic, copy) NSString * __nonnull expected;
@property (nonatomic, copy) NSString * __nullable actualValue;
@property (nonatomic, copy) NSString * __nonnull to;
@property (nonatomic, copy) NSString * __nonnull postfixMessage;
@property (nonatomic, copy) NSString * __nonnull postfixActual;
@property (nonatomic, copy) NSString * __nullable userDescription;
@property (nonatomic, copy) NSString * __nonnull stringValue;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithStringValue:(NSString * __nonnull)stringValue OBJC_DESIGNATED_INITIALIZER;
@end
/// Protocol for types that support only beEmpty()
SWIFT_PROTOCOL("_TtP6Nimble13NMBCollection_")
@protocol NMBCollection
@property (nonatomic, readonly) NSInteger count;
@end
/// Protocol for types to support beLessThan(), beLessThanOrEqualTo(), beGreaterThan(), beGreaterThanOrEqualTo(), and equal() matchers.
///
/// Types that conform to Swift's Comparable protocol will work implicitly too
SWIFT_PROTOCOL("_TtP6Nimble13NMBComparable_")
@protocol NMBComparable
- (NSComparisonResult)NMB_compare:(id <NMBComparable> __null_unspecified)otherObject;
@end
/// Protocol for types that support contain() matcher.
SWIFT_PROTOCOL("_TtP6Nimble12NMBContainer_")
@protocol NMBContainer
- (BOOL)containsObject:(id __null_unspecified)object;
@end
/// Protocol for types to support beCloseTo() matcher
SWIFT_PROTOCOL("_TtP6Nimble20NMBDoubleConvertible_")
@protocol NMBDoubleConvertible
@property (nonatomic, readonly) double doubleValue;
@end
@protocol NMBMatcher;
SWIFT_CLASS("_TtC6Nimble14NMBExpectation")
@interface NMBExpectation : NSObject
- (nonnull instancetype)initWithActualBlock:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock negative:(BOOL)negative file:(NSString * __nonnull)file line:(NSUInteger)line OBJC_DESIGNATED_INITIALIZER;
@property (nonatomic, readonly, copy) NMBExpectation * __nonnull (^ __nonnull withTimeout)(NSTimeInterval);
@property (nonatomic, readonly, copy) void (^ __nonnull to)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toNot)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toNotWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull notTo)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull notToWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toEventually)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toEventuallyWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toEventuallyNot)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toEventuallyNotWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toNotEventually)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toNotEventuallyWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
+ (void)failWithMessage:(NSString * __nonnull)message file:(NSString * __nonnull)file line:(NSUInteger)line;
@end
@class SourceLocation;
/// Objective-C interface to the Swift variant of Matcher.
SWIFT_PROTOCOL("_TtP6Nimble10NMBMatcher_")
@protocol NMBMatcher
- (BOOL)matches:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
- (BOOL)doesNotMatch:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
@end
SWIFT_CLASS("_TtC6Nimble23NMBObjCBeCloseToMatcher")
@interface NMBObjCBeCloseToMatcher : NSObject <NMBMatcher>
- (BOOL)matches:(NSObject * __null_unspecified (^ __nonnull)(void))actualExpression failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
- (BOOL)doesNotMatch:(NSObject * __null_unspecified (^ __nonnull)(void))actualExpression failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
@property (nonatomic, readonly, copy) NMBObjCBeCloseToMatcher * __nonnull (^ __nonnull within)(double);
@end
SWIFT_CLASS("_TtC6Nimble14NMBObjCMatcher")
@interface NMBObjCMatcher : NSObject <NMBMatcher>
- (BOOL)matches:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
- (BOOL)doesNotMatch:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beEmptyMatcher;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beIdenticalToMatcher:(NSObject * __nullable)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beginWithMatcher:(id __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beGreaterThanOrEqualToMatcher:(id <NMBComparable> __nullable)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)containMatcher:(NSArray<NSObject *> * __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beGreaterThanMatcher:(id <NMBComparable> __nullable)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beLessThanMatcher:(id <NMBComparable> __nullable)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (id <NMBMatcher> __nonnull)equalMatcher:(NSObject * __nonnull)expected;
@end
@class NSString;
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (id <NMBMatcher> __nonnull)matchMatcher:(NSString * __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (id <NMBMatcher> __nonnull)beAKindOfMatcher:(Class __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)allPassMatcher:(NMBObjCMatcher * __nonnull)matcher;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (id <NMBMatcher> __nonnull)beAnInstanceOfMatcher:(Class __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beLessThanOrEqualToMatcher:(id <NMBComparable> __nullable)expected;
@end
@class NSNumber;
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCBeCloseToMatcher * __nonnull)beCloseToMatcher:(NSNumber * __nonnull)expected within:(double)within;
@end
@class NMBObjCRaiseExceptionMatcher;
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCRaiseExceptionMatcher * __nonnull)raiseExceptionMatcher;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)endWithMatcher:(id __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beNilMatcher;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beTruthyMatcher;
+ (NMBObjCMatcher * __nonnull)beFalsyMatcher;
+ (NMBObjCMatcher * __nonnull)beTrueMatcher;
+ (NMBObjCMatcher * __nonnull)beFalseMatcher;
@end
@class NSDictionary;
@class NSException;
SWIFT_CLASS("_TtC6Nimble28NMBObjCRaiseExceptionMatcher")
@interface NMBObjCRaiseExceptionMatcher : NSObject <NMBMatcher>
- (BOOL)matches:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
- (BOOL)doesNotMatch:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
@property (nonatomic, readonly, copy) NMBObjCRaiseExceptionMatcher * __nonnull (^ __nonnull named)(NSString * __nonnull);
@property (nonatomic, readonly, copy) NMBObjCRaiseExceptionMatcher * __nonnull (^ __nonnull reason)(NSString * __nullable);
@property (nonatomic, readonly, copy) NMBObjCRaiseExceptionMatcher * __nonnull (^ __nonnull userInfo)(NSDictionary * __nullable);
@property (nonatomic, readonly, copy) NMBObjCRaiseExceptionMatcher * __nonnull (^ __nonnull satisfyingBlock)(void (^ __nullable)(NSException * __nonnull));
@end
/// Protocol for types that support beginWith(), endWith(), beEmpty() matchers
SWIFT_PROTOCOL("_TtP6Nimble20NMBOrderedCollection_")
@protocol NMBOrderedCollection <NMBCollection>
- (NSInteger)indexOfObject:(id __null_unspecified)object;
@end
@interface NSArray (SWIFT_EXTENSION(Nimble)) <NMBContainer>
@end
@interface NSArray (SWIFT_EXTENSION(Nimble)) <NMBOrderedCollection, NMBCollection>
@end
@interface NSArray (SWIFT_EXTENSION(Nimble))
@end
@interface NSDictionary (SWIFT_EXTENSION(Nimble)) <NMBCollection>
@end
@interface NSHashTable (SWIFT_EXTENSION(Nimble)) <NMBContainer>
@end
@interface NSHashTable (SWIFT_EXTENSION(Nimble)) <NMBCollection>
@end
@interface NSNumber (SWIFT_EXTENSION(Nimble)) <NMBDoubleConvertible>
@end
@interface NSNumber (SWIFT_EXTENSION(Nimble)) <NMBComparable>
- (NSComparisonResult)NMB_compare:(id <NMBComparable> __null_unspecified)otherObject;
@end
@interface NSSet (SWIFT_EXTENSION(Nimble)) <NMBCollection>
@end
@interface NSSet (SWIFT_EXTENSION(Nimble)) <NMBContainer>
@end
@interface NSString (SWIFT_EXTENSION(Nimble)) <NMBComparable>
- (NSComparisonResult)NMB_compare:(id <NMBComparable> __null_unspecified)otherObject;
@end
SWIFT_CLASS("_TtC6Nimble14SourceLocation")
@interface SourceLocation : NSObject
@property (nonatomic, readonly, copy) NSString * __nonnull file;
@property (nonatomic, readonly) NSUInteger line;
@property (nonatomic, readonly, copy) NSString * __nonnull description;
@end
#pragma clang diagnostic pop
-6
View File
@@ -1,6 +0,0 @@
#import <Foundation/Foundation.h>
#import <Nimble/NMBExceptionCapture.h>
#import <Nimble/DSL.h>
FOUNDATION_EXPORT double NimbleVersionNumber;
FOUNDATION_EXPORT const unsigned char NimbleVersionString[];
@@ -1,10 +0,0 @@
framework module Nimble {
umbrella header "Nimble.h"
export *
module * { export * }
}
module Nimble.Swift {
header "Nimble-Swift.h"
}
Binary file not shown.
-51
View File
@@ -1,51 +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>BuildMachineOSBuild</key>
<string>14F27</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>Nimble</string>
<key>CFBundleIdentifier</key>
<string>net.jeffhui.Nimble</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Nimble</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
</array>
<key>CFBundleVersion</key>
<string>1</string>
<key>DTCompiler</key>
<string>com.apple.compilers.llvm.clang.1_0</string>
<key>DTPlatformBuild</key>
<string>7A192o</string>
<key>DTPlatformVersion</key>
<string>GM</string>
<key>DTSDKBuild</key>
<string>15A244e</string>
<key>DTSDKName</key>
<string>macosx10.11</string>
<key>DTXcode</key>
<string>0700</string>
<key>DTXcodeBuild</key>
<string>7A192o</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2014 Jeff Hui. All rights reserved.</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
</dict>
</plist>
-1
View File
@@ -1 +0,0 @@
A
-20
View File
@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.apple.xcode.dsym.net.jeffhui.Nimble</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>dSYM</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Binary file not shown.
-129
View File
@@ -1,129 +0,0 @@
#import <Foundation/Foundation.h>
@class NMBExpectation;
@class NMBObjCBeCloseToMatcher;
@class NMBObjCRaiseExceptionMatcher;
@protocol NMBMatcher;
#define NIMBLE_EXPORT FOUNDATION_EXPORT
#ifdef NIMBLE_DISABLE_SHORT_SYNTAX
#define NIMBLE_SHORT(PROTO, ORIGINAL)
#else
#define NIMBLE_SHORT(PROTO, ORIGINAL) FOUNDATION_STATIC_INLINE PROTO { return (ORIGINAL); }
#endif
NIMBLE_EXPORT NMBExpectation *NMB_expect(id(^actualBlock)(), NSString *file, NSUInteger line);
NIMBLE_EXPORT NMBExpectation *NMB_expectAction(void(^actualBlock)(), NSString *file, NSUInteger line);
NIMBLE_EXPORT id<NMBMatcher> NMB_equal(id expectedValue);
NIMBLE_SHORT(id<NMBMatcher> equal(id expectedValue),
NMB_equal(expectedValue));
NIMBLE_EXPORT NMBObjCBeCloseToMatcher *NMB_beCloseTo(NSNumber *expectedValue);
NIMBLE_SHORT(NMBObjCBeCloseToMatcher *beCloseTo(id expectedValue),
NMB_beCloseTo(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_beAnInstanceOf(Class expectedClass);
NIMBLE_SHORT(id<NMBMatcher> beAnInstanceOf(Class expectedClass),
NMB_beAnInstanceOf(expectedClass));
NIMBLE_EXPORT id<NMBMatcher> NMB_beAKindOf(Class expectedClass);
NIMBLE_SHORT(id<NMBMatcher> beAKindOf(Class expectedClass),
NMB_beAKindOf(expectedClass));
NIMBLE_EXPORT id<NMBMatcher> NMB_beginWith(id itemElementOrSubstring);
NIMBLE_SHORT(id<NMBMatcher> beginWith(id itemElementOrSubstring),
NMB_beginWith(itemElementOrSubstring));
NIMBLE_EXPORT id<NMBMatcher> NMB_beGreaterThan(NSNumber *expectedValue);
NIMBLE_SHORT(id<NMBMatcher> beGreaterThan(NSNumber *expectedValue),
NMB_beGreaterThan(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_beGreaterThanOrEqualTo(NSNumber *expectedValue);
NIMBLE_SHORT(id<NMBMatcher> beGreaterThanOrEqualTo(NSNumber *expectedValue),
NMB_beGreaterThanOrEqualTo(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_beIdenticalTo(id expectedInstance);
NIMBLE_SHORT(id<NMBMatcher> beIdenticalTo(id expectedInstance),
NMB_beIdenticalTo(expectedInstance));
NIMBLE_EXPORT id<NMBMatcher> NMB_beLessThan(NSNumber *expectedValue);
NIMBLE_SHORT(id<NMBMatcher> beLessThan(NSNumber *expectedValue),
NMB_beLessThan(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_beLessThanOrEqualTo(NSNumber *expectedValue);
NIMBLE_SHORT(id<NMBMatcher> beLessThanOrEqualTo(NSNumber *expectedValue),
NMB_beLessThanOrEqualTo(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_beTruthy(void);
NIMBLE_SHORT(id<NMBMatcher> beTruthy(void),
NMB_beTruthy());
NIMBLE_EXPORT id<NMBMatcher> NMB_beFalsy(void);
NIMBLE_SHORT(id<NMBMatcher> beFalsy(void),
NMB_beFalsy());
NIMBLE_EXPORT id<NMBMatcher> NMB_beTrue(void);
NIMBLE_SHORT(id<NMBMatcher> beTrue(void),
NMB_beTrue());
NIMBLE_EXPORT id<NMBMatcher> NMB_beFalse(void);
NIMBLE_SHORT(id<NMBMatcher> beFalse(void),
NMB_beFalse());
NIMBLE_EXPORT id<NMBMatcher> NMB_beNil(void);
NIMBLE_SHORT(id<NMBMatcher> beNil(void),
NMB_beNil());
NIMBLE_EXPORT id<NMBMatcher> NMB_beEmpty(void);
NIMBLE_SHORT(id<NMBMatcher> beEmpty(void),
NMB_beEmpty());
NIMBLE_EXPORT id<NMBMatcher> NMB_containWithNilTermination(id itemOrSubstring, ...) NS_REQUIRES_NIL_TERMINATION;
#define NMB_contain(...) NMB_containWithNilTermination(__VA_ARGS__, nil)
#ifndef NIMBLE_DISABLE_SHORT_SYNTAX
#define contain(...) NMB_contain(__VA_ARGS__)
#endif
NIMBLE_EXPORT id<NMBMatcher> NMB_endWith(id itemElementOrSubstring);
NIMBLE_SHORT(id<NMBMatcher> endWith(id itemElementOrSubstring),
NMB_endWith(itemElementOrSubstring));
NIMBLE_EXPORT NMBObjCRaiseExceptionMatcher *NMB_raiseException(void);
NIMBLE_SHORT(NMBObjCRaiseExceptionMatcher *raiseException(void),
NMB_raiseException());
NIMBLE_EXPORT id<NMBMatcher> NMB_match(id expectedValue);
NIMBLE_SHORT(id<NMBMatcher> match(id expectedValue),
NMB_match(expectedValue));
NIMBLE_EXPORT id<NMBMatcher> NMB_allPass(id matcher);
NIMBLE_SHORT(id<NMBMatcher> allPass(id matcher),
NMB_allPass(matcher));
// In order to preserve breakpoint behavior despite using macros to fill in __FILE__ and __LINE__,
// define a builder that populates __FILE__ and __LINE__, and returns a block that takes timeout
// and action arguments. See https://github.com/Quick/Quick/pull/185 for details.
typedef void (^NMBWaitUntilTimeoutBlock)(NSTimeInterval timeout, void (^action)(void (^)(void)));
typedef void (^NMBWaitUntilBlock)(void (^action)(void (^)(void)));
NIMBLE_EXPORT NMBWaitUntilTimeoutBlock NMB_waitUntilTimeoutBuilder(NSString *file, NSUInteger line);
NIMBLE_EXPORT NMBWaitUntilBlock NMB_waitUntilBuilder(NSString *file, NSUInteger line);
NIMBLE_EXPORT void NMB_failWithMessage(NSString *msg, NSString *file, NSUInteger line);
#define NMB_waitUntilTimeout NMB_waitUntilTimeoutBuilder(@(__FILE__), __LINE__)
#define NMB_waitUntil NMB_waitUntilBuilder(@(__FILE__), __LINE__)
#ifndef NIMBLE_DISABLE_SHORT_SYNTAX
#define expect(...) NMB_expect(^id{ return (__VA_ARGS__); }, @(__FILE__), __LINE__)
#define expectAction(BLOCK) NMB_expectAction((BLOCK), @(__FILE__), __LINE__)
#define failWithMessage(msg) NMB_failWithMessage(msg, @(__FILE__), __LINE__)
#define fail() failWithMessage(@"fail() always fails")
#define waitUntilTimeout NMB_waitUntilTimeout
#define waitUntil NMB_waitUntil
#endif
-8
View File
@@ -1,8 +0,0 @@
#import <Foundation/Foundation.h>
@interface NMBExceptionCapture : NSObject
- (id)initWithHandler:(void(^)(NSException *))handler finally:(void(^)())finally;
- (void)tryBlock:(void(^)())unsafeBlock;
@end
-364
View File
@@ -1,364 +0,0 @@
// Generated by Apple Swift version 2.0 (swiftlang-700.0.57.3 clang-700.0.72)
#pragma clang diagnostic push
#if defined(__has_include) && __has_include(<swift/objc-prologue.h>)
# include <swift/objc-prologue.h>
#endif
#pragma clang diagnostic ignored "-Wauto-import"
#include <objc/NSObject.h>
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#if defined(__has_include) && __has_include(<uchar.h>)
# include <uchar.h>
#elif !defined(__cplusplus) || __cplusplus < 201103L
typedef uint_least16_t char16_t;
typedef uint_least32_t char32_t;
#endif
typedef struct _NSZone NSZone;
#if !defined(SWIFT_PASTE)
# define SWIFT_PASTE_HELPER(x, y) x##y
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
#endif
#if !defined(SWIFT_METATYPE)
# define SWIFT_METATYPE(X) Class
#endif
#if defined(__has_attribute) && __has_attribute(objc_runtime_name)
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
#else
# define SWIFT_RUNTIME_NAME(X)
#endif
#if defined(__has_attribute) && __has_attribute(swift_name)
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
#else
# define SWIFT_COMPILE_NAME(X)
#endif
#if !defined(SWIFT_CLASS_EXTRA)
# define SWIFT_CLASS_EXTRA
#endif
#if !defined(SWIFT_PROTOCOL_EXTRA)
# define SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_ENUM_EXTRA)
# define SWIFT_ENUM_EXTRA
#endif
#if !defined(SWIFT_CLASS)
# if defined(__has_attribute) && __has_attribute(objc_subclassing_restricted)
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# else
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
# endif
#endif
#if !defined(SWIFT_PROTOCOL)
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
#endif
#if !defined(SWIFT_EXTENSION)
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
#endif
#if !defined(OBJC_DESIGNATED_INITIALIZER)
# if defined(__has_attribute) && __has_attribute(objc_designated_initializer)
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
# else
# define OBJC_DESIGNATED_INITIALIZER
# endif
#endif
#if !defined(SWIFT_ENUM)
# define SWIFT_ENUM(_type, _name) enum _name : _type _name; enum SWIFT_ENUM_EXTRA _name : _type
#endif
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
#if defined(__has_feature) && __has_feature(modules)
@import ObjectiveC;
@import Foundation;
#endif
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
/// Encapsulates the failure message that matchers can report to the end user.
///
/// This is shared state between Nimble and matchers that mutate this value.
SWIFT_CLASS("_TtC6Nimble14FailureMessage")
@interface FailureMessage : NSObject
@property (nonatomic, copy) NSString * __nonnull expected;
@property (nonatomic, copy) NSString * __nullable actualValue;
@property (nonatomic, copy) NSString * __nonnull to;
@property (nonatomic, copy) NSString * __nonnull postfixMessage;
@property (nonatomic, copy) NSString * __nonnull postfixActual;
@property (nonatomic, copy) NSString * __nullable userDescription;
@property (nonatomic, copy) NSString * __nonnull stringValue;
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
- (nonnull instancetype)initWithStringValue:(NSString * __nonnull)stringValue OBJC_DESIGNATED_INITIALIZER;
@end
/// Protocol for types that support only beEmpty()
SWIFT_PROTOCOL("_TtP6Nimble13NMBCollection_")
@protocol NMBCollection
@property (nonatomic, readonly) NSInteger count;
@end
/// Protocol for types to support beLessThan(), beLessThanOrEqualTo(), beGreaterThan(), beGreaterThanOrEqualTo(), and equal() matchers.
///
/// Types that conform to Swift's Comparable protocol will work implicitly too
SWIFT_PROTOCOL("_TtP6Nimble13NMBComparable_")
@protocol NMBComparable
- (NSComparisonResult)NMB_compare:(id <NMBComparable> __null_unspecified)otherObject;
@end
/// Protocol for types that support contain() matcher.
SWIFT_PROTOCOL("_TtP6Nimble12NMBContainer_")
@protocol NMBContainer
- (BOOL)containsObject:(id __null_unspecified)object;
@end
/// Protocol for types to support beCloseTo() matcher
SWIFT_PROTOCOL("_TtP6Nimble20NMBDoubleConvertible_")
@protocol NMBDoubleConvertible
@property (nonatomic, readonly) double doubleValue;
@end
@protocol NMBMatcher;
SWIFT_CLASS("_TtC6Nimble14NMBExpectation")
@interface NMBExpectation : NSObject
- (nonnull instancetype)initWithActualBlock:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock negative:(BOOL)negative file:(NSString * __nonnull)file line:(NSUInteger)line OBJC_DESIGNATED_INITIALIZER;
@property (nonatomic, readonly, copy) NMBExpectation * __nonnull (^ __nonnull withTimeout)(NSTimeInterval);
@property (nonatomic, readonly, copy) void (^ __nonnull to)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toNot)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toNotWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull notTo)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull notToWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toEventually)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toEventuallyWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toEventuallyNot)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toEventuallyNotWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toNotEventually)(id <NMBMatcher> __nonnull);
@property (nonatomic, readonly, copy) void (^ __nonnull toNotEventuallyWithDescription)(id <NMBMatcher> __nonnull, NSString * __nonnull);
+ (void)failWithMessage:(NSString * __nonnull)message file:(NSString * __nonnull)file line:(NSUInteger)line;
@end
@class SourceLocation;
/// Objective-C interface to the Swift variant of Matcher.
SWIFT_PROTOCOL("_TtP6Nimble10NMBMatcher_")
@protocol NMBMatcher
- (BOOL)matches:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
- (BOOL)doesNotMatch:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
@end
SWIFT_CLASS("_TtC6Nimble23NMBObjCBeCloseToMatcher")
@interface NMBObjCBeCloseToMatcher : NSObject <NMBMatcher>
- (BOOL)matches:(NSObject * __null_unspecified (^ __nonnull)(void))actualExpression failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
- (BOOL)doesNotMatch:(NSObject * __null_unspecified (^ __nonnull)(void))actualExpression failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
@property (nonatomic, readonly, copy) NMBObjCBeCloseToMatcher * __nonnull (^ __nonnull within)(double);
@end
SWIFT_CLASS("_TtC6Nimble14NMBObjCMatcher")
@interface NMBObjCMatcher : NSObject <NMBMatcher>
- (BOOL)matches:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
- (BOOL)doesNotMatch:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beEmptyMatcher;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beIdenticalToMatcher:(NSObject * __nullable)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beginWithMatcher:(id __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beGreaterThanOrEqualToMatcher:(id <NMBComparable> __nullable)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)containMatcher:(NSArray<NSObject *> * __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beGreaterThanMatcher:(id <NMBComparable> __nullable)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beLessThanMatcher:(id <NMBComparable> __nullable)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (id <NMBMatcher> __nonnull)equalMatcher:(NSObject * __nonnull)expected;
@end
@class NSString;
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (id <NMBMatcher> __nonnull)matchMatcher:(NSString * __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (id <NMBMatcher> __nonnull)beAKindOfMatcher:(Class __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)allPassMatcher:(NMBObjCMatcher * __nonnull)matcher;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (id <NMBMatcher> __nonnull)beAnInstanceOfMatcher:(Class __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beLessThanOrEqualToMatcher:(id <NMBComparable> __nullable)expected;
@end
@class NSNumber;
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCBeCloseToMatcher * __nonnull)beCloseToMatcher:(NSNumber * __nonnull)expected within:(double)within;
@end
@class NMBObjCRaiseExceptionMatcher;
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCRaiseExceptionMatcher * __nonnull)raiseExceptionMatcher;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)endWithMatcher:(id __nonnull)expected;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beNilMatcher;
@end
@interface NMBObjCMatcher (SWIFT_EXTENSION(Nimble))
+ (NMBObjCMatcher * __nonnull)beTruthyMatcher;
+ (NMBObjCMatcher * __nonnull)beFalsyMatcher;
+ (NMBObjCMatcher * __nonnull)beTrueMatcher;
+ (NMBObjCMatcher * __nonnull)beFalseMatcher;
@end
@class NSDictionary;
@class NSException;
SWIFT_CLASS("_TtC6Nimble28NMBObjCRaiseExceptionMatcher")
@interface NMBObjCRaiseExceptionMatcher : NSObject <NMBMatcher>
- (BOOL)matches:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
- (BOOL)doesNotMatch:(NSObject * __null_unspecified (^ __nonnull)(void))actualBlock failureMessage:(FailureMessage * __nonnull)failureMessage location:(SourceLocation * __nonnull)location;
@property (nonatomic, readonly, copy) NMBObjCRaiseExceptionMatcher * __nonnull (^ __nonnull named)(NSString * __nonnull);
@property (nonatomic, readonly, copy) NMBObjCRaiseExceptionMatcher * __nonnull (^ __nonnull reason)(NSString * __nullable);
@property (nonatomic, readonly, copy) NMBObjCRaiseExceptionMatcher * __nonnull (^ __nonnull userInfo)(NSDictionary * __nullable);
@property (nonatomic, readonly, copy) NMBObjCRaiseExceptionMatcher * __nonnull (^ __nonnull satisfyingBlock)(void (^ __nullable)(NSException * __nonnull));
@end
/// Protocol for types that support beginWith(), endWith(), beEmpty() matchers
SWIFT_PROTOCOL("_TtP6Nimble20NMBOrderedCollection_")
@protocol NMBOrderedCollection <NMBCollection>
- (NSInteger)indexOfObject:(id __null_unspecified)object;
@end
@interface NSArray (SWIFT_EXTENSION(Nimble)) <NMBContainer>
@end
@interface NSArray (SWIFT_EXTENSION(Nimble)) <NMBOrderedCollection, NMBCollection>
@end
@interface NSArray (SWIFT_EXTENSION(Nimble))
@end
@interface NSDictionary (SWIFT_EXTENSION(Nimble)) <NMBCollection>
@end
@interface NSHashTable (SWIFT_EXTENSION(Nimble)) <NMBContainer>
@end
@interface NSHashTable (SWIFT_EXTENSION(Nimble)) <NMBCollection>
@end
@interface NSNumber (SWIFT_EXTENSION(Nimble)) <NMBDoubleConvertible>
@end
@interface NSNumber (SWIFT_EXTENSION(Nimble)) <NMBComparable>
- (NSComparisonResult)NMB_compare:(id <NMBComparable> __null_unspecified)otherObject;
@end
@interface NSSet (SWIFT_EXTENSION(Nimble)) <NMBCollection>
@end
@interface NSSet (SWIFT_EXTENSION(Nimble)) <NMBContainer>
@end
@interface NSString (SWIFT_EXTENSION(Nimble)) <NMBComparable>
- (NSComparisonResult)NMB_compare:(id <NMBComparable> __null_unspecified)otherObject;
@end
SWIFT_CLASS("_TtC6Nimble14SourceLocation")
@interface SourceLocation : NSObject
@property (nonatomic, readonly, copy) NSString * __nonnull file;
@property (nonatomic, readonly) NSUInteger line;
@property (nonatomic, readonly, copy) NSString * __nonnull description;
@end
#pragma clang diagnostic pop
-6
View File
@@ -1,6 +0,0 @@
#import <Foundation/Foundation.h>
#import <Nimble/NMBExceptionCapture.h>
#import <Nimble/DSL.h>
FOUNDATION_EXPORT double NimbleVersionNumber;
FOUNDATION_EXPORT const unsigned char NimbleVersionString[];
BIN
View File
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
-10
View File
@@ -1,10 +0,0 @@
framework module Nimble {
umbrella header "Nimble.h"
export *
module * { export * }
}
module Nimble.Swift {
header "Nimble-Swift.h"
}
BIN
View File
Binary file not shown.
-183
View File
@@ -1,183 +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>files</key>
<dict>
<key>Headers/DSL.h</key>
<data>
auYzCIxlY2jTkyI1BlljW3KUTJY=
</data>
<key>Headers/NMBExceptionCapture.h</key>
<data>
ncXv+PqMUjLHOJpiFz6BKmTAq5o=
</data>
<key>Headers/Nimble-Swift.h</key>
<data>
ix7zUf4GFfA4sevTnSKvAsAN3xM=
</data>
<key>Headers/Nimble.h</key>
<data>
HXkPd6XbqY7QmdFCpOCNIHhI4v0=
</data>
<key>Info.plist</key>
<data>
m9rBh3svN6G89okFeorwD5OH+2g=
</data>
<key>Modules/Nimble.swiftmodule/arm.swiftdoc</key>
<data>
lSaVfyH8XbRz0WDbmqKJxc5QtbY=
</data>
<key>Modules/Nimble.swiftmodule/arm.swiftmodule</key>
<data>
NseDOVaErTA347+6KjeL5eI3+kI=
</data>
<key>Modules/Nimble.swiftmodule/arm64.swiftdoc</key>
<data>
6W52hA33Ca+9qq8Yiql4aY8+0Rk=
</data>
<key>Modules/Nimble.swiftmodule/arm64.swiftmodule</key>
<data>
Yn3aQiLuskjb8JCg2+JAqYVrN/Y=
</data>
<key>Modules/module.modulemap</key>
<data>
HraXvk1VTxnsGdY8oSlKGNkdg60=
</data>
</dict>
<key>files2</key>
<dict>
<key>Headers/DSL.h</key>
<data>
auYzCIxlY2jTkyI1BlljW3KUTJY=
</data>
<key>Headers/NMBExceptionCapture.h</key>
<data>
ncXv+PqMUjLHOJpiFz6BKmTAq5o=
</data>
<key>Headers/Nimble-Swift.h</key>
<data>
ix7zUf4GFfA4sevTnSKvAsAN3xM=
</data>
<key>Headers/Nimble.h</key>
<data>
HXkPd6XbqY7QmdFCpOCNIHhI4v0=
</data>
<key>Modules/Nimble.swiftmodule/arm.swiftdoc</key>
<data>
lSaVfyH8XbRz0WDbmqKJxc5QtbY=
</data>
<key>Modules/Nimble.swiftmodule/arm.swiftmodule</key>
<data>
NseDOVaErTA347+6KjeL5eI3+kI=
</data>
<key>Modules/Nimble.swiftmodule/arm64.swiftdoc</key>
<data>
6W52hA33Ca+9qq8Yiql4aY8+0Rk=
</data>
<key>Modules/Nimble.swiftmodule/arm64.swiftmodule</key>
<data>
Yn3aQiLuskjb8JCg2+JAqYVrN/Y=
</data>
<key>Modules/module.modulemap</key>
<data>
HraXvk1VTxnsGdY8oSlKGNkdg60=
</data>
</dict>
<key>rules</key>
<dict>
<key>^</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^version.plist$</key>
<true/>
</dict>
<key>rules2</key>
<dict>
<key>.*\.dSYM($|/)</key>
<dict>
<key>weight</key>
<real>11</real>
</dict>
<key>^</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^(.*/)?\.DS_Store$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>2000</real>
</dict>
<key>^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^.*</key>
<true/>
<key>^.*\.lproj/</key>
<dict>
<key>optional</key>
<true/>
<key>weight</key>
<real>1000</real>
</dict>
<key>^.*\.lproj/locversion.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>1100</real>
</dict>
<key>^Info\.plist$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^PkgInfo$</key>
<dict>
<key>omit</key>
<true/>
<key>weight</key>
<real>20</real>
</dict>
<key>^[^/]+$</key>
<dict>
<key>nested</key>
<true/>
<key>weight</key>
<real>10</real>
</dict>
<key>^embedded\.provisionprofile$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
<key>^version\.plist$</key>
<dict>
<key>weight</key>
<real>20</real>
</dict>
</dict>
</dict>
</plist>
+23 -69
View File
@@ -8,17 +8,13 @@
/* Begin PBXBuildFile section */
803F9CD51B92324C002F728F /* OrderedDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 803F9CD21B92324C002F728F /* OrderedDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; };
803F9CD81B9232EE002F728F /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803F9CD71B9232EE002F728F /* OrderedDictionary.swift */; settings = {ASSET_TAGS = (); }; };
803F9CF41B925B1C002F728F /* OrderedDictionary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 803F9CC61B923207002F728F /* OrderedDictionary.framework */; settings = {ASSET_TAGS = (); }; };
803F9CFD1B925B4C002F728F /* OrderedDictionaryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803F9CFC1B925B4C002F728F /* OrderedDictionaryTests.swift */; settings = {ASSET_TAGS = (); }; };
803F9D001B925BBF002F728F /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 803F9CE91B925AE5002F728F /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
803F9D011B925BE9002F728F /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 803F9CE91B925AE5002F728F /* Nimble.framework */; };
803F9CD81B9232EE002F728F /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803F9CD71B9232EE002F728F /* OrderedDictionary.swift */; };
803F9CF41B925B1C002F728F /* OrderedDictionary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 803F9CC61B923207002F728F /* OrderedDictionary.framework */; };
803F9CFD1B925B4C002F728F /* OrderedDictionaryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803F9CFC1B925B4C002F728F /* OrderedDictionaryTests.swift */; };
8060976B1B92F2D200DB20CF /* OrderedDictionary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803F9CD71B9232EE002F728F /* OrderedDictionary.swift */; };
8060976C1B92F2D900DB20CF /* OrderedDictionary.h in Headers */ = {isa = PBXBuildFile; fileRef = 803F9CD21B92324C002F728F /* OrderedDictionary.h */; settings = {ATTRIBUTES = (Public, ); }; };
806097761B92F44F00DB20CF /* OrderedDictionary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 806097631B92F20400DB20CF /* OrderedDictionary.framework */; settings = {ASSET_TAGS = (); }; };
806097761B92F44F00DB20CF /* OrderedDictionary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 806097631B92F20400DB20CF /* OrderedDictionary.framework */; };
8060977C1B92F4A000DB20CF /* OrderedDictionaryTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 803F9CFC1B925B4C002F728F /* OrderedDictionaryTests.swift */; };
806097801B92F4F000DB20CF /* Nimble.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8060977F1B92F4F000DB20CF /* Nimble.framework */; settings = {ASSET_TAGS = (); }; };
806097821B92F4FC00DB20CF /* Nimble.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8060977F1B92F4F000DB20CF /* Nimble.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -45,7 +41,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
803F9D001B925BBF002F728F /* Nimble.framework in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -55,7 +50,6 @@
dstPath = "";
dstSubfolderSpec = 10;
files = (
806097821B92F4FC00DB20CF /* Nimble.framework in CopyFiles */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -66,13 +60,11 @@
803F9CD21B92324C002F728F /* OrderedDictionary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OrderedDictionary.h; sourceTree = "<group>"; };
803F9CD41B92324C002F728F /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
803F9CD71B9232EE002F728F /* OrderedDictionary.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderedDictionary.swift; sourceTree = "<group>"; };
803F9CE91B925AE5002F728F /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/Mac/Nimble.framework; sourceTree = "<group>"; };
803F9CEF1B925B1C002F728F /* OrderedDictionary-OSX-Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "OrderedDictionary-OSX-Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
803F9CFC1B925B4C002F728F /* OrderedDictionaryTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OrderedDictionaryTests.swift; sourceTree = "<group>"; };
803F9CFE1B925B56002F728F /* Info-Tests.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = "Info-Tests.plist"; path = "Supporting Files/Info-Tests.plist"; sourceTree = SOURCE_ROOT; };
803F9CFE1B925B56002F728F /* Info-Tests.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Info-Tests.plist"; sourceTree = "<group>"; };
806097631B92F20400DB20CF /* OrderedDictionary.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = OrderedDictionary.framework; sourceTree = BUILT_PRODUCTS_DIR; };
806097711B92F44F00DB20CF /* OrderedDictionary-iOS-Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "OrderedDictionary-iOS-Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
8060977F1B92F4F000DB20CF /* Nimble.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Nimble.framework; path = Carthage/Build/iOS/Nimble.framework; sourceTree = "<group>"; };
80F94F181B926A60000A96E7 /* OrderedDictionary.playground */ = {isa = PBXFileReference; lastKnownFileType = file.playground; path = OrderedDictionary.playground; sourceTree = "<group>"; };
/* End PBXFileReference section */
@@ -89,7 +81,6 @@
buildActionMask = 2147483647;
files = (
803F9CF41B925B1C002F728F /* OrderedDictionary.framework in Frameworks */,
803F9D011B925BE9002F728F /* Nimble.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -105,7 +96,6 @@
buildActionMask = 2147483647;
files = (
806097761B92F44F00DB20CF /* OrderedDictionary.framework in Frameworks */,
806097801B92F4F000DB20CF /* Nimble.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -116,10 +106,9 @@
isa = PBXGroup;
children = (
803F9CD11B92324C002F728F /* Sources */,
80F94F171B926A60000A96E7 /* Playgrounds */,
803F9CFB1B925B4C002F728F /* Tests */,
80F94F171B926A60000A96E7 /* Playgrounds */,
803F9CD31B92324C002F728F /* Supporting Files */,
803F9CE81B9259F3002F728F /* Frameworks */,
803F9CC71B923207002F728F /* Products */,
);
sourceTree = "<group>";
@@ -147,21 +136,12 @@
803F9CD31B92324C002F728F /* Supporting Files */ = {
isa = PBXGroup;
children = (
803F9CD41B92324C002F728F /* Info.plist */,
803F9CFE1B925B56002F728F /* Info-Tests.plist */,
803F9CD41B92324C002F728F /* Info.plist */,
);
path = "Supporting Files";
sourceTree = "<group>";
};
803F9CE81B9259F3002F728F /* Frameworks */ = {
isa = PBXGroup;
children = (
8060977D1B92F4D900DB20CF /* OSX */,
8060977E1B92F4DF00DB20CF /* iOS */,
);
name = Frameworks;
sourceTree = "<group>";
};
803F9CFB1B925B4C002F728F /* Tests */ = {
isa = PBXGroup;
children = (
@@ -170,22 +150,6 @@
path = Tests;
sourceTree = "<group>";
};
8060977D1B92F4D900DB20CF /* OSX */ = {
isa = PBXGroup;
children = (
803F9CE91B925AE5002F728F /* Nimble.framework */,
);
name = OSX;
sourceTree = "<group>";
};
8060977E1B92F4DF00DB20CF /* iOS */ = {
isa = PBXGroup;
children = (
8060977F1B92F4F000DB20CF /* Nimble.framework */,
);
name = iOS;
sourceTree = "<group>";
};
80F94F171B926A60000A96E7 /* Playgrounds */ = {
isa = PBXGroup;
children = (
@@ -450,6 +414,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
@@ -490,6 +455,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
MACOSX_DEPLOYMENT_TARGET = 10.10;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = macosx;
@@ -507,14 +473,12 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = "Supporting Files/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = com.lukaskubanek.OrderedDictionary;
PRODUCT_NAME = OrderedDictionary;
SKIP_INSTALL = YES;
@@ -531,14 +495,12 @@
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = "Supporting Files/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
PRODUCT_BUNDLE_IDENTIFIER = com.lukaskubanek.OrderedDictionary;
PRODUCT_NAME = OrderedDictionary;
SKIP_INSTALL = YES;
@@ -549,10 +511,7 @@
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "Supporting Files/Info-Tests.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.lukaskubanek.OrderedDictionaryTests;
@@ -564,10 +523,7 @@
isa = XCBuildConfiguration;
buildSettings = {
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "Supporting Files/Info-Tests.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.lukaskubanek.OrderedDictionaryTests;
@@ -578,13 +534,14 @@
806097691B92F20400DB20CF /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_IDENTITY = "iPhone Developer";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "Supporting Files/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.lukaskubanek.OrderedDictionary;
PRODUCT_NAME = OrderedDictionary;
@@ -597,13 +554,14 @@
8060976A1B92F20400DB20CF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_IDENTITY = "iPhone Developer";
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = "Supporting Files/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.lukaskubanek.OrderedDictionary;
PRODUCT_NAME = OrderedDictionary;
@@ -617,10 +575,7 @@
8060977A1B92F44F00DB20CF /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "Supporting Files/Info-Tests.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@@ -633,10 +588,7 @@
8060977B1B92F44F00DB20CF /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/iOS",
);
FRAMEWORK_SEARCH_PATHS = "$(inherited)";
INFOPLIST_FILE = "Supporting Files/Info-Tests.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
@@ -684,6 +636,7 @@
8060976A1B92F20400DB20CF /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
806097791B92F44F00DB20CF /* Build configuration list for PBXNativeTarget "OrderedDictionary-iOS-Tests" */ = {
isa = XCConfigurationList;
@@ -692,6 +645,7 @@
8060977B1B92F44F00DB20CF /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -11,7 +11,8 @@
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
buildForAnalyzing = "YES"
hideIssues = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "803F9CC51B923207002F728F"
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
LastUpgradeVersion = "0730"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -11,7 +11,8 @@
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
buildForAnalyzing = "YES"
hideIssues = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "806097621B92F20400DB20CF"
@@ -63,3 +63,25 @@ print(orderedDictionary.indexForKey("F")) // => Optional(1)
print(orderedDictionary.indexForKey("E")) // => Optional(2)
print(orderedDictionary.indexForKey("A")) // => nil
print(orderedDictionary.indexForKey("C")) // => nil
////
// Sorting
////
var sortingOrderedDictionary: OrderedDictionary<String, Int> = [
("E", 4),
("G", 3),
("A", 3),
("D", 1),
("B", 4)
]
sortingOrderedDictionary.sortInPlace { (item1, item2) in
if item1.1 == item2.1 {
return item1.0 < item2.0
} else {
return item1.1 < item2.1
}
}
print(sortingOrderedDictionary) // => [D: 1, A: 3, G: 3, B: 4, E: 4]
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='5.0' target-platform='osx' requires-full-environment='true'>
<playground version='5.0' target-platform='osx'>
<timeline fileName='timeline.xctimeline'/>
</playground>
+67 -49
View File
@@ -1,40 +1,56 @@
# OrderedDictionary
[![][image-1]][1] [![][image-2]][2] [![][image-3]][3] ![][image-4] [![][image-5]][4] [![][image-6]][5]
[![][travis-image]][travis-link] [![][release-image]][release-link] [![][swift-image]][swift-link] ![][platform-image] [![][carthage-image]][carthage-link] [![][license-image]][license-link]
This is a lightweight implementation of an ordered dictionary data structure in Swift packed into a µframework.
[travis-image]: https://img.shields.io/travis/lukaskubanek/OrderedDictionary.svg?style=flat-square "Build"
[travis-link]: https://travis-ci.org/lukaskubanek/OrderedDictionary
`OrderedDictionary` is an immutable generic collection which combines the features of `Dictionary` and `Array`. Like `Dictionary` it stores key-value pairs and maps the keys to values. Additionally these pairs are sorted by zero-based integer index like in `Array`. The `OrderedDictionary` provides similar APIs to the collections from the Swift standard library and allows accessing the content by keys or indexes.
[release-image]: https://img.shields.io/github/release/lukaskubanek/OrderedDictionary.svg?style=flat-square
[release-link]: https://github.com/lukaskubanek/OrderedDictionary/releases
[swift-image]: https://img.shields.io/badge/Swift-2.2-orange.svg?style=flat-square "Swift 2.2"
[swift-link]: https://developer.apple.com/swift/
[platform-image]: https://img.shields.io/badge/platform-osx/ios-yellowgreen.svg?style=flat-square "Platform: OS X, iOS"
[carthage-image]: https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat-square "Carthage compatible"
[carthage-link]: https://github.com/Carthage/Carthage
[license-image]: https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat-square "License: MIT"
[license-link]: LICENSE.md
**OrderedDictionary** is a lightweight implementation of an ordered dictionary data structure in Swift packed into a µframework.
The `OrderedDictionary` structure is an immutable generic collection which combines the features of `Dictionary` and `Array` from the Swift standard library. Like `Dictionary` it stores key-value pairs and maps each key to a value. Like `Array` it stores those pairs sorted and accessible by a zero-based integer index. `OrderedDictionary` provides similar APIs to collections from the standard library. This includes accessing contents by keys or indexes, inserting and removing contents, sorting etc.
Internally `OrderedDictionary` uses a backing store composed of an instance of `Dictionary` for storing the key-value pairs and an instance of `Array` for managing the ordered keys.
## Requirements
- Swift 2.0
- Xcode 7.0 GM
- Swift 2.2+
- Xcode 7.3
- iOS 8.0+ / OS X 10.10+
## Installation
The easiest way to integrate `OrderedDictionary` to your project is to use [Carthage][6]. Add following line to your `Cartfile`:
### Carthage
```
github "lukaskubanek/OrderedDictionary" ~> 0.3
```
The easiest way to integrate this framework in your project is to use [Carthage][carthage-link]).
Then drag the `OrderedDictionary.xcodeproj` or the `OrderedDictionary.framework` into your project/workspace and link against the `OrderedDictionary.framework`.
1. Add `github "lukaskubanek/OrderedDictionary" ~> 0.6` to your `Cartfile`.
2. Run `carthage bootstrap`.
3. Drag either the `OrderedDictionary.xcodeproj` or the `OrderedDictionary.framework` into your project/workspace and link your target against the `OrderedDictionary.framework`.
4. Make sure the framework [gets copied](https://github.com/Carthage/Carthage#adding-frameworks-to-an-application) to your application bundle.
Finally make sure the framework gets copied into your application bundle.
### Submodules
Another option for integrating this framework is to use [Git submodules](http://git-scm.com/book/en/v2/Git-Tools-Submodules).
## Example Usage
Initialization:
```swift
import OrderedDictionary
////
// Initialize an ordered dictionary using an array of key-value pairs
////
var orderedDictionary: OrderedDictionary<String, Int> = [
("A", 1),
("B", 2),
@@ -43,11 +59,11 @@ var orderedDictionary: OrderedDictionary<String, Int> = [
]
print(orderedDictionary) // => [A: 1, B: 2, C: 3, D: 4]
```
////
// Loop through the contents
////
Looping through the contents:
```swift
for (index, (key, value)) in orderedDictionary.enumerate() {
print("\(index): (\(key): \(value))")
}
@@ -56,11 +72,11 @@ for (index, (key, value)) in orderedDictionary.enumerate() {
// => 1: (B: 2)
// => 2: (C: 3)
// => 3: (D: 4)
```
////
// Modify the values by setting the value for key
////
Modifying the values by setting the value for key:
```swift
orderedDictionary["A"] = 100
orderedDictionary["E"] = 5
orderedDictionary["B"] = nil
@@ -73,11 +89,11 @@ print(orderedDictionary["B"]) // => nil
print(orderedDictionary["C"]) // => Optional(3)
print(orderedDictionary["D"]) // => Optional(42)
print(orderedDictionary["E"]) // => Optional(5)
```
////
// Modify the values by setting the element for index
////
Modifying the values by setting the element for index:
```swift
orderedDictionary[2] = ("F", 235)
orderedDictionary.updateElement(("K", 12), atIndex: 1)
orderedDictionary.removeAtIndex(0)
@@ -96,31 +112,33 @@ print(orderedDictionary.indexForKey("A")) // => nil
print(orderedDictionary.indexForKey("C")) // => nil
```
Sorting:
```swift
var sortingOrderedDictionary: OrderedDictionary<String, Int> = [
("E", 4),
("G", 3),
("A", 3),
("D", 1),
("B", 4)
]
sortingOrderedDictionary.sortInPlace { (item1, item2) in
if item1.1 == item2.1 {
return item1.0 < item2.0
} else {
return item1.1 < item2.1
}
}
print(sortingOrderedDictionary) // => [D: 1, A: 3, G: 3, B: 4, E: 4]
```
## Author
Lukas Kubanek // [lukaskubanek.com][11] // [@kubanekl][12]
Lukas Kubanek // [lukaskubanek.com](http://lukaskubanek.com) // [@kubanekl](https://twitter.com/kubanekl)
## License
`OrderedDictionary` is released under the [MIT License][13].
[1]: https://travis-ci.org/lukaskubanek/OrderedDictionary
[2]: https://github.com/lukaskubanek/OrderedDictionary/releases
[3]: https://developer.apple.com/swift/
[4]: https://github.com/Carthage/Carthage
[5]: LICENSE.md
[6]: https://github.com/Carthage/Carthage/
[7]: https://developer.apple.com/swift/
[8]: https://github.com/lukaskubanek/OrderedDictionary/releases
[9]: https://developer.apple.com/swift/
[10]: https://github.com/Carthage/Carthage
[11]: http://lukaskubanek.com
[12]: https://twitter.com/kubanekl
[13]: LICENSE.md
[image-1]: https://img.shields.io/travis/lukaskubanek/OrderedDictionary.svg?style=flat-square
[image-2]: https://img.shields.io/github/release/lukaskubanek/OrderedDictionary.svg?style=flat-square
[image-3]: https://img.shields.io/badge/Swift-2.0-orange.svg?style=flat-square
[image-4]: https://img.shields.io/badge/platform-OS_X%20&_iOS-yellowgreen.svg?style=flat-square
[image-5]: https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat-square "Carthage compatible"
[image-6]: https://img.shields.io/badge/license-MIT-lightgrey.svg?style=flat-square "License"
**OrderedDictionary** is released under the [MIT License](LICENSE.md).
+100 -67
View File
@@ -6,18 +6,23 @@
// Copyright © 2015 Lukas Kubanek. All rights reserved.
//
public struct OrderedDictionary<Key: Hashable, Value>: CollectionType, ArrayLiteralConvertible, CustomStringConvertible {
public struct OrderedDictionary<Key: Hashable, Value>: MutableCollectionType, ArrayLiteralConvertible, CustomStringConvertible {
// ======================================================= //
// MARK: - Type Aliases
// ======================================================= //
public typealias Element = (Key, Value)
public typealias Index = Int
// ======================================================= //
// MARK: - Initialization
// ======================================================= //
public init() {
self.orderedKeys = []
self.keysToValues = [:]
}
public init() {}
public init(elements: [Element]) {
self.init()
for element in elements {
self[element.0] = element.1
}
@@ -27,16 +32,25 @@ public struct OrderedDictionary<Key: Hashable, Value>: CollectionType, ArrayLite
self.init(elements: elements)
}
// MARK: - Type Aliases
// ======================================================= //
// MARK: - Accessing Keys & Values
// ======================================================= //
public typealias Element = (Key, Value)
public typealias Index = Int
public var orderedKeys: [Key] {
return _orderedKeys
}
public var orderedValues: [Value] {
return _orderedKeys.flatMap { _keysToValues[$0] }
}
// ======================================================= //
// MARK: - Managing Content Using Keys
// ======================================================= //
public subscript(key: Key) -> Value? {
get {
return keysToValues[key]
return _keysToValues[key]
}
set(newValue) {
if let newValue = newValue {
@@ -48,34 +62,34 @@ public struct OrderedDictionary<Key: Hashable, Value>: CollectionType, ArrayLite
}
public func containsKey(key: Key) -> Bool {
return orderedKeys.contains(key)
return _orderedKeys.contains(key)
}
public mutating func updateValue(value: Value, forKey key: Key) -> Value? {
if orderedKeys.contains(key) {
guard let currentValue = keysToValues[key] else {
if _orderedKeys.contains(key) {
guard let currentValue = _keysToValues[key] else {
fatalError("Inconsistency error occured in OrderedDictionary")
}
keysToValues[key] = value
_keysToValues[key] = value
return currentValue
} else {
orderedKeys.append(key)
keysToValues[key] = value
_orderedKeys.append(key)
_keysToValues[key] = value
return nil
}
}
public mutating func removeValueForKey(key: Key) -> Value? {
if let index = orderedKeys.indexOf(key) {
guard let currentValue = keysToValues[key] else {
if let index = _orderedKeys.indexOf(key) {
guard let currentValue = _keysToValues[key] else {
fatalError("Inconsistency error occured in OrderedDictionary")
}
orderedKeys.removeAtIndex(index)
keysToValues[key] = nil
_orderedKeys.removeAtIndex(index)
_keysToValues[key] = nil
return currentValue
} else {
@@ -84,11 +98,13 @@ public struct OrderedDictionary<Key: Hashable, Value>: CollectionType, ArrayLite
}
public mutating func removeAll(keepCapacity keepCapacity: Bool = true) {
orderedKeys.removeAll(keepCapacity: keepCapacity)
keysToValues.removeAll(keepCapacity: keepCapacity)
_orderedKeys.removeAll(keepCapacity: keepCapacity)
_keysToValues.removeAll(keepCapacity: keepCapacity)
}
// ======================================================= //
// MARK: - Managing Content Using Indexes
// ======================================================= //
public subscript(index: Index) -> Element {
get {
@@ -104,21 +120,25 @@ public struct OrderedDictionary<Key: Hashable, Value>: CollectionType, ArrayLite
}
public func indexForKey(key: Key) -> Index? {
return orderedKeys.indexOf(key)
return _orderedKeys.indexOf(key)
}
public func elementAtIndex(index: Index) -> Element? {
guard orderedKeys.indices.contains(index) else { return nil }
guard _orderedKeys.indices.contains(index) else { return nil }
let key = orderedKeys[index]
let key = _orderedKeys[index]
guard let value = self.keysToValues[key] else {
guard let value = self._keysToValues[key] else {
fatalError("Inconsistency error occured in OrderedDictionary")
}
return (key, value)
}
public mutating func insertElementWithKey(key: Key, value: Value, atIndex index: Index) -> Value? {
return insertElement((key, value), atIndex: index)
}
public mutating func insertElement(newElement: Element, atIndex index: Index) -> Value? {
guard index >= 0 else {
fatalError("Negative OrderedDictionary index is out of range")
@@ -133,19 +153,19 @@ public struct OrderedDictionary<Key: Hashable, Value>: CollectionType, ArrayLite
let adjustedIndex: Int
let currentValue: Value?
if let currentIndex = orderedKeys.indexOf(key) {
currentValue = keysToValues[key]
if let currentIndex = _orderedKeys.indexOf(key) {
currentValue = _keysToValues[key]
adjustedIndex = (currentIndex < index - 1) ? index - 1 : index
orderedKeys.removeAtIndex(currentIndex)
keysToValues[key] = nil
_orderedKeys.removeAtIndex(currentIndex)
_keysToValues[key] = nil
} else {
currentValue = nil
adjustedIndex = index
}
orderedKeys.insert(key, atIndex: adjustedIndex)
keysToValues[key] = value
_orderedKeys.insert(key, atIndex: adjustedIndex)
_keysToValues[key] = value
return currentValue
}
@@ -157,16 +177,16 @@ public struct OrderedDictionary<Key: Hashable, Value>: CollectionType, ArrayLite
let (newKey, newValue) = (element.0, element.1)
orderedKeys[index] = newKey
keysToValues[newKey] = newValue
_orderedKeys[index] = newKey
_keysToValues[newKey] = newValue
return currentElement
}
public mutating func removeAtIndex(index: Index) -> Element? {
if let element = elementAtIndex(index) {
orderedKeys.removeAtIndex(index)
keysToValues.removeValueForKey(element.0)
_orderedKeys.removeAtIndex(index)
_keysToValues.removeValueForKey(element.0)
return element
} else {
@@ -174,47 +194,60 @@ public struct OrderedDictionary<Key: Hashable, Value>: CollectionType, ArrayLite
}
}
// ======================================================= //
// MARK: - CollectionType Conformance
// ======================================================= //
public var startIndex: Index {
return _orderedKeys.startIndex
}
public var endIndex: Index {
return _orderedKeys.endIndex
}
public func generate() -> AnyGenerator<Element> {
var nextIndex = 0
let lastIndex = self.count
return AnyGenerator {
guard nextIndex < lastIndex else { return nil }
let nextKey = self._orderedKeys[nextIndex]
guard let nextValue = self._keysToValues[nextKey] else {
fatalError("Inconsistency error occured in OrderedDictionary")
}
let element = (nextKey, nextValue)
nextIndex += 1
return element
}
}
// ======================================================= //
// MARK: - Description
// ======================================================= //
public var description: String {
let content = map({ "\($0.0): \($0.1)" }).joinWithSeparator(", ")
return "[\(content)]"
}
// MARK: - Backing Store
// ======================================================= //
// MARK: - Internal Backing Store
// ======================================================= //
private var orderedKeys: [Key]
private var keysToValues: [Key: Value]
/// The backing store for the ordered keys.
private var _orderedKeys = [Key]()
// MARK: - SequenceType & Indexable Conformance
public func generate() -> AnyGenerator<Element> {
var nextIndex = 0
let lastIndex = self.count
return anyGenerator {
guard nextIndex < lastIndex else { return nil }
let nextKey = self.orderedKeys[nextIndex]
guard let nextValue = self.keysToValues[nextKey] else {
fatalError("Inconsistency error occured in OrderedDictionary")
}
let element = (nextKey, nextValue)
nextIndex++
return element
}
}
public var startIndex: Index { return orderedKeys.startIndex }
public var endIndex: Index { return orderedKeys.endIndex }
/// The backing store for the mapping of keys to values.
private var _keysToValues = [Key: Value]()
}
public func == <Key: Equatable, Value: Equatable>(lhs: OrderedDictionary<Key, Value>, rhs: OrderedDictionary<Key, Value>) -> Bool {
return lhs.orderedKeys == rhs.orderedKeys && lhs.keysToValues == rhs.keysToValues
return lhs._orderedKeys == rhs._orderedKeys && lhs._keysToValues == rhs._keysToValues
}
+1 -1
View File
@@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.1</string>
<string>0.5</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
+150 -104
View File
@@ -7,7 +7,6 @@
//
import XCTest
import Nimble
import OrderedDictionary
class OrderedDictionaryTests: XCTestCase {
@@ -22,22 +21,24 @@ class OrderedDictionaryTests: XCTestCase {
]
}
// ======================================================= //
// MARK: - Content
// ======================================================= //
func testInitializedContent() {
expect(self.orderedDictionary.count) == 3
XCTAssertEqual(orderedDictionary.count, 3)
expect(self.orderedDictionary["A"]) == 1
expect(self.orderedDictionary.indexForKey("A")) == 0
expect(self.orderedDictionary.containsKey("A")) == true
XCTAssertEqual(orderedDictionary["A"], 1)
XCTAssertEqual(orderedDictionary.indexForKey("A"), 0)
XCTAssertTrue(orderedDictionary.containsKey("A"))
expect(self.orderedDictionary["B"]) == 2
expect(self.orderedDictionary.indexForKey("B")) == 1
expect(self.orderedDictionary.containsKey("B")) == true
XCTAssertEqual(orderedDictionary["B"], 2)
XCTAssertEqual(orderedDictionary.indexForKey("B"), 1)
XCTAssertTrue(orderedDictionary.containsKey("B"))
expect(self.orderedDictionary["C"]) == 3
expect(self.orderedDictionary.indexForKey("C")) == 2
expect(self.orderedDictionary.containsKey("C")) == true
XCTAssertEqual(orderedDictionary["C"], 3)
XCTAssertEqual(orderedDictionary.indexForKey("C"), 2)
XCTAssertTrue(orderedDictionary.containsKey("C"))
}
func testInitializationUsingPairs() {
@@ -47,86 +48,95 @@ class OrderedDictionaryTests: XCTestCase {
("C", 3)
]
expect(OrderedDictionary(elements: elements) == self.orderedDictionary).to(beTrue())
XCTAssertTrue(OrderedDictionary(elements: elements) == orderedDictionary)
}
func testElementsGenerator() {
for entry in self.orderedDictionary.enumerate() {
expect(self.orderedDictionary[entry.index].0) == entry.element.0
expect(self.orderedDictionary[entry.index].1) == entry.element.1
for entry in orderedDictionary.enumerate() {
XCTAssertEqual(orderedDictionary[entry.index].0, entry.element.0)
XCTAssertEqual(orderedDictionary[entry.index].1, entry.element.1)
}
}
// MARK: - Key-based Modifications
func testKeyBasedSubscript() {
self.orderedDictionary["A"] = 5
self.orderedDictionary["D"] = 10
self.orderedDictionary["B"] = nil
expect(self.orderedDictionary.count) == 3
expect(self.orderedDictionary["A"]) == 5
expect(self.orderedDictionary.indexForKey("A")) == 0
expect(self.orderedDictionary.containsKey("A")) == true
expect(self.orderedDictionary["B"]).to(beNil())
expect(self.orderedDictionary.indexForKey("B")).to(beNil())
expect(self.orderedDictionary.containsKey("B")) == false
expect(self.orderedDictionary["C"]) == 3
expect(self.orderedDictionary.indexForKey("C")) == 1
expect(self.orderedDictionary.containsKey("C")) == true
expect(self.orderedDictionary["D"]) == 10
expect(self.orderedDictionary.indexForKey("D")) == 2
expect(self.orderedDictionary.containsKey("D")) == true
func testOrderedKeysAndValues() {
XCTAssertEqual(orderedDictionary.orderedKeys, ["A", "B", "C"])
XCTAssertEqual(orderedDictionary.orderedValues, [1, 2, 3])
}
// ======================================================= //
// MARK: - Key-based Modifications
// ======================================================= //
func testKeyBasedSubscript() {
orderedDictionary["A"] = 5
orderedDictionary["D"] = 10
orderedDictionary["B"] = nil
XCTAssertEqual(orderedDictionary.count, 3)
XCTAssertEqual(orderedDictionary["A"], 5)
XCTAssertEqual(orderedDictionary.indexForKey("A"), 0)
XCTAssertTrue(orderedDictionary.containsKey("A"))
XCTAssertNil(orderedDictionary["B"])
XCTAssertNil(orderedDictionary.indexForKey("B"))
XCTAssertFalse(orderedDictionary.containsKey("B"))
XCTAssertEqual(orderedDictionary["C"], 3)
XCTAssertEqual(orderedDictionary.indexForKey("C"), 1)
XCTAssertTrue(orderedDictionary.containsKey("C"))
XCTAssertEqual(orderedDictionary["D"], 10)
XCTAssertEqual(orderedDictionary.indexForKey("D"), 2)
XCTAssertTrue(orderedDictionary.containsKey("D"))
}
// ======================================================= //
// MARK: - Index-based Modifications
// ======================================================= //
func testIndexBasedSubscriptForRetrievingValues() {
let elementAtIndex0 = self.orderedDictionary[0]
expect(elementAtIndex0.0) == "A"
expect(elementAtIndex0.1) == 1
let elementAtIndex0 = orderedDictionary[0]
XCTAssertEqual(elementAtIndex0.0, "A")
XCTAssertEqual(elementAtIndex0.1, 1)
let elementAtIndex1 = self.orderedDictionary[1]
expect(elementAtIndex1.0) == "B"
expect(elementAtIndex1.1) == 2
let elementAtIndex1 = orderedDictionary[1]
XCTAssertEqual(elementAtIndex1.0, "B")
XCTAssertEqual(elementAtIndex1.1, 2)
let elementAtIndex2 = self.orderedDictionary[2]
expect(elementAtIndex2.0) == "C"
expect(elementAtIndex2.1) == 3
let elementAtIndex2 = orderedDictionary[2]
XCTAssertEqual(elementAtIndex2.0, "C")
XCTAssertEqual(elementAtIndex2.1, 3)
}
func testIndexBasedSubscriptForSettingValues() {
self.orderedDictionary[0] = ("F", 10)
self.orderedDictionary[1] = ("B", 5)
orderedDictionary[0] = ("F", 10)
orderedDictionary[1] = ("B", 5)
let elementAtIndex0 = self.orderedDictionary[0]
expect(elementAtIndex0.0) == "F"
expect(elementAtIndex0.1) == 10
let elementAtIndex0 = orderedDictionary[0]
XCTAssertEqual(elementAtIndex0.0, "F")
XCTAssertEqual(elementAtIndex0.1, 10)
let elementAtIndex1 = self.orderedDictionary[1]
expect(elementAtIndex1.0) == "B"
expect(elementAtIndex1.1) == 5
let elementAtIndex1 = orderedDictionary[1]
XCTAssertEqual(elementAtIndex1.0, "B")
XCTAssertEqual(elementAtIndex1.1, 5)
let elementAtIndex2 = self.orderedDictionary[2]
expect(elementAtIndex2.0) == "C"
expect(elementAtIndex2.1) == 3
let elementAtIndex2 = orderedDictionary[2]
XCTAssertEqual(elementAtIndex2.0, "C")
XCTAssertEqual(elementAtIndex2.1, 3)
}
func testRetrievingElementAtNonExistentIndex() {
expect(self.orderedDictionary.elementAtIndex(10)).to(beNil())
XCTAssertNil(orderedDictionary.elementAtIndex(10))
}
func testIndexBasedInsertionsOfElementsWithDistinctKeys() {
self.orderedDictionary.insertElement(("T", 15), atIndex: 0)
self.orderedDictionary.insertElement(("U", 16), atIndex: 2)
self.orderedDictionary.insertElement(("V", 17), atIndex: 5)
self.orderedDictionary.insertElement(("W", 18), atIndex: 2)
orderedDictionary.insertElement(("T", 15), atIndex: 0)
orderedDictionary.insertElement(("U", 16), atIndex: 2)
orderedDictionary.insertElement(("V", 17), atIndex: 5)
orderedDictionary.insertElement(("W", 18), atIndex: 2)
let expectedOrderedDictionary: OrderedDictionary<String, Int> = [
let XCTAssertEqualedOrderedDictionary: OrderedDictionary<String, Int> = [
("T", 15),
("A", 1),
("W", 18),
@@ -136,11 +146,11 @@ class OrderedDictionaryTests: XCTestCase {
("V", 17)
]
expect(self.orderedDictionary == expectedOrderedDictionary).to(beTrue())
XCTAssertTrue(orderedDictionary == XCTAssertEqualedOrderedDictionary)
}
func testIndexBasedInsertionOfElementWithSameKeyBeforeItsCurrentIndex() {
let previousValue = self.orderedDictionary.insertElement(("B", 5), atIndex: 0)
let previousValue = orderedDictionary.insertElement(("B", 5), atIndex: 0)
let expectedOrderedDictionary: OrderedDictionary<String, Int> = [
("B", 5),
@@ -148,13 +158,13 @@ class OrderedDictionaryTests: XCTestCase {
("C", 3)
]
expect(self.orderedDictionary.count) == 3
expect(self.orderedDictionary == expectedOrderedDictionary).to(beTrue())
expect(previousValue) == 2
XCTAssertEqual(orderedDictionary.count, 3)
XCTAssertTrue(orderedDictionary == expectedOrderedDictionary)
XCTAssertEqual(previousValue, 2)
}
func testIndexBasedInsertionOfElementWithSameKeyAtItsCurrentIndex() {
let previousValue = self.orderedDictionary.insertElement(("B", 5), atIndex: 1)
let previousValue = orderedDictionary.insertElement(("B", 5), atIndex: 1)
let expectedOrderedDictionary: OrderedDictionary<String, Int> = [
("A", 1),
@@ -162,13 +172,13 @@ class OrderedDictionaryTests: XCTestCase {
("C", 3)
]
expect(self.orderedDictionary.count) == 3
expect(self.orderedDictionary == expectedOrderedDictionary).to(beTrue())
expect(previousValue) == 2
XCTAssertEqual(orderedDictionary.count, 3)
XCTAssertTrue(orderedDictionary == expectedOrderedDictionary)
XCTAssertEqual(previousValue, 2)
}
func testIndexBasedInsertionOfElementWithSameKeyAfterItsCurrentIndex() {
let previousValue = self.orderedDictionary.insertElement(("B", 5), atIndex: 3)
let previousValue = orderedDictionary.insertElement(("B", 5), atIndex: 3)
let expectedOrderedDictionary: OrderedDictionary<String, Int> = [
("A", 1),
@@ -176,63 +186,99 @@ class OrderedDictionaryTests: XCTestCase {
("B", 5)
]
expect(self.orderedDictionary.count) == 3
expect(self.orderedDictionary == expectedOrderedDictionary).to(beTrue())
expect(previousValue) == 2
XCTAssertEqual(orderedDictionary.count, 3)
XCTAssertTrue(orderedDictionary == expectedOrderedDictionary)
XCTAssertEqual(previousValue, 2)
}
// ======================================================= //
// MARK: - Removal
// ======================================================= //
func testRemoveAll() {
self.orderedDictionary.removeAll()
orderedDictionary.removeAll()
expect(self.orderedDictionary.count) == 0
XCTAssertEqual(orderedDictionary.count, 0)
}
func testRemovalForKey() {
let removedValue1 = self.orderedDictionary.removeValueForKey("A")
let removedValue2 = self.orderedDictionary.removeValueForKey("K")
let removedValue1 = orderedDictionary.removeValueForKey("A")
let removedValue2 = orderedDictionary.removeValueForKey("K")
expect(removedValue1) == 1
expect(removedValue2).to(beNil())
XCTAssertEqual(removedValue1, 1)
XCTAssertNil(removedValue2)
expect(self.orderedDictionary.count) == 2
XCTAssertEqual(orderedDictionary.count, 2)
expect(self.orderedDictionary["A"]).to(beNil())
expect(self.orderedDictionary.indexForKey("A")).to(beNil())
XCTAssertNil(orderedDictionary["A"])
XCTAssertNil(orderedDictionary.indexForKey("A"))
expect(self.orderedDictionary["B"]) == 2
expect(self.orderedDictionary.indexForKey("B")) == 0
XCTAssertEqual(orderedDictionary["B"], 2)
XCTAssertEqual(orderedDictionary.indexForKey("B"), 0)
expect(self.orderedDictionary["C"]) == 3
expect(self.orderedDictionary.indexForKey("C")) == 1
XCTAssertEqual(orderedDictionary["C"], 3)
XCTAssertEqual(orderedDictionary.indexForKey("C"), 1)
}
func testRemovalAtIndex() {
let removedElement1 = self.orderedDictionary.removeAtIndex(1)
let removedElement2 = self.orderedDictionary.removeAtIndex(0)
let removedElement3 = self.orderedDictionary.removeAtIndex(5)
let removedElement1 = orderedDictionary.removeAtIndex(1)
let removedElement2 = orderedDictionary.removeAtIndex(0)
let removedElement3 = orderedDictionary.removeAtIndex(5)
expect(removedElement1?.0) == "B"
expect(removedElement1?.1) == 2
XCTAssertEqual(removedElement1?.0, "B")
XCTAssertEqual(removedElement1?.1, 2)
expect(removedElement2?.0) == "A"
expect(removedElement2?.1) == 1
XCTAssertEqual(removedElement2?.0, "A")
XCTAssertEqual(removedElement2?.1, 1)
expect(removedElement3).to(beNil())
XCTAssertNil(removedElement3)
expect(self.orderedDictionary.count) == 1
XCTAssertEqual(orderedDictionary.count, 1)
let elementAtIndex0 = self.orderedDictionary[0]
expect(elementAtIndex0.0) == "C"
expect(elementAtIndex0.1) == 3
let elementAtIndex0 = orderedDictionary[0]
XCTAssertEqual(elementAtIndex0.0, "C")
XCTAssertEqual(elementAtIndex0.1, 3)
}
// ======================================================= //
// MARK: - Sorting
// ======================================================= //
func testSortingInPlace() {
var testOrderedDictionary: OrderedDictionary<String, Int> = [
("E", 4),
("G", 3),
("A", 3),
("D", 1),
("B", 4)
]
testOrderedDictionary.sortInPlace { (item1, item2) in
if item1.1 == item2.1 {
return item1.0 < item2.0
} else {
return item1.1 < item2.1
}
}
let expectedOrderedDictionary: OrderedDictionary<String, Int> = [
("D", 1),
("A", 3),
("G", 3),
("B", 4),
("E", 4)
]
XCTAssertTrue(testOrderedDictionary == expectedOrderedDictionary)
}
// ======================================================= //
// MARK: - Description
// ======================================================= //
func testDescription() {
expect(self.orderedDictionary.description) == "[A: 1, B: 2, C: 3]"
XCTAssertEqual(orderedDictionary.description, "[A: 1, B: 2, C: 3]")
}
}