OxL Справочник OxL
РусскийEnglish

tests/count_test.oxl

oxl
use super.count { countWords, top }

test "words are counted case-insensitively" {
  let c = countWords("The cat and THE dog and the bird")
  assert_eq(c.get("the") ?? 0, 3)
  assert_eq(c.get("and") ?? 0, 2)
  assert c.get("a") is none
}

test "top lists the most frequent first" {
  let c = countWords("red red red blue blue green")
  assert_eq(top(c, 2), ["red: 3", "blue: 2"])
}

Исходник: examples/wordcount/tests/count_test.oxl