mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-15 11:13:50 +00:00
CPPredicate: Fix for fail when parsing empty quotes. With Tests.
This commit is contained in:
1 parent
275f89a340
commit
c735399ca5
2 files changed
+14
-8
No files matched your search
@@ -638,37 +638,40 @@ function(newValue)\
|
||||
|
||||
[self setScanLocation:location];
|
||||
}
|
||||
|
||||
|
||||
if ([self scanString:@"\"" intoString:NULL])
|
||||
{
|
||||
var skip = [self charactersToBeSkipped],
|
||||
str;
|
||||
str = @"";
|
||||
|
||||
[self setCharactersToBeSkipped:nil];
|
||||
if ([self scanUpToString:@"\"" intoString:REFERENCE(str)] == NO)
|
||||
[self scanUpToString:@"\"" intoString:REFERENCE(str)];
|
||||
|
||||
if ([self scanString:@"\"" intoString:NULL] == NO)
|
||||
{
|
||||
[self setCharactersToBeSkipped:skip];
|
||||
[CPException raise:CPInvalidArgumentException reason:@"Invalid double quoted literal at "+location];
|
||||
}
|
||||
|
||||
[self scanString:@"\"" intoString:NULL];
|
||||
[self setCharactersToBeSkipped:skip];
|
||||
|
||||
return [CPExpression expressionForConstantValue:str];
|
||||
}
|
||||
|
||||
if ([self scanString:@"'" intoString:NULL])
|
||||
{
|
||||
var skip = [self charactersToBeSkipped],
|
||||
str;
|
||||
str = @"";
|
||||
|
||||
[self setCharactersToBeSkipped:nil];
|
||||
if ([self scanUpToString:@"'" intoString:REFERENCE(str)] == NO)
|
||||
[self scanUpToString:@"'" intoString:REFERENCE(str)];
|
||||
|
||||
if ([self scanString:@"'" intoString:NULL] == NO)
|
||||
{
|
||||
[self setCharactersToBeSkipped:skip];
|
||||
[CPException raise:CPInvalidArgumentException reason:@"Invalid single quoted literal at "+location];
|
||||
[CPException raise:CPInvalidArgumentException reason:@"Invalid double quoted literal at "+location];
|
||||
}
|
||||
|
||||
[self scanString:@"'" intoString:NULL];
|
||||
[self setCharactersToBeSkipped:skip];
|
||||
|
||||
return [CPExpression expressionForConstantValue:str];
|
||||
|
||||
@@ -221,6 +221,9 @@
|
||||
|
||||
predicate = [CPPredicate predicateWithFormat: @"a BETWEEN {%f,%f}", 20, 40];
|
||||
[self assertTrue:([predicate predicateOperatorType] == CPBetweenPredicateOperatorType) message:[predicate description] + " operator should be a CPBetweenPredicateOperatorType"];
|
||||
|
||||
predicate = [CPPredicate predicateWithFormat: @"a CONTAINS \"\""];
|
||||
[self assertNotNull:predicate message:[predicate description] + " should not be nil"];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in new issue
Block a user