diff --git a/features/algebraic-type-forward-declaration.feature b/features/algebraic-type-forward-declaration.feature index ab43a27..a3bff41 100644 --- a/features/algebraic-type-forward-declaration.feature +++ b/features/algebraic-type-forward-declaration.feature @@ -104,7 +104,7 @@ Feature: Outputting forward declarations in Algebraic Types { switch (_subtype) { case _SimpleADTSubtypesFirstSubtype: { - return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %tu; \n", [super description], _firstSubtype_firstValue, _firstSubtype_secondValue]; + return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %llu; \n", [super description], _firstSubtype_firstValue, (unsigned long long)_firstSubtype_secondValue]; break; } case _SimpleADTSubtypesSomeRandomSubtype: { diff --git a/features/algebraic-types-coding.feature b/features/algebraic-types-coding.feature index d6c8ec9..f69a609 100644 --- a/features/algebraic-types-coding.feature +++ b/features/algebraic-types-coding.feature @@ -113,7 +113,7 @@ Feature: Outputting Algebraic Types { switch (_subtype) { case _SimpleADTSubtypesFirstSubtype: { - return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %tu; \n", [super description], _firstSubtype_firstValue, _firstSubtype_secondValue]; + return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %llu; \n", [super description], _firstSubtype_firstValue, (unsigned long long)_firstSubtype_secondValue]; break; } case _SimpleADTSubtypesSecondSubtype: { diff --git a/features/algebraic-types-cplusplus.feature b/features/algebraic-types-cplusplus.feature index 8182d76..73894c4 100644 --- a/features/algebraic-types-cplusplus.feature +++ b/features/algebraic-types-cplusplus.feature @@ -100,7 +100,7 @@ Feature: Outputting ObjC++ Algebraic Types { switch (_subtype) { case _SimpleADTSubtypesFirstSubtype: { - return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %tu; \n", [super description], _firstSubtype_firstValue, _firstSubtype_secondValue]; + return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %llu; \n", [super description], _firstSubtype_firstValue, (unsigned long long)_firstSubtype_secondValue]; break; } case _SimpleADTSubtypesSomeRandomSubtype: { diff --git a/features/algebraic-types.feature b/features/algebraic-types.feature index 1f619c4..e2436e5 100644 --- a/features/algebraic-types.feature +++ b/features/algebraic-types.feature @@ -136,7 +136,7 @@ Feature: Outputting Algebraic Types { switch (_subtype) { case _SimpleADTSubtypesFirstSubtype: { - return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %tu; \n", [super description], _firstSubtype_firstValue, _firstSubtype_secondValue]; + return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %llu; \n", [super description], _firstSubtype_firstValue, (unsigned long long)_firstSubtype_secondValue]; break; } case _SimpleADTSubtypesSomeRandomSubtype: { @@ -144,7 +144,7 @@ Feature: Outputting Algebraic Types break; } case _SimpleADTSubtypesSomeAttributeSubtype: { - return [NSString stringWithFormat:@"%@ - \n\t someAttributeSubtype: %tu; \n", [super description], _someAttributeSubtype]; + return [NSString stringWithFormat:@"%@ - \n\t someAttributeSubtype: %llu; \n", [super description], (unsigned long long)_someAttributeSubtype]; break; } case _SimpleADTSubtypesSecondSubtype: { @@ -317,7 +317,7 @@ Feature: Outputting Algebraic Types { switch (_subtype) { case _SimpleADTSubtypesFirstSubtype: { - return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %tu; \n", [super description], _firstSubtype_firstValue, _firstSubtype_secondValue]; + return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %llu; \n", [super description], _firstSubtype_firstValue, (unsigned long long)_firstSubtype_secondValue]; break; } case _SimpleADTSubtypesSecondSubtype: { @@ -488,7 +488,7 @@ Feature: Outputting Algebraic Types { switch (_subtype) { case _SimpleADTSubtypesFirstSubtype: { - return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %tu; \n", [super description], _firstSubtype_firstValue, _firstSubtype_secondValue]; + return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %llu; \n", [super description], _firstSubtype_firstValue, (unsigned long long)_firstSubtype_secondValue]; break; } case _SimpleADTSubtypesSomeRandomSubtype: { diff --git a/features/coding.feature b/features/coding.feature index a8b7c56..386ed45 100644 --- a/features/coding.feature +++ b/features/coding.feature @@ -70,7 +70,7 @@ Feature: Outputting Value Objects With Coded Values - (NSString *)description { - return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %zd; \n\t numberOfRatings: %tu; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, _likeCount, _numberOfRatings]; + return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %lld; \n\t numberOfRatings: %llu; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, (long long)_likeCount, (unsigned long long)_numberOfRatings]; } - (void)encodeWithCoder:(NSCoder *)aCoder diff --git a/features/configuration.feature b/features/configuration.feature index eb918b4..d51b52c 100644 --- a/features/configuration.feature +++ b/features/configuration.feature @@ -136,7 +136,7 @@ Feature: Outputting Value Objects With A Custom Plugin - (NSString *)description { - return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %zd; \n\t numberOfRatings: %tu; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, _likeCount, _numberOfRatings]; + return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %lld; \n\t numberOfRatings: %llu; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, (long long)_likeCount, (unsigned long long)_numberOfRatings]; } @end diff --git a/features/cplusplus.feature b/features/cplusplus.feature index 41794e3..455380b 100644 --- a/features/cplusplus.feature +++ b/features/cplusplus.feature @@ -73,7 +73,7 @@ Feature: Outputting C++ Value Objects - (NSString *)description { - return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %zd; \n\t numberOfRatings: %tu; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, _likeCount, _numberOfRatings]; + return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %lld; \n\t numberOfRatings: %llu; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, (long long)_likeCount, (unsigned long long)_numberOfRatings]; } - (NSUInteger)hash diff --git a/features/forward-declaration.feature b/features/forward-declaration.feature index f2de8ef..4992920 100644 --- a/features/forward-declaration.feature +++ b/features/forward-declaration.feature @@ -100,7 +100,7 @@ Feature: Outputting Value Objects With Forward Declarations - (NSString *)description { - return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %zd; \n\t numberOfRatings: %tu; \n\t proxy: %@; \n\t followers: %@; \n\t helloObj: %@; \n\t worldVc: %@; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, _likeCount, _numberOfRatings, _proxy, _followers, _helloObj, _worldVc]; + return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %lld; \n\t numberOfRatings: %llu; \n\t proxy: %@; \n\t followers: %@; \n\t helloObj: %@; \n\t worldVc: %@; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, (long long)_likeCount, (unsigned long long)_numberOfRatings, _proxy, _followers, _helloObj, _worldVc]; } - (NSUInteger)hash @@ -230,7 +230,7 @@ Feature: Outputting Value Objects With Forward Declarations - (NSString *)description { - return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %zd; \n\t countIconHeight: %f; \n\t countIconWidth: %f; \n\t numberOfRatings: %tu; \n\t foo: %@; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, _likeCount, _countIconHeight, _countIconWidth, _numberOfRatings, _foo]; + return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %lld; \n\t countIconHeight: %f; \n\t countIconWidth: %f; \n\t numberOfRatings: %llu; \n\t foo: %@; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, (long long)_likeCount, _countIconHeight, _countIconWidth, (unsigned long long)_numberOfRatings, _foo]; } @end diff --git a/features/nullability.feature b/features/nullability.feature index 272d137..72600f4 100644 --- a/features/nullability.feature +++ b/features/nullability.feature @@ -219,7 +219,7 @@ Feature: Outputting Objects With Nullability Annotations { switch (_subtype) { case _SimpleADTSubtypesFirstSubtype: { - return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %tu; \n", [super description], _firstSubtype_firstValue, _firstSubtype_secondValue]; + return [NSString stringWithFormat:@"%@ - FirstSubtype \n\t firstValue: %@; \n\t secondValue: %llu; \n", [super description], _firstSubtype_firstValue, (unsigned long long)_firstSubtype_secondValue]; break; } case _SimpleADTSubtypesSomeRandomSubtype: { diff --git a/features/object.feature b/features/object.feature index 1975cba..85af8f5 100644 --- a/features/object.feature +++ b/features/object.feature @@ -80,7 +80,7 @@ Feature: Outputting Objects - (NSString *)description { - return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %zd; \n\t numberOfRatings: %u; \n\t someType: %@; \n\t someClass: %@; \n\t someBlock: %@; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, _likeCount, _numberOfRatings, _someType, _someClass, _someBlock]; + return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %lld; \n\t numberOfRatings: %u; \n\t someType: %@; \n\t someClass: %@; \n\t someBlock: %@; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, (long long)_likeCount, _numberOfRatings, _someType, _someClass, _someBlock]; } @end @@ -161,7 +161,7 @@ Feature: Outputting Objects - (NSString *)description { - return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %zd; \n\t countIconHeight: %f; \n\t countIconWidth: %f; \n\t numberOfRatings: %tu; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, _likeCount, _countIconHeight, _countIconWidth, _numberOfRatings]; + return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %lld; \n\t countIconHeight: %f; \n\t countIconWidth: %f; \n\t numberOfRatings: %llu; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, (long long)_likeCount, _countIconHeight, _countIconWidth, (unsigned long long)_numberOfRatings]; } @end diff --git a/features/value_object.feature b/features/value_object.feature index 2ab5685..1081d4c 100644 --- a/features/value_object.feature +++ b/features/value_object.feature @@ -85,7 +85,7 @@ Feature: Outputting Value Objects - (NSString *)description { - return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %zd; \n\t numberOfRatings: %u; \n\t someType: %@; \n\t someClass: %@; \n\t someBlock: %@; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, _likeCount, _numberOfRatings, _someType, _someClass, _someBlock]; + return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %lld; \n\t numberOfRatings: %u; \n\t someType: %@; \n\t someClass: %@; \n\t someBlock: %@; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, (long long)_likeCount, _numberOfRatings, _someType, _someClass, _someBlock]; } - (NSUInteger)hash @@ -208,7 +208,7 @@ Feature: Outputting Value Objects - (NSString *)description { - return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %zd; \n\t countIconHeight: %f; \n\t countIconWidth: %f; \n\t numberOfRatings: %tu; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, _likeCount, _countIconHeight, _countIconWidth, _numberOfRatings]; + return [NSString stringWithFormat:@"%@ - \n\t doesUserLike: %@; \n\t identifier: %@; \n\t likeCount: %lld; \n\t countIconHeight: %f; \n\t countIconWidth: %f; \n\t numberOfRatings: %llu; \n", [super description], _doesUserLike ? @"YES" : @"NO", _identifier, (long long)_likeCount, _countIconHeight, _countIconWidth, (unsigned long long)_numberOfRatings]; } @end diff --git a/src/__tests__/plugins/description-test.ts b/src/__tests__/plugins/description-test.ts index 285e206..18b8d82 100644 --- a/src/__tests__/plugins/description-test.ts +++ b/src/__tests__/plugins/description-test.ts @@ -412,7 +412,7 @@ describe('ObjectSpecPlugins.Description', function() { { belongsToProtocol:Maybe.Just('NSObject'), code: [ - 'return [NSString stringWithFormat:@"%@ - \\n\\t age: %zd; \\n", [super description], _age];' + 'return [NSString stringWithFormat:@"%@ - \\n\\t age: %lld; \\n", [super description], (long long)_age];' ], comments: [], compilerAttributes:[], @@ -465,7 +465,7 @@ describe('ObjectSpecPlugins.Description', function() { { belongsToProtocol:Maybe.Just('NSObject'), code: [ - 'return [NSString stringWithFormat:@"%@ - \\n\\t age: %tu; \\n", [super description], _age];' + 'return [NSString stringWithFormat:@"%@ - \\n\\t age: %llu; \\n", [super description], (unsigned long long)_age];' ], comments: [], compilerAttributes:[], @@ -943,7 +943,7 @@ describe('ObjectSpecPlugins.Description', function() { { belongsToProtocol:Maybe.Just('NSObject'), code: [ - 'return [NSString stringWithFormat:@"%@ - \\n\\t age: %tu; \\n", [super description], _age];' + 'return [NSString stringWithFormat:@"%@ - \\n\\t age: %llu; \\n", [super description], (unsigned long long)_age];' ], comments: [], compilerAttributes:[], @@ -1429,7 +1429,7 @@ describe('AlgebraicTypePlugins.Description', function() { code: [ 'switch (_subtype) {', ' case _TestSubtypesSomeSubtype: {', - ' return [NSString stringWithFormat:@"%@ - SomeSubtype \\n\\t someString: %@; \\n\\t someUnsignedInteger: %tu; \\n", [super description], _someSubtype_someString, _someSubtype_someUnsignedInteger];', + ' return [NSString stringWithFormat:@"%@ - SomeSubtype \\n\\t someString: %@; \\n\\t someUnsignedInteger: %llu; \\n", [super description], _someSubtype_someString, (unsigned long long)_someSubtype_someUnsignedInteger];', ' break;', ' }', ' case _TestSubtypesCoolSingleAttributeBoolSubtype: {', diff --git a/src/plugins/description.ts b/src/plugins/description.ts index a641750..5276844 100644 --- a/src/plugins/description.ts +++ b/src/plugins/description.ts @@ -34,6 +34,12 @@ function useValueAccessor(valueAccessor:string):string { return valueAccessor; } +function castValueAccessorValue(castToApply: string):(valueAccessor:string) => string { + return function(valueAccessor:string):string { + return '(' + castToApply + ')' + valueAccessor; + }; +} + function useFunctionReturnValueAsDescriptionValue(functionToCall:string):(valueAccessor:string) => string { return function(valueAccessor:string):string { return functionToCall + '(' + valueAccessor + ')'; @@ -72,15 +78,15 @@ function attributeDescriptionForType(type:ObjC.Type):AttributeDescription { NSInteger: function() { return { descriptionFunctionImport: Maybe.Nothing(), - token: '%zd', - valueGenerator: useValueAccessor + token: '%lld', + valueGenerator: castValueAccessorValue('long long') }; }, NSUInteger: function() { return { descriptionFunctionImport: Maybe.Nothing(), - token: '%tu', - valueGenerator: useValueAccessor + token: '%llu', + valueGenerator: castValueAccessorValue('unsigned long long') }; }, double: function() {