Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'cedar' into experimental
- Loading branch information
Showing
135 changed files
with
5,687 additions
and
6,674 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Versions/Current/Cedar |
File renamed without changes.
File renamed without changes.
Binary file not shown.
117 changes: 117 additions & 0 deletions
117
AppledocTests/Libraries/Cedar.framework/Versions/A/Headers/ActualValue.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <iostream> | ||
|
||
#import "StringifiersBase.h" | ||
#import "CDRSpecFailure.h" | ||
|
||
namespace Cedar { namespace Matchers { | ||
|
||
void CDR_fail(const char *fileName, int lineNumber, NSString * reason); | ||
|
||
template<typename T> class ActualValue; | ||
|
||
#pragma mark class ActualValueMatchProxy | ||
template<typename T> | ||
class ActualValueMatchProxy { | ||
private: | ||
template<typename U> | ||
ActualValueMatchProxy(const ActualValueMatchProxy<U> &); | ||
template<typename U> | ||
ActualValueMatchProxy & operator=(const ActualValueMatchProxy<U> &); | ||
|
||
public: | ||
explicit ActualValueMatchProxy(const ActualValue<T> &, bool negate = false); | ||
ActualValueMatchProxy(); | ||
|
||
template<typename MatcherType> void operator()(const MatcherType &) const; | ||
ActualValueMatchProxy<T> negate() const; | ||
|
||
private: | ||
const ActualValue<T> & actualValue_; | ||
bool negate_; | ||
}; | ||
|
||
template<typename T> | ||
ActualValueMatchProxy<T>::ActualValueMatchProxy(const ActualValue<T> & actualValue, bool negate /*= false */) | ||
: actualValue_(actualValue), negate_(negate) {} | ||
|
||
template<typename T> template<typename MatcherType> | ||
void ActualValueMatchProxy<T>::operator()(const MatcherType & matcher) const { | ||
if (negate_) { | ||
actualValue_.execute_negative_match(matcher); | ||
} else { | ||
actualValue_.execute_positive_match(matcher); | ||
} | ||
} | ||
|
||
template<typename T> | ||
ActualValueMatchProxy<T> ActualValueMatchProxy<T>::negate() const { | ||
return ActualValueMatchProxy<T>(actualValue_, !negate_); | ||
} | ||
|
||
#pragma mark class ActualValue | ||
template<typename T> | ||
class ActualValue { | ||
private: | ||
template<typename U> | ||
ActualValue(const ActualValue<U> &); | ||
template<typename U> | ||
ActualValue & operator=(const ActualValue<U> &); | ||
|
||
public: | ||
explicit ActualValue(const char *, int, const T &); | ||
~ActualValue(); | ||
|
||
ActualValueMatchProxy<T> to; | ||
ActualValueMatchProxy<T> to_not; | ||
|
||
private: | ||
template<typename MatcherType> void execute_positive_match(const MatcherType &) const; | ||
template<typename MatcherType> void execute_negative_match(const MatcherType &) const; | ||
friend class ActualValueMatchProxy<T>; | ||
|
||
private: | ||
const T & value_; | ||
std::string fileName_; | ||
int lineNumber_; | ||
}; | ||
|
||
template<typename T> | ||
ActualValue<T>::ActualValue(const char *fileName, int lineNumber, const T & value) : fileName_(fileName), lineNumber_(lineNumber), value_(value), to(*this), to_not(*this, true) { | ||
} | ||
|
||
template<typename T> | ||
ActualValue<T>::~ActualValue() { | ||
} | ||
|
||
template<typename T> template<typename MatcherType> | ||
void ActualValue<T>::execute_positive_match(const MatcherType & matcher) const { | ||
if (!matcher.matches(value_)) { | ||
CDR_fail(fileName_.c_str(), lineNumber_, matcher.failure_message_for(value_)); | ||
} | ||
} | ||
|
||
template<typename T> template<typename MatcherType> | ||
void ActualValue<T>::execute_negative_match(const MatcherType & matcher) const { | ||
if (matcher.matches(value_)) { | ||
CDR_fail(fileName_.c_str(), lineNumber_, matcher.negative_failure_message_for(value_)); | ||
} | ||
} | ||
|
||
template<typename T> | ||
const ActualValue<T> CDR_expect(const char *fileName, int lineNumber, const T & actualValue) { | ||
return ActualValue<T>(fileName, lineNumber, actualValue); | ||
} | ||
|
||
inline void CDR_fail(const char *fileName, int lineNumber, NSString * reason) { | ||
[[CDRSpecFailure specFailureWithReason:reason | ||
fileName:[NSString stringWithUTF8String:fileName] | ||
lineNumber:lineNumber] raise]; | ||
} | ||
|
||
}} | ||
|
||
#ifndef CEDAR_MATCHERS_COMPATIBILITY_MODE | ||
#define expect(x) CDR_expect(__FILE__, __LINE__, (x)) | ||
#define fail(x) CDR_fail(__FILE__, __LINE__, (x)) | ||
#endif |
60 changes: 60 additions & 0 deletions
60
AppledocTests/Libraries/Cedar.framework/Versions/A/Headers/Argument.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#import <Foundation/Foundation.h> | ||
#import "CompareEqual.h" | ||
#import "CedarStringifiers.h" | ||
#import "CedarComparators.h" | ||
|
||
namespace Cedar { namespace Doubles { | ||
|
||
class Argument { | ||
public: | ||
virtual ~Argument() = 0; | ||
|
||
virtual const char * value_encoding() const = 0; | ||
virtual NSString * value_string() const = 0; | ||
|
||
virtual bool matches_bytes(void * expectedArgumentBytes) const = 0; | ||
}; | ||
|
||
inline /* virtual */ Argument::~Argument() {} | ||
|
||
template<typename T> | ||
class TypedArgument : public Argument { | ||
private: | ||
TypedArgument<T> & operator=(const TypedArgument<T> &); | ||
|
||
public: | ||
explicit TypedArgument(const T &); | ||
virtual ~TypedArgument(); | ||
// Allow default copy ctor. | ||
|
||
virtual const char * value_encoding() const; | ||
virtual NSString * value_string() const; | ||
|
||
virtual bool matches_bytes(void * expectedArgumentBytes) const; | ||
|
||
private: | ||
const T & value_; | ||
}; | ||
|
||
|
||
template<typename T> | ||
TypedArgument<T>::TypedArgument(const T & value) : Argument(), value_(value) {} | ||
|
||
template<typename T> | ||
/* virtual */ TypedArgument<T>::~TypedArgument() {} | ||
|
||
template<typename T> | ||
/* virtual */ const char * TypedArgument<T>::value_encoding() const { | ||
return @encode(T); | ||
} | ||
|
||
template<typename T> | ||
/* virtual */ NSString * TypedArgument<T>::value_string() const { | ||
return Matchers::Stringifiers::string_for(value_); | ||
} | ||
|
||
template<typename T> | ||
/* virtual */ bool TypedArgument<T>::matches_bytes(void * expectedArgumentBytes) const { | ||
return Matchers::Comparators::compare_equal(value_, *(static_cast<T *>(expectedArgumentBytes))); | ||
} | ||
}} |
51 changes: 51 additions & 0 deletions
51
AppledocTests/Libraries/Cedar.framework/Versions/A/Headers/Base.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <sstream> | ||
|
||
#import "CedarStringifiers.h" | ||
|
||
namespace Cedar { namespace Matchers { | ||
struct BaseMessageBuilder { | ||
template<typename U> | ||
static NSString * string_for_actual_value(const U & value) { | ||
return Stringifiers::string_for(value); | ||
} | ||
}; | ||
|
||
/** | ||
* Basic functionality for all matchers. Meant to be used as a convenience base class for | ||
* matcher classes. | ||
*/ | ||
template<typename MessageBuilder_ = BaseMessageBuilder> | ||
class Base { | ||
private: | ||
Base & operator=(const Base &); | ||
|
||
public: | ||
Base(); | ||
virtual ~Base() = 0; | ||
// Allow default copy ctor. | ||
|
||
template<typename U> | ||
NSString * failure_message_for(const U &) const; | ||
template<typename U> | ||
NSString * negative_failure_message_for(const U &) const; | ||
|
||
protected: | ||
virtual NSString * failure_message_end() const = 0; | ||
}; | ||
|
||
template<typename MessageBuilder_> | ||
Base<MessageBuilder_>::Base() {} | ||
template<typename MessageBuilder_> | ||
Base<MessageBuilder_>::~Base() {} | ||
|
||
template<typename MessageBuilder_> template<typename U> | ||
NSString * Base<MessageBuilder_>::failure_message_for(const U & value) const { | ||
return [NSString stringWithFormat:@"Expected <%@> to %@", MessageBuilder_::string_for_actual_value(value), this->failure_message_end()]; | ||
} | ||
|
||
template<typename MessageBuilder_> template<typename U> | ||
NSString * Base<MessageBuilder_>::negative_failure_message_for(const U & value) const { | ||
return [NSString stringWithFormat:@"Expected <%@> to not %@", MessageBuilder_::string_for_actual_value(value), this->failure_message_end()]; | ||
} | ||
}} |
Oops, something went wrong.