Sha256: 5731b068ec09477cd73d7fca44782acbca6634b8a44b2ba0b86b2addd079443e

Contents?: true

Size: 1.75 KB

Versions: 76

Compression:

Stored size: 1.75 KB

Contents

import ceylon.test { ... }

{[String, {String*}, {String*}]*} cases => {
  // no matches
  ["diaper", {"hello", "world", "zombies", "pants"}, {}],
  // detects simple anagram
  ["ant", {"tan", "stand", "at"}, {"tan"}],
  // does not detect false positives
  ["galea", {"eagle"}, {}],
  // detects multiple anagrams
  ["master", {"stream", "pigeon", "maters"}, {"stream", "maters"}],
  // does not detect anagram subsets
  ["good", {"dog", "goody"}, {}],
  // detects anagram
  ["listen", {"enlists", "google", "inlets", "banana"}, {"inlets"}],
  // detects multiple anagrams
  [
    "allergy",
    {"gallery", "ballerina", "regally", "clergy", "largely", "leading"},
    {"gallery", "regally", "largely"}
  ],
  // does not detect identical words
  ["corn", {"corn", "dark", "Corn", "rank", "CORN", "cron", "park"}, {"cron"}],
  // does not detect non-anagrams with identical checksum
  ["mass", {"last"}, {}],
  // detects anagrams case-insensitively
  ["Orchestra", {"cashregister", "Carthorse", "radishes"}, {"Carthorse"}],
  // detects anagrams using case-insensitive subject
  ["Orchestra", {"cashregister", "carthorse", "radishes"}, {"carthorse"}],
  // detects anagrams using case-insensitive possible matches
  ["orchestra", {"cashregister", "Carthorse", "radishes"}, {"Carthorse"}],
  // does not detect a word as its own anagram
  ["banana", {"Banana"}, {}],
  // does not detect a anagram if the original word is repeated
  ["go", {"go Go GO"}, {}],
  // anagrams must use all letters exactly once
  ["tapper", {"patter"}, {}],
  // capital word is not own anagram
  ["BANANA", {"Banana"}, {}]
};

test
parameters(`value cases`)
void testAnagram(String subject, {String*} candidates, {String*} expected) {
  assertEquals(sort(anagrams(subject, candidates)), sort(expected));
}

Version data entries

76 entries across 76 versions & 1 rubygems

Version Path
trackler-2.0.8.43 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.42 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.41 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.40 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.39 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.38 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.37 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.36 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.35 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.34 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.33 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.32 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.31 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.30 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.29 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.28 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.27 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.26 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.24 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.0.8.23 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon