Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added a unit test to determine if 'conformToProtocol' was properly id…

…entifying a class conforming to a protocol via inheritance
  • Loading branch information...
commit 376212f00de14e17c90fe504390e08bdc3c766a7 1 parent 4863025
@aspitz aspitz authored
Showing with 19 additions and 0 deletions.
  1. +19 −0 CoreParseTests/CoreParseTests.m
View
19 CoreParseTests/CoreParseTests.m
@@ -889,4 +889,23 @@ - (void)testErrorRecovery
STAssertEquals([result intValue], 45, @"Parsed expression had incorrect value", nil);
}
+- (void)testConformsToProtocol
+{
+ CPTokeniser *tokeniser = [[[CPTokeniser alloc] init] autorelease];
+ [tokeniser addTokenRecogniser:[CPNumberRecogniser integerRecogniser]];
+ [tokeniser addTokenRecogniser:[CPWhiteSpaceRecogniser whiteSpaceRecogniser]];
+ [tokeniser addTokenRecogniser:[CPKeywordRecogniser recogniserForKeyword:@"+"]];
+ [tokeniser setDelegate:[[[CPTestWhiteSpaceIgnoringDelegate alloc] init] autorelease]];
+ CPTokenStream *tokenStream = [tokeniser tokenise:@"5 + 9 + 2 + 7"];
+
+ NSString *testGrammar =
+ @"Expression2 ::= <Term2> | <Expression2> '+' <Term2>;"
+ @"Term2 ::= 'Number';";
+ CPGrammar *grammar = [CPGrammar grammarWithStart:@"Expression2" backusNaurForm:testGrammar error:NULL];
+ CPParser *parser = [CPSLRParser parserWithGrammar:grammar];
+ Expression *e = [parser parse:tokenStream];
+
+ STAssertEquals([e value], 23.0f, @"'conformToProtocol' failed", [e value]);
+}
+
@end
Please sign in to comment.
Something went wrong with that request. Please try again.