Sha256: 7e7803c30bfbe0abd857cb43d1c27c853bea4263b1cd84fb108105eb3f6acae7

Contents?: true

Size: 1.8 KB

Versions: 58

Compression:

Stored size: 1.8 KB

Contents

import ceylon.test { ... }

// Tests adapted from problem-specifications version 1.0.1
{[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 two anagrams
  ["master", {"stream", "pigeon", "maters"}, {"stream", "maters"}],
  // does not detect anagram subsets
  ["good", {"dog", "goody"}, {}],
  // detects anagram
  ["listen", {"enlists", "google", "inlets", "banana"}, {"inlets"}],
  // detects three 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

58 entries across 58 versions & 1 rubygems

Version Path
trackler-2.2.1.88 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.87 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.86 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.85 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.84 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.83 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.82 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.81 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.80 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.79 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.78 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.77 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.76 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.75 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.74 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.73 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.72 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.71 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.70 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.69 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon