-
Notifications
You must be signed in to change notification settings - Fork 20
/
test.cram
executable file
·179 lines (140 loc) · 6.63 KB
/
test.cram
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/usr/bin/env cram --indent=4
Test scspell.
$ SCSPELL="python $TESTDIR --report-only"
Test spelling mistake.
$ echo 'This is blabbb.' > bad.txt
$ $SCSPELL bad.txt
bad.txt:1: 'blabbb' not found in dictionary (from token 'blabbb')
[1]
Test okay file.
$ echo 'This is okay.' > good.txt
$ $SCSPELL good.txt
Test file with --override-dictionary and a fileid mapping entry
$ cp -a "$TESTDIR/tests" .
$ $SCSPELL --override-dictionary 'tests/fileidmap/dictionary' \
> --relative-to 'tests/fileidmap' \
> 'tests/fileidmap/inputfile.txt' 'tests/fileidmap/inputfile2.txt'
tests/fileidmap/inputfile.txt:3: 'soem' not found in dictionary (from token 'soem')
tests/fileidmap/inputfile2.txt:4: 'soem' not found in dictionary (from token 'soem')
[1]
Test file ID manipulations
$ $SCSPELL --override-dictionary tests/fileidmap/dictionary \
> --relative-to tests/fileidmap \
> tests/fileidmap/mix*
$ $SCSPELL --override-dictionary tests/fileidmap/dictionary \
> --relative-to tests/fileidmap \
> --merge-file-ids tests/fileidmap/mix4.txt tests/fileidmap/mix1.txt
$ mv tests/fileidmap/mix2.txt tests/fileidmap/mix22.txt
$ $SCSPELL --override-dictionary tests/fileidmap/dictionary \
> --relative-to tests/fileidmap \
> --rename-file tests/fileidmap/mix2.txt tests/fileidmap/mix22.txt
Switching file ID d5641cfe-3574-11e6-a3a6-10ddb1d4c3d5 from mix2.txt to mix22.txt
$ $SCSPELL --override-dictionary tests/fileidmap/dictionary \
> --relative-to tests/fileidmap \
> --delete-file tests/fileidmap/mix5.txt
Removing tests/fileidmap/mix5.txt <-> 7f72eb84-3576-11e6-a3a6-10ddb1d4c3d5 mappings
$ $SCSPELL --override-dictionary tests/fileidmap/dictionary \
> --relative-to tests/fileidmap \
> --copy-file tests/fileidmap/mix3.txt tests/fileidmap/mix33.txt
Setting mix33.txt to use mix3.txt's file ID d6ee6908-3574-11e6-a3a6-10ddb1d4c3d5.
$ diff tests/fileidmap/dictionary tests/fileidmap/dictionary.post
$ diff tests/fileidmap/dictionary.fileids.json \
> tests/fileidmap/dictionary.fileids.json.post
Base dicts tests
$ T=tests/basedicts
With all the dictionaries, clean run:
$ $SCSPELL --override-dictionary $T/dictionary \
> --use-builtin-base-dict \
> --base-dict $T/base-dictionary-1 --base-dict $T/base-dictionary-2 \
> $T/testfile
Leave out everything but the override dictionary
$ $SCSPELL --override-dictionary $T/dictionary $T/testfile
tests/basedicts/testfile:1: 'hoth' not found in dictionary (from token 'hoth')
tests/basedicts/testfile:1: 'apple' not found in dictionary (from token 'apple')
tests/basedicts/testfile:1: 'bakingsoda' not found in dictionary (from token 'bakingsoda')
tests/basedicts/testfile:2: 'perfectly' not found in dictionary (from token 'perfectly')
tests/basedicts/testfile:3: 'also' not found in dictionary (from token 'also')
tests/basedicts/testfile:3: 'yavin' not found in dictionary (from token 'yavin')
[1]
Add in just the first base dict
$ $SCSPELL --override-dictionary $T/dictionary \
> --base-dict $T/base-dictionary-1 $T/testfile
tests/basedicts/testfile:1: 'apple' not found in dictionary (from token 'apple')
tests/basedicts/testfile:1: 'bakingsoda' not found in dictionary (from token 'bakingsoda')
tests/basedicts/testfile:2: 'perfectly' not found in dictionary (from token 'perfectly')
tests/basedicts/testfile:3: 'also' not found in dictionary (from token 'also')
[1]
Filter out builtin-base-dict from base-dictionary-2
$ $SCSPELL --override-dictionary $T/base-dictionary-2 \
> --use-builtin-base-dict --filter-out-base-dicts
$ diff -u $T/base-dictionary-2 $T/base-dictionary-2.filtered
Test add file to dictionary from command line
$ SCSPELL="python $TESTDIR --override-dictionary tests/basedicts/addtodict"
$ $SCSPELL --add-to-dict p additional file.ex
Dictionary for file extension '.ex' not found.
$ $SCSPELL --add-to-dict natural myfancyword
$ $SCSPELL --add-to-dict n special
$ $SCSPELL --add-to-dict programming dizzy file.py
$ $SCSPELL --add-to-dict p juicy py
$ $SCSPELL --add-to-dict file unique file.py --relative-to .
New file ID .* for file.py (re)
$ cat tests/basedicts/addtodict
FILETYPE: Python; .py
dizzy
juicy
FILEID: .* (re)
unique
NATURAL:
myfancyword
special
Test interactive use, using --test-input instead of --report-only
$ SCSPELL="python $TESTDIR --test-input"
replace bakingsoda -> barking soda
ignore cromulent
add-natural embiggen
show context of yavin
replace/cancel-via-enter yavin
add/back yavin
ignore yavin
$ (echo rbarking soda; echo iancr; echo abi) | \
> $SCSPELL --use-builtin-base-dict --override-dictionary $T/newdict \
> $T/testfile
Warning: unable to read dictionary file 'tests/basedicts/newdict' (reason: [Errno 2] No such file or directory: 'tests/basedicts/newdict')
Continuing with empty natural dictionary
tests/basedicts/testfile:1: Unmatched 'bakingsoda' --> {bakingsoda}
(i)gnore, (I)gnore all, (r)eplace, (R)eplace all, (a)dd to dictionary, or
show (c)ontext? [i]
Replacement text for 'bakingsoda':
tests/basedicts/testfile:2: Unmatched 'cromulent' --> {cromulent}
(i)gnore, (I)gnore all, (r)eplace, (R)eplace all, (a)dd to dictionary, or
show (c)ontext? [i]
tests/basedicts/testfile:3: Unmatched 'embiggen' --> {embiggen}
(i)gnore, (I)gnore all, (r)eplace, (R)eplace all, (a)dd to dictionary, or
show (c)ontext? [i]
Subtoken 'embiggen':
(b)ack, (i)gnore, add to (n)atural language dictionary [i]
tests/basedicts/testfile:3: Unmatched 'yavin' --> {yavin}
(i)gnore, (I)gnore all, (r)eplace, (R)eplace all, (a)dd to dictionary, or
show (c)ontext? [i]
1: hoth apple barking soda
2: perfectly cromulent
3: also embiggen yavin
4:
(i)gnore, (I)gnore all, (r)eplace, (R)eplace all, (a)dd to dictionary, or
show (c)ontext? [i]
Replacement text for 'yavin': (Canceled.)
(i)gnore, (I)gnore all, (r)eplace, (R)eplace all, (a)dd to dictionary, or
show (c)ontext? [i]
Subtoken 'yavin':
(b)ack, (i)gnore, add to (n)atural language dictionary [i]
(Canceled.)
(i)gnore, (I)gnore all, (r)eplace, (R)eplace all, (a)dd to dictionary, or
show (c)ontext? [i]
[1]
$ cat $T/testfile
hoth apple barking soda
perfectly cromulent
also embiggen yavin
$ cat $T/newdict
NATURAL:
embiggen