|
44 | 44 | * `// $tag=expected-value` |
45 | 45 | * |
46 | 46 | * Where `tag` is the value of the `tag` parameter from `hasActualResult()`, and `expected-value` is |
47 | | - * the value of the `value` parameter from `hasActualResult()`. Multiple expectations may be placed |
48 | | - * in the same comment, as long as each is prefixed by a `$`. Any actual result that appears on a |
49 | | - * line that does not contain a matching expected result comment will be reported with a message of |
50 | | - * the form "Unexpected result: tag=value". Any expected result comment for which there is no |
51 | | - * matching actual result will be reported with a message of the form |
| 47 | + * the value of the `value` parameter from `hasActualResult()`. The `=expected-value` portion may be |
| 48 | + * omitted, in which case `expected-value` is treated as the empty string. Multiple expectations may |
| 49 | + * be placed in the same comment, as long as each is prefixed by a `$`. Any actual result that |
| 50 | + * appears on a line that does not contain a matching expected result comment will be reported with |
| 51 | + * a message of the form "Unexpected result: tag=value". Any expected result comment for which there |
| 52 | + * is no matching actual result will be reported with a message of the form |
52 | 53 | * "Missing result: tag=expected-value". |
53 | 54 | * |
54 | 55 | * Example: |
@@ -148,8 +149,19 @@ abstract class InlineExpectationsTest extends string { |
148 | 149 | } |
149 | 150 | } |
150 | 151 |
|
| 152 | +/** |
| 153 | + * RegEx pattern to match a comment containing one or more expected results. The comment must be a |
| 154 | + * C++-style (`//`) comment with `$` as its first non-whitespace character. Any subsequent character |
| 155 | + * is treated as part of the expected results, except that the comment may contain a `//` sequence |
| 156 | + * to treat the remainder of the line as a regular (non-interpreted) comment. |
| 157 | + */ |
151 | 158 | private string expectationCommentPattern() { result = "//\\s*(\\$(?:[^/]|/[^/])*)(?://.*)?" } |
152 | 159 |
|
| 160 | +/** |
| 161 | + * RegEx pattern to match a single expected result, not including the leading `$`. It starts with an |
| 162 | + * optional `f+:` or `f-:`, followed by one or more comma-separated tags containing only letters, |
| 163 | + * `-`, and `_`, optionally followed by `=` and the expected value. |
| 164 | + */ |
153 | 165 | private string expectationPattern() { |
154 | 166 | result = "(?:(f(?:\\+|-)):)?((?:[A-Za-z-_]+)(?:\\s*,\\s*[A-Za-z-_]+)*)(?:=(.*))?" |
155 | 167 | } |
|
0 commit comments