Merge pull request #170090 from danth/has-infix-toString
lib/strings: call toString within hasInfix
This commit is contained in:
@@ -254,7 +254,7 @@ rec {
|
|||||||
=> false
|
=> false
|
||||||
*/
|
*/
|
||||||
hasInfix = infix: content:
|
hasInfix = infix: content:
|
||||||
builtins.match ".*${escapeRegex infix}.*" content != null;
|
builtins.match ".*${escapeRegex infix}.*" "${content}" != null;
|
||||||
|
|
||||||
/* Convert a string to a list of characters (i.e. singleton strings).
|
/* Convert a string to a list of characters (i.e. singleton strings).
|
||||||
This allows you to, e.g., map a function over each character. However,
|
This allows you to, e.g., map a function over each character. However,
|
||||||
|
|||||||
@@ -280,6 +280,36 @@ runTests {
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
testHasInfixFalse = {
|
||||||
|
expr = hasInfix "c" "abde";
|
||||||
|
expected = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
testHasInfixTrue = {
|
||||||
|
expr = hasInfix "c" "abcde";
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
testHasInfixDerivation = {
|
||||||
|
expr = hasInfix "hello" (import ../.. { system = "x86_64-linux"; }).hello;
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
testHasInfixPath = {
|
||||||
|
expr = hasInfix "tests" ./.;
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
testHasInfixPathStoreDir = {
|
||||||
|
expr = hasInfix builtins.storeDir ./.;
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
testHasInfixToString = {
|
||||||
|
expr = hasInfix "a" { __toString = _: "a"; };
|
||||||
|
expected = true;
|
||||||
|
};
|
||||||
|
|
||||||
# LISTS
|
# LISTS
|
||||||
|
|
||||||
testFilter = {
|
testFilter = {
|
||||||
|
|||||||
Reference in New Issue
Block a user