Skip to content

Commit ca8f0aa

Browse files
committed
feat: Add unittests for handling std.range.interfaces.InputRange in should() and evaluate()
1 parent d191153 commit ca8f0aa

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

source/fluentasserts/core/base.d

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,19 @@ unittest {
8888
arr[].should.equal([1, 2, 3]);
8989
}
9090

91+
// Issue #88: std.range.interfaces.InputRange should work with should()
92+
// The unified Expect API handles InputRange interfaces as ranges
93+
@("issue #88: should works with std.range.interfaces.InputRange")
94+
unittest {
95+
import std.range.interfaces : InputRange, inputRangeObject;
96+
97+
auto arr = [1, 2, 3];
98+
InputRange!int ir = inputRangeObject(arr);
99+
100+
// InputRange interfaces are treated as ranges and converted to arrays
101+
ir.should.equal([1, 2, 3]);
102+
}
103+
91104
/// Provides a traditional assertion API as an alternative to fluent syntax.
92105
/// All methods are static and can be called as `Assert.equal(a, b)`.
93106
/// Supports negation by prefixing with "not": `Assert.notEqual(a, b)`.

source/fluentasserts/core/evaluation/eval.d

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,3 +631,19 @@ unittest {
631631
assert(result.evaluation.strValue[] == "[1, 2, 3]",
632632
"Expected '[1, 2, 3]', got '" ~ result.evaluation.strValue[].idup ~ "'");
633633
}
634+
635+
// Issue #88: std.range.interfaces.InputRange should be treated as a range
636+
// The isNonArrayRange constraint correctly identifies InputRange interfaces
637+
@("issue #88: evaluate works with std.range.interfaces.InputRange")
638+
unittest {
639+
import std.range.interfaces : InputRange, inputRangeObject;
640+
641+
auto arr = [1, 2, 3];
642+
InputRange!int ir = inputRangeObject(arr);
643+
644+
// InputRange is detected as isNonArrayRange and converted to array
645+
auto result = evaluate(ir);
646+
647+
assert(result.evaluation.strValue[] == "[1, 2, 3]",
648+
"Expected '[1, 2, 3]', got '" ~ result.evaluation.strValue[].idup ~ "'");
649+
}

0 commit comments

Comments
 (0)