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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
|
// Runs a slew of generic command tests
var dactyllib = require("dactyl");
var setupModule = function (module) {
controller = mozmill.getBrowserController();
dactyl = new dactyllib.Controller(controller);
dactyl.dactyl.options["autocomplete"] = [];
dactyl.dactyl.options["wildmode"] = ["list"];
dactyl.dactyl.prefs.set("browser.tabs.closeWindowWithLastTab", false);
};
var teardownModule = function (module) {
dactyl.teardown();
}
var tests = {
"!": {
multiOutput: ["echo foo"]
},
abbreviate: {
someOutput: ["", "abc"],
noOutput: ["abc def", "-js abc def"],
completions: ["", "abc ", "-js abc "]
},
abclear: {
noOutput: [""]
},
addons: {
multiOutput: ["", "dactyl", "-type=extension", "-type=extension dactyl"]
},
autocmd: {
multiOutput: ["", "DOMLoad", "DOMLoad foo"],
noOutput: ["DOMLoad foo bar", "-js DOMLoad foo bar"],
completions: ["", "DOMLoad foo ", "-js DOMLoad foo "]
},
back: { noOutput: [""] },
bdelete: {
init: ["tabopen about:pentadactyl", "tabopen about:pentadactyl"],
noOutput: [""],
anyOutput: ["about:pentadactyl"]
},
bmark: {
anyOutput: ["bmark", "bmark -tags=foo -titlt=bar -keyword=baz -charset=UTF-8 -post=quux about:pentadactyl"],
error: ["bmark -tags=foo -titlt=bar -keyword=baz -charset=nonExistentCharset -post=quux about:pentadactyl"],
completions: [
"-max=1 -keyword=",
"-max=1 -keyword=foo -tags=",
"-max=1 -keyword=foo -tags=bar -title=",
"-max=1 -keyword=foo -tags=bar -title=baz -charset=",
"-max=1 -keyword=foo -tags=bar -title=baz -charset= about:"
]
},
bmarks: {
multiOutput: ["-max=1", "-max=1 -keyword=foo -tags=bar -title=baz about:pentadactyl"],
completions: [
"-max=1 -keyword=",
"-max=1 -keyword=foo -tags=",
"-max=1 -keyword=foo -tags=bar -title=",
"-max=1 -keyword=foo -tags=bar -title=baz about:"
]
},
buffer: {
anyOutput: ["", "1"],
noOutput: ["!", "! 1"],
completions: ["", "1"]
},
buffers: {
multiOutput: ["", "1"],
completions: ["", "1"]
},
cd: {
anyOutput: ["", "~/"],
completions: ["", "~/"]
},
colorscheme: {
error: ["", "some-non-existent-scheme"]
},
command: {
anyOutput: ["", "foo", "foo bar", "-js bar baz"],
error: ["foo bar", "-js bar baz"]
},
comclear: {
noOutput: [""]
},
contexts: {}, // Not testable in this manner
cookies: {
anyOutput: ["dactyl.sf.net", "dactyl.sf.net list"],
error: [""],
completions: ["", "dactyl.sf.net "]
},
delbmarks: { anyOutput: ["", "about:pentadactyl"] },
delcommand: {
noOutput: ["foo"]
},
delmacros: {
error: [""],
noOutput: ["x"],
completions: ["", "x"]
},
delmapgroup: {}, // Skip for now
get delmarks() this.delmacros,
get delqmarks() this.delmacros,
delstyle: {
completions: [
"", "-name=", "-name=foo ", "-index=", "-index="
]
},
dialog: {
// Skip implementation for now
completions: ["", "pre"]
},
doautoall: {}, // Skip for now
doautocmd: {}, // Skip for now
downloads: {
multiOutput: ["", "dactyl", "-type=extension", "-type=extension dactyl"]
},
echo: {
singleOutput: ["' - '"],
multiOutput: ["'\\n'", "window"],
completions: [
"",
"window",
"window.",
"window['",
"commands.get('"
]
},
get echoerr() this.echo,
get echomsg() this.echo,
else: {}, // Skip for now
elseif: {}, // Skip for now
emenu: {
noOutput: ["View.Zoom.Zoom In", "View.Zoom.Zoom Out"],
error: [""],
completions: ["", "View."]
},
endif: {}, // Skip for now
execute: {
noOutput: ["", "'js " + "".quote() + "'"],
someOutput: ["'ls'"]
},
extadd: { error: [""] },
extdelete: { error: [""] },
extdisable: { error: [""] },
extenable: { error: [""] },
extoptions: { error: [""] },
extrehash: { error: [""] },
exttoggle: { error: [""] },
extupdate: { error: [""] },
feedkeys: {
noOutput: ["<Exc>"],
error: [""]
},
finish: { noOutput: [""] },
forward: { noOutput: [""] },
frameonly: { noOutput: [""] },
hardcopy: {}, // Skip for now
help: {
noOutput: ["", "intro"],
cleanup: ["tabdelete", "tabdelete"],
completions: ["", "'wild"]
},
get helpall() this.help,
highlight: {
multiOutput: ["", "Help"],
noOutput: [
"Help foo: bar;",
"Help -group=FontCode",
"Help -group=FontCode foo: bar;"
],
completions: [
"",
"Help",
"Help ",
"Help -group=",
"Help -group=FontCode ",
"Help foo: bar; -moz"
]
},
history: {
anyOutput: ["-max=1", "-max=1 -sort=+date", "-max=1 dactyl"],
completions: [
"",
"dactyl",
"-sort=+",
"-sort=-",
"-sort=+date ",
"-sort=+date dactyl"
]
},
if: {}, // Skip for now
javascript: {
noOutput: ["''", "'\\n'", "<pre>foo bar</pre>", "window"],
completions: [
"",
"window",
"window.",
"window['",
"commands.get('"
]
},
jumps: {
multiOutput: [""]
},
keepalt: {
error: [""],
noOutput: ["js ''"],
anyOutput: ["echo 'foo'"]
},
let: {}, // Deprecated. Fuck it.
listcommands: {
anyOutput: ["", "in"],
completions: ["", "in "]
},
get listkeys() this.listcommands,
get listoptions() this.listcommands,
loadplugins: {},
macros: {
multiOutput: [""]
},
map: {
multiOutput: ["", "i"],
noOutput: ["i j", "-b i j", "-js i j()", "-ex i :j"]
},
mapclear: {
noOutput: [""]
},
mapgroup: {},
mark: {},
marks: {},
messages: {},
messclear: {},
mkpentadactylrc: {},
mksyntax: {},
mlistkeys: {},
mmap: {},
mmapclear: {},
mnoremap: {},
munmap: {},
nlistkeys: {},
nmap: {},
nmapclear: {},
nnoremap: {},
nohlfind: {},
noremap: {},
normal: {},
nunmap: {},
open: {},
pageinfo: {},
pagestyle: {},
preferences: {},
pwd: {},
qmark: {},
qmarks: {},
quit: {},
quitall: {},
redraw: {},
rehash: {},
reload: {},
reloadall: {},
restart: {},
runtime: {},
sanitize: {},
saveas: {},
sbclose: {},
scriptnames: {},
set: {},
setglobal: {},
setlocal: {},
sidebar: {},
silent: {},
source: {},
stop: {},
stopall: {},
style: {},
styledisable: {},
styleenable: {},
styletoggle: {},
tab: {},
tabattach: {},
tabdetach: {},
tabdo: {},
tabduplicate: {},
tablast: {},
tabmove: {},
tabnext: {},
tabonly: {},
tabopen: {},
tabprevious: {},
tabrewind: {},
time: {},
tlistkeys: {},
tmap: {},
tmapclear: {},
tnoremap: {},
toolbarhide: {},
toolbarshow: {},
toolbartoggle: {},
tunmap: {},
unabbreviate: {},
undo: {},
undoall: {},
unlet: {},
unmap: {},
verbose: {},
version: {},
viewsource: {},
vlistkeys: {},
vmap: {},
vmapclear: {},
vnoremap: {},
vunmap: {},
winclose: {},
window: {},
winonly: {},
winopen: {},
wqall: {},
yank: {},
zoom: {}
};
var global = this;
function addTest(cmdName, testName, func) {
global["testCommand_" + cmdName + "_" + testName] = func;
}
function runCommands(cmdName, testName, commands, test) {
addTest(cmdName, testName, function () {
commands.forEach(function (cmd) {
// dump("CMD: " + cmdName + " " + cmd + "\n");
dactyl.clearMessage();
dactyl.closeMessageWindow();
cmd = cmdName + cmd.replace(/^(!?) ?/, "$1 ");
dactyl.runExCommand(cmd);
test(cmd);
});
});
}
for (var val in Iterator(tests)) (function ([command, params]) {
if (params.init)
runCommands(command, "init", params.init, function () {});
// Goddamn stupid fucking MozMill and its stupid fucking sandboxes with their ancient fucking JS versions.
for (var val in Iterator(params)) (function ([testName, commands]) {
switch (testName) {
case "noOutput":
runCommands(command, testName, commands, function (cmd) {
dactyl.assertMessage(function (msg) !msg, "Unexpected command output: " + cmd);
});
break;
case "anyOutput":
runCommands(command, testName, commands, function (cmd) {});
break;
case "someOutput":
runCommands(command, testName, commands, function (cmd) {
dactyl.assertMessage(/./, "Expected command output: " + cmd);
});
break;
case "singleOutput":
runCommands(command, testName, commands, function (cmd) {
dactyl.assertMessageLine(/./, "Expected command output: " + cmd);
});
break;
case "multiOutput":
runCommands(command, testName, commands, function (cmd) {
dactyl.assertMessageWindowOpen(true, "Expected command output: " + cmd);
});
break;
case "error":
addTest(command, testName, function () {
commands.forEach(function (cmd) {
cmd = command + cmd.replace(/^(!?) ?/, "$1 ");
dactyl.assertMessageError(function () {
dactyl.runExCommand(cmd);
}, null, [], cmd);
});
});
break;
case "completions":
addTest(command, testName, function () {
commands.forEach(function (cmd) {
dactyl.runExCompletion(command + cmd.replace(/^(!?) ?/, "$1 "));
});
});
break;
}
})(val);
if (params.cleanup)
runCommands(command, "cleanup", params.cleanup, function () {});
})(val);
// vim: sw=4 ts=8 et:
|