Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[webview_flutter_wkwebview] Return an NSNumber that represents a bool #5968

Merged
merged 4 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ - (void)testRemoveDataOfTypes {
blockError = error;
}];
XCTAssertEqualObjects(returnValue, @YES);
// Asserts whether the NSNumber value represents a BOOL.
XCTAssertEqual(CFBooleanGetTypeID(), CFGetTypeID((__bridge CFTypeRef)(returnValue)));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compare to CFBooleanGetTypeID()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I just wasn't reading carefully and thought the right hand side was the expected value and that you were extracting the type from a local variable. I was suggesting using CFBooleanGetTypeID() as the expected value instead which is already what you are doing. Oops!

(It is confusing that this test is inconsistent about whether you put the expected value first or second though. The line right above this does the opposite.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right. I switched the order

XCTAssertNil(blockError);
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ - (void)createDefaultDataStoreWithIdentifier:(nonnull NSNumber *)identifier
modifiedSince:[NSDate dateWithTimeIntervalSince1970:
modificationTimeInSecondsSinceEpoch.doubleValue]
completionHandler:^{
completion(@(records.count > 0), nil);
completion([NSNumber numberWithBool:(records.count > 0)], nil);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, that's a surprising foot-gun. TIL.

What type was it turning into exactly? Int?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, it was returning an int for some reason.

}];
}];
}
Expand Down