Skip to content

Commit f4edf2b

Browse files
committed
feat: Upgrade fluent-asserts to v2.0 with major architectural changes
- Refactor evaluation logic to use structs for better performance and memory management. - Transition from GC-based string serialization to HeapString for @nogc compatibility. - Update import paths for operations and serializers to reflect new module structure. - Enhance custom operation and serializer registration processes. - Introduce new features including centralized configuration, multiple output formats, and context data for assertions. - Improve assertion failure messages and statistics tracking. - Add migration guide for users upgrading from v1.x to v2.0.
1 parent ed37ff1 commit f4edf2b

File tree

18 files changed

+723
-553
lines changed

18 files changed

+723
-553
lines changed

docs/astro.config.mjs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,17 @@ export default defineConfig({
1919
label: 'Guide',
2020
items: [
2121
{ label: 'Introduction', link: '/guide/introduction/' },
22+
{ label: 'Philosophy', link: '/guide/philosophy/' },
2223
{ label: 'Installation', link: '/guide/installation/' },
23-
{ label: 'Assertion Styles', link: '/guide/assertion-styles/' },
2424
{ label: 'Core Concepts', link: '/guide/core-concepts/' },
25+
{ label: 'Assertion Styles', link: '/guide/assertion-styles/' },
26+
{ label: 'Configuration', link: '/guide/configuration/' },
27+
{ label: 'Context Data', link: '/guide/context-data/' },
28+
{ label: 'Assertion Statistics', link: '/guide/statistics/' },
2529
{ label: 'Memory Management', link: '/guide/memory-management/' },
2630
{ label: 'Extending', link: '/guide/extending/' },
27-
{ label: 'Philosophy', link: '/guide/philosophy/' },
2831
{ label: 'Contributing', link: '/guide/contributing/' },
32+
{ label: 'Upgrading to v2', link: '/guide/upgrading-v2/' },
2933
],
3034
},
3135
{

docs/src/content/docs/guide/configuration.mdx

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ fluent-asserts provides configurable output formats for assertion failure messag
77

88
## Output Formats
99

10-
Three output formats are available:
10+
Three output formats are available, each designed for a specific audience:
1111

1212
### Verbose (Default)
1313

14-
The verbose format provides detailed, human-readable output with full context:
14+
The **human-friendly** format. Provides detailed, readable output with full context including source code snippets. Perfect for local development and debugging when you need to understand exactly what went wrong.
1515

1616
```
1717
ASSERTION FAILED: 5 should equal 3.
@@ -24,17 +24,9 @@ source/mytest.d:42
2424
> 42: expect(5).to.equal(3);
2525
```
2626

27-
### Compact
28-
29-
A single-line format optimized for minimal token usage, useful for AI-assisted development:
30-
31-
```
32-
FAIL: 5 should equal 3. | actual=5 expected=3 | source/mytest.d:42
33-
```
34-
3527
### TAP (Test Anything Protocol)
3628

37-
Standard TAP format for integration with CI/CD tools and test harnesses:
29+
The **universal machine-readable** format. [TAP](https://testanything.org/) is a standard protocol understood by CI/CD systems, test harnesses, and reporting tools worldwide. Use this when integrating with automated pipelines or generating test reports.
3830

3931
```
4032
not ok - 5 should equal 3.
@@ -45,6 +37,14 @@ not ok - 5 should equal 3.
4537
...
4638
```
4739

40+
### Compact
41+
42+
The **token-optimized** format for AI-assisted development. Delivers all essential information in a single line, minimizing token usage when working with AI coding assistants like Claude Code. Every character counts when you're paying per token.
43+
44+
```
45+
FAIL: 5 should equal 3. | actual=5 expected=3 | source/mytest.d:42
46+
```
47+
4848
## Setting the Output Format
4949

5050
### Environment Variable
@@ -93,11 +93,11 @@ unittest {
9393

9494
## Format Comparison
9595

96-
| Format | Use Case | Output Size |
97-
|--------|----------|-------------|
98-
| `verbose` | Development, debugging | Large |
99-
| `compact` | AI tools, log aggregation | Small |
100-
| `tap` | CI/CD, test harnesses | Medium |
96+
| Format | Audience | Use Case | Output Size |
97+
|--------|----------|----------|-------------|
98+
| `verbose` | Humans | Local development, debugging | Large |
99+
| `tap` | Machines | CI/CD pipelines, test harnesses, reporting tools | Medium |
100+
| `compact` | AI assistants | Claude Code, token-limited contexts | Small |
101101

102102
## Example Outputs
103103

docs/src/content/docs/guide/context-data.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@ void validateOrder(Order order) {
173173

174174
## Limits
175175

176-
- Context is limited to 8 key-value pairs per assertion
176+
- Context is limited to 8 key-value pairs per assertion (defined by `MAX_CONTEXT_ENTRIES`)
177177
- Keys and values are converted to strings using `std.conv.to!string`
178178
- Context is cleared between assertions
179+
- If you exceed 8 context entries, a warning is displayed in the output indicating that additional entries were dropped
179180

180181
## Next Steps
181182

0 commit comments

Comments
 (0)