Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] Fix spacing, a couple of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jmkiley committed Sep 25, 2019
1 parent fbe7ce8 commit 06f4094
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions platform/darwin/src/NSExpression+MGLAdditions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1057,7 +1057,8 @@ - (id)mgl_jsonExpressionObject {
NSString *function = self.function;

BOOL hasCollectionProperty = !(self.arguments.firstObject.expressionType == NSConstantValueExpressionType || self.arguments.firstObject.expressionType == NSKeyPathExpressionType
|| self.arguments.firstObject.expressionType == NSVariableExpressionType || !self.arguments.firstObject.expressionType);
|| self.arguments.firstObject.expressionType == NSVariableExpressionType || !self.arguments.firstObject.expressionType
);
NSString *op = MGLExpressionOperatorsByFunctionNames[function];
if (op) {
NSArray *arguments = self.arguments.mgl_jsonExpressionObject;
Expand All @@ -1082,17 +1083,17 @@ - (id)mgl_jsonExpressionObject {
} else if ([function isEqualToString:@"min:"]) {
NSArray *arguments;
if (!hasCollectionProperty) {
arguments = [self.arguments valueForKeyPath:@"mgl_jsonExpressionObject"];
arguments = [self.arguments valueForKeyPath:@"mgl_jsonExpressionObject"];
} else {
arguments = [self.arguments.firstObject.collection valueForKeyPath:@"mgl_jsonExpressionObject"];
}
return [@[@"min"] arrayByAddingObjectsFromArray:arguments];
} else if ([function isEqualToString:@"max:"]) {
NSArray *arguments;
if (!hasCollectionProperty) {
arguments = [self.arguments valueForKeyPath:@"mgl_jsonExpressionObject"];
arguments = [self.arguments valueForKeyPath:@"mgl_jsonExpressionObject"];
} else {
arguments = [self.arguments.firstObject.collection valueForKeyPath:@"mgl_jsonExpressionObject"];
arguments = [self.arguments.firstObject.collection valueForKeyPath:@"mgl_jsonExpressionObject"];
}
return [@[@"max"] arrayByAddingObjectsFromArray:arguments];
} else if ([function isEqualToString:@"exp:"]) {
Expand All @@ -1103,7 +1104,7 @@ - (id)mgl_jsonExpressionObject {
} else if ([function isEqualToString:@"mgl_join:"]) {
NSArray *arguments;
if (!hasCollectionProperty) {
arguments = [self.arguments valueForKeyPath:@"mgl_jsonExpressionObject"];
arguments = [self.arguments valueForKeyPath:@"mgl_jsonExpressionObject"];
} else {
arguments = [self.arguments.firstObject.collection valueForKeyPath:@"mgl_jsonExpressionObject"];
}
Expand Down
12 changes: 6 additions & 6 deletions platform/darwin/test/MGLExpressionTests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,6 @@ - (void)testStatisticalExpressionObject {
XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @28);
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
}
{
NSExpression *expression = [NSExpression expressionForFunction:@"sum:" arguments:@[@1, @2, @2, @3, @4, @7, @9]];
NSArray *jsonExpression = @[@"+", @1, @2, @2, @3, @4, @7, @9];
XCTAssertEqualObjects([expression expressionValueWithObject:nil context:nil], @28);
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
}
{
NSExpression *expression = [NSExpression expressionWithFormat:@"count({1, 2, 2, 3, 4, 7, 9})"];
NSArray *jsonExpression = @[@"length", @[@"literal", @[@1, @2, @2, @3, @4, @7, @9]]];
Expand Down Expand Up @@ -393,6 +387,12 @@ - (void)testArithmeticExpressionObject {
XCTAssertEqualObjects([NSExpression expressionWithFormat:@"1 + 1"].mgl_jsonExpressionObject, jsonExpression);
XCTAssertEqualObjects([NSExpression expressionWithMGLJSONObject:jsonExpression], expression);
}
{
NSExpression *expression = [NSExpression expressionForFunction:@"sum:" arguments:arguments];
NSArray *jsonExpression = @[@"+", @1, @1];
XCTAssertEqualObjects(expression.mgl_jsonExpressionObject, jsonExpression);
XCTAssertEqualObjects([NSExpression expressionWithFormat:@"1 + 1"].mgl_jsonExpressionObject, jsonExpression);
}
{
NSArray *threeArguments = @[MGLConstantExpression(@1), MGLConstantExpression(@1), MGLConstantExpression(@1)];
NSExpression *expression = [NSExpression expressionForFunction:@"add:to:" arguments:threeArguments];
Expand Down

0 comments on commit 06f4094

Please sign in to comment.