From 936c76d142b9669cf76ac79eda0ba4b8cfc2139a Mon Sep 17 00:00:00 2001 From: iska Date: Sat, 11 Apr 2015 21:47:55 +0200 Subject: [PATCH] Remove the superfluous allObjects method from the tokenizer class Being a NSEnumerator, the tokenizer cannot be reset, hence the change in the tests to create a new instance for each iteration. --- HTMLKit/HTMLTokenizer.m | 8 -------- HTMLKitTests/HTMLKitTokenizerTests.m | 6 +++--- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/HTMLKit/HTMLTokenizer.m b/HTMLKit/HTMLTokenizer.m index f4e207c..d64cba9 100644 --- a/HTMLKit/HTMLTokenizer.m +++ b/HTMLKit/HTMLTokenizer.m @@ -103,14 +103,6 @@ return nextToken; } -- (NSArray *)allObjects -{ - while (_eof == NO) { - [self read]; - } - return _tokens; -} - - (void)read { SEL selector = [[_states objectForKey:@(_currentState)] pointerValue]; diff --git a/HTMLKitTests/HTMLKitTokenizerTests.m b/HTMLKitTests/HTMLKitTokenizerTests.m index b480a3b..dbf40aa 100644 --- a/HTMLKitTests/HTMLKitTokenizerTests.m +++ b/HTMLKitTests/HTMLKitTokenizerTests.m @@ -90,15 +90,15 @@ - (void)testTokenizer { for (HTML5LibTokenizerTest *test in self.testsList) { - HTMLTokenizer *tokenizer = [[HTMLTokenizer alloc] initWithString:test.input]; - [tokenizer setValue:test.lastStartTag forKey:@"_lastStartTagName"]; for (NSNumber *state in test.initialStates) { + HTMLTokenizer *tokenizer = [[HTMLTokenizer alloc] initWithString:test.input]; + [tokenizer setValue:test.lastStartTag forKey:@"_lastStartTagName"]; tokenizer.state = [state integerValue]; NSArray *expectedTokens = test.output; - NSArray *tokens = [tokenizer allObjects]; + NSArray *tokens = tokenizer.allObjects; XCTAssertEqualObjects(tokens, expectedTokens, @"%@", test.title); } }