From 436e3ce430e83ba93a6e79f24788b302dc2a9839 Mon Sep 17 00:00:00 2001 From: jmkiley Date: Fri, 12 Oct 2018 11:14:41 -0700 Subject: [ios, macos] fixed a test, documented length is unavailable --- platform/darwin/src/NSExpression+MGLAdditions.h | 2 ++ platform/darwin/src/NSExpression+MGLAdditions.mm | 4 ++-- platform/darwin/test/MGLExpressionTests.mm | 12 ++++++------ platform/darwin/test/MGLOfflineStorageTests.mm | 1 - 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/platform/darwin/src/NSExpression+MGLAdditions.h b/platform/darwin/src/NSExpression+MGLAdditions.h index d13f0227b4..43acde15ce 100644 --- a/platform/darwin/src/NSExpression+MGLAdditions.h +++ b/platform/darwin/src/NSExpression+MGLAdditions.h @@ -173,6 +173,8 @@ FOUNDATION_EXTERN MGL_EXPORT const MGLExpressionInterpolationMode MGLExpressionI guide for a correspondence of operators and types between the style specification and the `NSExpression` representation used by this SDK. + Note that the `length` argument is not currently supported with iOS 8. + You can use `NSJSONSerialization` to serialize the Foundation object as data to write to a file. */ diff --git a/platform/darwin/src/NSExpression+MGLAdditions.mm b/platform/darwin/src/NSExpression+MGLAdditions.mm index 59b0cd3479..3146872a27 100644 --- a/platform/darwin/src/NSExpression+MGLAdditions.mm +++ b/platform/darwin/src/NSExpression+MGLAdditions.mm @@ -843,9 +843,9 @@ NSArray *MGLSubexpressionsWithJSONObjects(NSArray *objects) { NSPredicate *conditional = [arguments.firstObject constantValue]; return [NSExpression expressionForConditional:conditional trueExpression:arguments[1] falseExpression:arguments[2]]; } - } else { - return [NSExpression expressionForFunction:@"MGL_IF" arguments:arguments]; } + + return [NSExpression expressionForFunction:@"MGL_IF" arguments:arguments]; } else if ([op isEqualToString:@"match"]) { NSMutableArray *optionsArray = [NSMutableArray array]; diff --git a/platform/darwin/test/MGLExpressionTests.mm b/platform/darwin/test/MGLExpressionTests.mm index 39f08eda00..7e091a7f05 100644 --- a/platform/darwin/test/MGLExpressionTests.mm +++ b/platform/darwin/test/MGLExpressionTests.mm @@ -620,11 +620,12 @@ using namespace std::string_literals; XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression); } { - // TODO JK: caught "NSInternalInconsistencyException", "length: is not a supported method." - NSExpression *expression = [NSExpression expressionForFunction:@"length:" arguments:arguments]; - NSArray *jsonExpression = @[@"length", @"MacDonald"]; - XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); - XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression); + if (@available(iOS 9.0, *)) { + NSExpression *expression = [NSExpression expressionForFunction:@"length:" arguments:arguments]; + NSArray *jsonExpression = @[@"length", @"MacDonald"]; + XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression); + XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression); + } } } @@ -1099,7 +1100,6 @@ using namespace std::string_literals; @80000 ], @[@"get", @"abbr"], - // TODO JK - ((localizedExpression.mgl_jsonExpressionObject) equal to (localizedJSONExpression)) failed: throwing "*** -constantValue only defined for abstract class. Define -[NSKeyPathExpression constantValue]!" @[@"get", @"name"] ], @5, @[@"get", @"name"] diff --git a/platform/darwin/test/MGLOfflineStorageTests.mm b/platform/darwin/test/MGLOfflineStorageTests.mm index c02ec379b6..ad6e1a0570 100644 --- a/platform/darwin/test/MGLOfflineStorageTests.mm +++ b/platform/darwin/test/MGLOfflineStorageTests.mm @@ -266,7 +266,6 @@ auto fs = os.mbglFileSource; - // TODO JK - Getting failures // Delegate returns "https://api.mapbox.com" as a replacement URL. const mbgl::Resource resource { mbgl::Resource::Unknown, "test://api" }; std::unique_ptr req; -- cgit v1.2.1