summaryrefslogtreecommitdiff
path: root/spellcheck/spellcheck-test.scm
blob: 438384ddaa2ff118d76449472ea19927e9b74b62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
(use-modules (srfi srfi-64)
             (dictionary)
             (mutate))

(define simple-dict (create-dictionary '("word")))
(define complex-dict (create-dictionary '("Again" "the" "thirst"
                                          "quencher" "of" "wolves"
                                          "embarked" "on" "a" "well"
                                          "prepared" "expedition"
                                          "eastward" "the" "generous"
                                          "ruler" "moved" "the" "bitter"
                                          "heart" "of" "the" "snake"
                                          "across" "the" "fire")))

(test-begin "dictionary")


(test-assert "create-dictionary returns hashtable"
  (hash-table?
   (create-dictionary '())))

(define dict (create-dictionary '("word")))

(test-equal "list-keys-single"
  '("word")
  (dict-keys-ref simple-dict))

(test-equal "count-values-single"
  1
  (dict-values-ref simple-dict))


(test-equal "retrieve single"
  1
  (dict-occur-ref complex-dict "wolves"))

(test-equal "retrieve double"
  2
  (dict-occur-ref complex-dict "of"))

(test-equal "retrieve quintuple"
  5
  (dict-occur-ref complex-dict "the"))

(test-equal "retrieve zero"
  0
  (dict-occur-ref complex-dict "king"))

(test-equal "list-keys-sentence"
  '("Again" "a" "across" "bitter" "eastward" "embarked" "expedition" "fire" "generous" "heart" "moved" "of" "on" "prepared" "quencher" "ruler" "snake" "the" "thirst" "well" "wolves")
  (sort (dict-keys-ref complex-dict) string<?))

(test-equal "count-values-sentence"
  26
  (dict-values-ref complex-dict))


(test-end "dictionary")

(test-begin "mutate")


(test-equal "test deletes six"
  '("ix" "sx" "si")
  (deletes "six"))

(test-equal "test transposes"
  '("isx" "sxi")
  (transposes "six"))

(test-equal "test replaces"
  '("aix" "bix" "cix" "dix" "eix" "fix" "gix" "hix" "iix" "jix" "kix" "lix" "mix" "nix" "oix" "pix" "qix" "rix" "six" "tix" "uix" "vix" "wix" "xix" "yix" "zix" "sax" "sbx" "scx" "sdx" "sex" "sfx" "sgx" "shx" "six" "sjx" "skx" "slx" "smx" "snx" "sox" "spx" "sqx" "srx" "ssx" "stx" "sux" "svx" "swx" "sxx" "syx" "szx" "sia" "sib" "sic" "sid" "sie" "sif" "sig" "sih" "sii" "sij" "sik" "sil" "sim" "sin" "sio" "sip" "siq" "sir" "sis" "sit" "siu" "siv" "siw" "six" "siy" "siz")
  (replaces "six"))

(test-equal "test inserts"
  '("asix" "bsix" "csix" "dsix" "esix" "fsix" "gsix" "hsix" "isix" "jsix" "ksix" "lsix" "msix" "nsix" "osix" "psix" "qsix" "rsix" "ssix" "tsix" "usix" "vsix" "wsix" "xsix" "ysix" "zsix" "saix" "sbix" "scix" "sdix" "seix" "sfix" "sgix" "shix" "siix" "sjix" "skix" "slix" "smix" "snix" "soix" "spix" "sqix" "srix" "ssix" "stix" "suix" "svix" "swix" "sxix" "syix" "szix" "siax" "sibx" "sicx" "sidx" "siex" "sifx" "sigx" "sihx" "siix" "sijx" "sikx" "silx" "simx" "sinx" "siox" "sipx" "siqx" "sirx" "sisx" "sitx" "siux" "sivx" "siwx" "sixx" "siyx" "sizx" "sixa" "sixb" "sixc" "sixd" "sixe" "sixf" "sixg" "sixh" "sixi" "sixj" "sixk" "sixl" "sixm" "sixn" "sixo" "sixp" "sixq" "sixr" "sixs" "sixt" "sixu" "sixv" "sixw" "sixx" "sixy" "sixz")
  (inserts "six"))


(test-end "mutate")