Ship

Files · src/Text.shp

src/Text.shp

examples/003-utility-functionsRaw
1234567891011
let surroundsurround: pure fn!(value: String, prefix: String, suffix: String) -> String = (valuevalue: String, prefixprefix: String, suffixsuffix: String) => prefixprefix: String ++ valuevalue: String ++ suffixsuffix: String;
let has_prefixhas_prefix: pure fn!(value: String, prefix: String) -> Bool = (valuevalue: String, prefixprefix: String) => String.starts_withstarts_with: pure fn!(string: String, needle: String) -> Bool(valuevalue: String, prefixprefix: String);

test "surround composes delimiters" {
  expect surroundsurround: pure fn!(value: String, prefix: String, suffix: String) -> String("ship""ship": String, "[""[": String, "]""]": String) == "[ship]""[ship]": String;
}

test "has_prefix checks the beginning only" {
  expect has_prefixhas_prefix: pure fn!(value: String, prefix: String) -> Bool("shipping""shipping": String, "ship""ship": String);
  expect has_prefixhas_prefix: pure fn!(value: String, prefix: String) -> Bool("shipping""shipping": String, "ping""ping": String) == FalseFalse: Bool;
}