Using Dotstar · Part 5

Tests

A pattern that works on today’s text can break on tomorrow’s, or when you change one part of it. The Tests tab keeps strings it should match and strings it shouldn’t, and marks each pass or fail as you edit the pattern.

The Tests tab: a date pattern with three strings that should match and three that shouldn’t, one of them failing.

Should match, should not match

Add strings under each heading. A string that should match passes when the pattern finds a match in it; one that shouldn’t, when it finds none. The tab’s count says how many pass, 5/6, so a failure shows from any tab.

Each string is searched on its own, with the pattern as written. In the picture, the pattern accepts 2026-02-30: it knows months and days, but not calendars. That’s a test doing its job.

Asking more of a match

⋯ beside a string that should match asks more of it:

  • that the match be the whole string
  • or exactly some text
  • that a group hold a value: year is 2026
  • that replacing in it give a result, with Replace on

Hover a string to see what passed, or what didn’t.

Kept with the pattern

The tests are saved with the pattern: in the library, in projects and in shared links. The Code tab can write them as unit tests in your language’s usual framework (pytest, JUnit, xUnit, Vitest and others), around the same code it writes for the pattern.