mirror of
https://github.com/typeable/nixpkgs.git
synced 2024-09-11 11:57:32 +03:00
Merge pull request #170090 from danth/has-infix-toString
lib/strings: call toString within hasInfix
This commit is contained in:
commit
761c21a16a
@ -254,7 +254,7 @@ rec {
|
||||
=> false
|
||||
*/
|
||||
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).
|
||||
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
|
||||
|
||||
testFilter = {
|
||||
|
Loading…
Reference in New Issue
Block a user