Set iterator and range detach operations to noop

Leave the housekeeping to the NSHashTable itself, which should purge
null-references automatically (not necessarily right away)

Also update tests accordingly: Use `allObjects.count` instead of simply
`count` on the NSHashTable, since `allObjects.count` returns non-null
references.

This should fix #36
This commit is contained in:
iska
2019-08-06 21:26:21 +02:00
parent 1dda2921fe
commit 153d48c19c
3 changed files with 11 additions and 9 deletions
+7 -5
View File
@@ -580,19 +580,20 @@ static HTMLNode * (^ LastDescendant)(HTMLNode *) = ^ HTMLNode * (HTMLNode *node)
XCTAssertNotNil(body);
// iterator should be deallocated and detached at this point
XCTAssertEqual(0, nodeIterators.count);
XCTAssertEqual(0, nodeIterators.allObjects.count);
// iterator should be autoreleased, deallocated and detached after autoreleasepool
@autoreleasepool {
HTMLNodeIterator *iterator = [[HTMLNodeIterator alloc] initWithNode:body];
[iterator nextNode];
XCTAssertEqual(1, nodeIterators.count);
XCTAssertEqual(1, nodeIterators.allObjects.count);
}
XCTAssertEqual(0, nodeIterators.count);
XCTAssertEqual(0, nodeIterators.allObjects.count);
}
- (void)testBugFix_Issue_22 {
- (void)testBugFix_Issue_22
{
// The issue is applicable only for devices. On simulator the test is passed.
HTMLDocument *document = [HTMLDocument documentWithString:@"<div id=\"id\"></div>"];
@@ -608,7 +609,8 @@ static HTMLNode * (^ LastDescendant)(HTMLNode *) = ^ HTMLNode * (HTMLNode *node)
XCTAssertTrue([element.elementId isEqualToString:divId]);
}
- (void)testBugFix_Issue_28 {
- (void)testBugFix_Issue_28
{
HTMLDocument *document = self.document;
HTMLNodeIterator *iterator = document.body.nodeIterator;