Files
mercury/tests/hard_coded/string_contains_match.exp
Julien Fischer ae0525af53 Add string.contains_match/2.
Add a new predicate that tests if string contains any characters that succeed
for a given test predicate.

library/string.m:
    Add the new predicate.

compiler/options.m:
    Replace the predicate string_contains_whitespace/1 defined here
    with a call to the new library predicate.

NEWS:
    Announce the new predicate.

tests/hard_coded/Mmakefile:
tests/hard_coded/string_contains_match.{m,exp}:
    Add a test of the new predicate.
2022-07-25 19:38:01 +10:00

10 lines
561 B
Plaintext

contains_match(is_whitespace, "") ==> false.
contains_match(is_whitespace, "abc") ==> false.
contains_match(is_whitespace, " abc") ==> true.
contains_match(is_whitespace, "a bc") ==> true.
contains_match(is_whitespace, "abc ") ==> true.
contains_match(is_whitespace, "μῆνιν ἄειδε θεὰ Πηληϊάδεω Ἀχιλῆος") ==> true.
contains_match(is_chess_piece, "♜ ♞ ♝ ♛ ♚ ♝ ♞ ♜") ==> true.
contains_match(is_chess_piece, "abc♜ def") ==> true.
contains_match(is_chess_piece, "no chess pieces here!") ==> false.