mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fixed bug where method calls containing struct arguments would fail silently
Summary: The arg block for handling structs did not return a value, which was being intepreted as failure. This diff returns YES for success, and also adds an error log for this case so future regressions won't fail silently.
This commit is contained in:
1 parent
a4e64196bc
commit
76a9baaf2f
2 files changed
+20
-5
No files matched your search
@@ -35,6 +35,9 @@ static BOOL RCTLogsError(void (^block)(void))
|
||||
@end
|
||||
|
||||
@implementation RCTModuleMethodTests
|
||||
{
|
||||
CGRect _s;
|
||||
}
|
||||
|
||||
- (void)doFooWithBar:(__unused NSString *)bar { }
|
||||
|
||||
@@ -56,6 +59,7 @@ static BOOL RCTLogsError(void (^block)(void))
|
||||
- (void)doFooWithNumber:(__unused NSNumber *)n { }
|
||||
- (void)doFooWithDouble:(__unused double)n { }
|
||||
- (void)doFooWithInteger:(__unused NSInteger)n { }
|
||||
- (void)doFooWithCGRect:(CGRect)s { _s = s; }
|
||||
|
||||
- (void)testNumbersNonnull
|
||||
{
|
||||
@@ -102,4 +106,16 @@ static BOOL RCTLogsError(void (^block)(void))
|
||||
}
|
||||
}
|
||||
|
||||
- (void)testStructArgument
|
||||
{
|
||||
NSString *methodName = @"doFooWithCGRect:(CGRect)s";
|
||||
RCTModuleMethod *method = [[RCTModuleMethod alloc] initWithObjCMethodName:methodName
|
||||
JSMethodName:nil
|
||||
moduleClass:[self class]];
|
||||
|
||||
CGRect r = CGRectMake(10, 20, 30, 40);
|
||||
[method invokeWithBridge:nil module:self arguments:@[@[@10, @20, @30, @40]]];
|
||||
XCTAssertTrue(CGRectEqualToRect(r, _s));
|
||||
}
|
||||
|
||||
@end
|
||||
Reference in new issue
Block a user