add taskAssert computation expression for simplified assertions in F# - #3977
Conversation
Code Review: F# taskAssert Computation ExpressionThank you for this contribution! This is a clean and idiomatic F# enhancement that significantly improves the assertion experience for F# users. Here's my detailed review: ✅ Strengths1. Excellent F# Idioms
2. Clean Implementation
3. Good Documentation
4. Comprehensive Test Coverage
🔍 Observations & Minor Suggestions1. Test Duplication
I recommend Option A for this PR since:
2. Performance Considerations
✅ No performance concerns identified 3. Type Signature Clarity member inlinex.Bind(assertion:IAssertion,continuation:Unit ->TaskCode<'TOverall,'TResult2>)The 🛡️ Security & Safety✅ No security concerns
📋 Checklist (Based on CLAUDE.md)Let me verify against the project's requirements:
🎯 Final AssessmentRecommendation: ✅ APPROVE with minor suggestion This PR is well-implemented and ready to merge. The code is:
Optional Enhancement (Non-blocking)Consider adding one additional test case demonstrating assertion failure behavior to ensure the CE properly propagates exceptions: [<Test>][<Category("Fail")>]member_.FailingAssertion_ThrowsCorrectly():Task =
taskAssert {do! Assert.That(1+1).IsEqualTo(3)// Should fail}This would verify the error handling path works correctly, though it's likely already covered by existing assertion tests. Great work, @marcpiechura! This is a valuable addition to TUnit's F# support. 🎉 |
thomhurst
commented
Dec 4, 2025
Thanks @marcpiechura ! Do you mind adding the negative assertion test as suggested by Claude? So we can confirm it correctly throws if an assertion fails. |
marcpiechura
commented
Dec 5, 2025
Sure thing, I've added the test. |
Uh oh!
There was an error while loading. Please reload this page.
As discussed, I've used the new taskAssert expression in all of my tests and it's working as expected, so I think it's good to go.
closes#3971