Пример #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)
Пример #2
0
import wordtools
from wordtools import test
from wordtools import cleanword
from wordtools import has_dashdash
from wordtools import extract_words
from wordtools import wordcount
from wordtools import wordset
from wordtools import longestword

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(
Пример #3
0
import wordtools

print("test(wordtools.cleanword(\"what?\") == \"what\"")
wordtools.test(wordtools.cleanword("what?"), "what")

print("test(wordtools.cleanword(\"'now!'\") == \"now\"")
wordtools.test(wordtools.cleanword("'now!'"), "now")

print("test(cleanword(\"?+='w-o-r-d!,@$()'\") ==  \"word\"")
wordtools.test(wordtools.cleanword("?+='w-o-r-d!,@$()'"), "word")

print("test(has_dashdash(\"distance--but\")")
wordtools.test(wordtools.has_dashdash("distance--but"), 1)

print("test(not has_dashdash(\"several\")")
wordtools.test(wordtools.has_dashdash("spoke--"), 1)

print("test(has_dashdash(\"distance--but\")")
wordtools.test(wordtools.has_dashdash("distance--but"), 1)

print("test(not has_dashdash(\"-yo-yo-\")")
wordtools.test(wordtools.has_dashdash("-yo-yo-"), 0)

print(
    "test(extract_words(\"Now is the time!  'Now', is the time? Yes, now.\") == \['now','is','the','time','now','is','the','time','yes','now'\]"
)
wordtools.test(
    wordtools.extract_words("Now is the time!  'Now', is the time? Yes, now."),
    ['now', 'is', 'the', 'time', 'now', 'is', 'the', 'time', 'yes', 'now'])

print(
Пример #4
0
def test_has_dashdash():
    assert has_dashdash("distance--but")
    assert not has_dashdash("several")
    assert has_dashdash("spoke--")
    assert has_dashdash("distance--but")
    assert not has_dashdash("-yo-yo-")