Make new tests documented

This commit is contained in:
Nick Treleaven 2023-11-06 17:27:53 +00:00
parent a2c2f79dfa
commit edc5bbde7b

View file

@ -2588,6 +2588,10 @@ template canFind(alias pred="a == b")
assert(!canFind(arr, 4));
// find one of several needles
assert(arr.canFind(3, 2));
assert(arr.canFind(3, 2) == 2); // second needle found
assert(arr.canFind([1, 3], 2) == 2);
assert(canFind(arr, [1, 2], [2, 3]));
assert(canFind(arr, [1, 2], [2, 3]) == 1);
assert(canFind(arr, [1, 7], [2, 3]));
@ -2596,13 +2600,6 @@ template canFind(alias pred="a == b")
assert(canFind(arr, [1, 3], [2, 4]) == 0);
}
// More multiple needles
@safe unittest
{
assert([1, 2, 3].canFind(3, 2) == 2);
assert([1, 2, 3].canFind([1, 3], 2) == 2);
}
/**
* Example using a custom predicate.
* Note that the needle appears as the second argument of the predicate.