# file      : tests/function/string/testscript
# license   : MIT; see accompanying LICENSE file

.include ../../common.testscript

: icasecmp
:
{
  : equal
  :
  {
    $* <'print $icasecmp([string] "a", [string] "A")' >'true' : string-string
    $* <'print $icasecmp([string] "a", "A")'          >'true' : string-untyped
    $* <'print $icasecmp("a", [string] "A")'          >'true' : untyped-string
    $* <'print $string.icasecmp("a", "A")'            >'true' : untyped-untyped
  }

  : different
  :
  {
    $* <'print $icasecmp([string] "a", [string] "b")' >'false' : string-string
    $* <'print $icasecmp([string] "a", "b")'          >'false' : string-untyped
    $* <'print $icasecmp("a", [string] "b")'          >'false' : untyped-string
    $* <'print $string.icasecmp("a", "b")'            >'false' : untyped-untyped
  }
}

: trim
:
{
  $* <'print $trim([string] "  a  ")' >'a' : string
  $* <'print $string.trim(  "  a  ")' >'a' : untyped
}

: sort
:
{
  $* <'print $sort([strings] a c b a)'        >'a a b c' : basics
  $* <'print $sort([strings] a c b a, dedup)' >'a b c'   : dedup
  $* <'print $sort([strings] a C B a, icase)' >'a a B C' : icase
}

: size
:
{
  $* <'print $size([string] abc)' >'3' : basics
  $* <'print $size([string] )'    >'0' : zero
}

: find
:
{
  $* <'print $find([strings] x y z, y)'        >'true'  : basics-true
  $* <'print $find([strings] x y z, Y)'        >'false' : basics-false
  $* <'print $find([strings] x y z, Y, icase)' >'true'  : icase
}

: find_index
:
{
  $* <'print $find_index([strings] x y z, y)'        >'1' : basics-true
  $* <'print $find_index([strings] x y z, Y)'        >'3' : basics-false
  $* <'print $find_index([strings] x y z, Y, icase)' >'1' : icase
}
