Assert::match and placeholders redesign

Notice: This thread is very old.
David Grudl
Nette Core | 8218
+
0
-

For matching string against pattern Nette Tester provides methods Assert::match() and Assert::matchFile(). It is possible to use classic regexp pattern, but more useful are these wildchars (or placeholders):

  • %a% one or more of anything except the end of line characters
  • %a?% zero or more of anything except the end of line characters
  • %A% one or more of anything including the end of line characters
  • %A?% zero or more of anything including the end of line characters
  • %s% one or more white space characters except the end of line characters
  • %s?% zero or more white space characters except the end of line characters
  • %S% one or more of characters except the white space
  • %S?% zero or more of characters except the white space
  • %c% a single character of any sort (except the end of line)
  • %d% one or more digits
  • %d?% zero or more digits
  • %i% signed integer value
  • %f% floating point number
  • %h% one or more HEX digits
  • %ds% directory separator
  • %[...]% any characters range
  • …and you can add new custom wildchars

They are useful because you don't need to think about escaping all regexp meta characters.

But there is problem with inconsistency: %a% vs. %A% and %s% vs. %S%. First ones differs in line endings, second ones have opposite meaning. Some of wildchars are not intuitive. I'd like to fix it. Let's put our heads together and figure out how some of them change.