Sha256: 3d3ba85f9ca62130c753e39b01e26e45a1416e59b1bb69990a78da5e3e413e85

Contents?: true

Size: 1.58 KB

Versions: 63

Compression:

Stored size: 1.58 KB

Contents

import ceylon.test {
    ...
}

// Tests adapted from problem-specifications version 1.2.0

{[String, {String*}, {String*}]*} cases => {
    // no matches
    ["diaper", { "hello", "world", "zombies", "pants" }, {}],
    // 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 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 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

63 entries across 63 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.179 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.178 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.177 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.176 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.175 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.174 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.173 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.172 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.171 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.170 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.169 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.167 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.166 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.165 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.164 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.163 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.162 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.161 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon
trackler-2.2.1.160 tracks/ceylon/exercises/anagram/source/anagram/AnagramTest.ceylon