Beispiel #1
0
def test_suite(): #Few tests of "add_vectors" function
    test(wdt.cleanword("what?") == "what")
    test(wdt.cleanword("'now!'") == "now")
    test(wdt.cleanword("?+='w-o-r-d!,@$()'") ==  "word")
        
    test(wdt.has_dashdash("distance--but"))
    test(not wdt.has_dashdash("several"))
    test(wdt.has_dashdash("spoke--"))
    test(wdt.has_dashdash("distance--but"))
    test(not wdt.has_dashdash("-yo-yo-"))

    test(wdt.extract_words("Now is the time!  'Now', is the time? Yes, now.") == ['now','is','the','time','now','is','the','time','yes','now'])
    test(wdt.extract_words("she tried to curtsey as she spoke--fancy") == ['she','tried','to','curtsey','as','she','spoke','fancy'])

    test(wdt.wordcount("now", ["now","is","time","is","now","is","is"]) == 2)
    test(wdt.wordcount("is", ["now","is","time","is","now","the","is"]) == 3)
    test(wdt.wordcount("time", ["now","is","time","is","now","is","is"]) == 1)
    test(wdt.wordcount("frog", ["now","is","time","is","now","is","is"]) == 0)

    test(wdt.wordset(["now", "is", "time", "is", "now", "is", "is"]) == ["is", "now", "time"])
    test(wdt.wordset(["I", "a", "a", "is", "a", "is", "I", "am"]) == ["I", "a", "am", "is"])
    test(wdt.wordset(["or", "a", "am", "is", "are", "be", "but", "am"]) == ["a", "am", "are", "be", "but", "is", "or"])

    test(wdt.longestword(["a", "apple", "pear", "grape"]) == 5)
    test(wdt.longestword(["a", "am", "I", "be"]) == 2)
    test(wdt.longestword(["this","supercalifragilisticexpialidocious"]) == 34)
    test(wdt.longestword([ ]) == 0)
Beispiel #2
0
test(cleanword("what?") == "what")
test(cleanword("'now!'") == "now")
test(cleanword("?+='w-o-r-d!,@$()'") == "word")
test(has_dashdash("distance--but"))
test(not has_dashdash("several"))
test(has_dashdash("spoke--"))
test(has_dashdash("distance--but"))
test(not has_dashdash("-yo-yo-"))
test(
    extract_words("Now is the time! 'Now', is the time? Yes, now.") ==
    ['now', 'is', 'the', 'time', 'now', 'is', 'the', 'time', 'yes', 'now'])
test(
    extract_words("she tried to curtsey as she spoke--fancy") ==
    ['she', 'tried', 'to', 'curtsey', 'as', 'she', 'spoke', 'fancy'])
test(wordcount("now", ["now", "is", "time", "is", "now", "is", "is"]) == 2)
test(wordcount("is", ["now", "is", "time", "is", "now", "the", "is"]) == 3)
test(wordcount("time", ["now", "is", "time", "is", "now", "is", "is"]) == 1)
test(wordcount("frog", ["now", "is", "time", "is", "now", "is", "is"]) == 0)
test(
    wordset(["now", "is", "time", "is", "now", "is", "is"]) ==
    ["is", "now", "time"])
test(
    wordset(["I", "a", "a", "is", "a", "is", "I", "am"]) ==
    ["I", "a", "am", "is"])
test(
    wordset(["or", "a", "am", "is", "are", "be", "but", "am"]) ==
    ["a", "am", "are", "be", "but", "is", "or"])
test(longestword(["a", "apple", "pear", "grape"]) == 5)
test(longestword(["a", "am", "I", "be"]) == 2)
test(longestword(["this", "supercalifragilisticexpialidocious"]) == 34)
test(longestword([]) == 0)
Beispiel #3
0
wordtools.test(
    wordtools.wordset(["now", "is", "time", "is", "now", "is", "is"]),
    ["is", "now", "time"])

print(
    "test(wordset([\"I\", \"a\", \"a\", \"is\", \"a\", \"is\", \"I\", \"am\"]) == [\"I\", \"a\", \"am\", \"is\"]"
)
wordtools.test(wordtools.wordset(["I", "a", "a", "is", "a", "is", "I", "am"]),
               ["I", "a", "am", "is"])

print(
    "test(wordset([\"or\", \"a\", \"am\", \"is\", \"are\", \"be\", \"but\", \"am\"]) == [\"a\", \"am\", \"are\", \"be\", \"but\", \"is\", \"or\"]"
)
wordtools.test(
    wordtools.wordset(["or", "a", "am", "is", "are", "be", "but", "am"]),
    ["a", "am", "are", "be", "but", "is", "or"])

print("test(longestword([\"a\", \"apple\", \"pear\", \"grape\"]) == 5")
wordtools.test(wordtools.longestword(["a", "apple", "pear", "grape"]), 5)

print("test(longestword([\"a\", \"am\", \"I\", \"be\"]) == 2")
wordtools.test(wordtools.longestword(["a", "am", "I", "be"]), 2)

print(
    "test(longestword([\"this\",\"supercalifragilisticexpialidocious\"]) == 34"
)
wordtools.test(
    wordtools.longestword(["this", "supercalifragilisticexpialidocious"]), 34)

print("test(longestword([ ]) == 0")
wordtools.test(wordtools.longestword([]), 0)
Beispiel #4
0
def test_longestword():
    assert longestword(["a", "apple", "pear", "grape"]) == 5
    assert longestword(["a", "am", "I", "be"]) == 2
    assert longestword(["this", "supercalifragilisticexpialidocious"]) == 34
    assert longestword([]) == 0