From ab7ad88b21ba6209727fd48fa55c611fd2954de4 Mon Sep 17 00:00:00 2001 From: Doug Kearns Date: Wed, 29 Jun 2011 20:11:22 +1000 Subject: [PATCH] Clarify some arg counts and some related tests. --HG-- extra : rebase_source : e50c757b46406988b0bfa0c179ec1e9bad21a446 --- common/content/dactyl.js | 6 +- common/content/events.js | 1 + common/content/tabs.js | 8 +- common/modules/commands.jsm | 1 + common/modules/io.jsm | 2 +- common/modules/javascript.jsm | 1 + common/tests/functional/testCommands.js | 269 +++++++++++++++++++----- pentadactyl/content/config.js | 2 +- teledactyl/content/mail.js | 4 +- 9 files changed, 228 insertions(+), 66 deletions(-) diff --git a/common/content/dactyl.js b/common/content/dactyl.js index f025ab4b..9aea3b2e 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -1886,7 +1886,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { util.rehash(args); }, { - argCount: "0", + argCount: "0", // FIXME options: [ { names: ["+u"], @@ -2024,7 +2024,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { dactyl.echoerr(e); } }, { - argCount: "+", + argCount: "1", bang: true, completer: function (context) { if (/^:/.test(context.filter)) @@ -2055,7 +2055,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { vbs.setFrom = setFrom; } }, { - argCount: "+", + argCount: "1", completer: function (context) completion.ex(context), count: true, literal: 0, diff --git a/common/content/events.js b/common/content/events.js index c3c1ebd5..095d0b8f 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -1620,6 +1620,7 @@ var Events = Module("events", { else dactyl.echoerr(_("error.argumentRequired")); }, { + argCount: "?", bang: true, completer: function (context) completion.macro(context), literal: 0 diff --git a/common/content/tabs.js b/common/content/tabs.js index 2d41525d..65147f8e 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -621,16 +621,14 @@ var Tabs = Module("tabs", { commands.add(["keepa[lt]"], "Execute a command without changing the current alternate buffer", function (args) { - let alternate = tabs.alternate; - try { dactyl.execute(args[0], null, true); } finally { - tabs.updateSelectionHistory([tabs.getTab(), alternate]); + tabs.updateSelectionHistory([tabs.getTab(), tabs.alternate]); } }, { - argCount: "+", + argCount: "1", completer: function (context) completion.ex(context), literal: 0, subCommand: 0 @@ -644,7 +642,7 @@ var Tabs = Module("tabs", { dactyl.execute(args[0], null, true); }); }, { - argCount: "+", + argCount: "1", completer: function (context) completion.ex(context), literal: 0, subCommand: 0 diff --git a/common/modules/commands.jsm b/common/modules/commands.jsm index a3c388c5..d0ef2455 100644 --- a/common/modules/commands.jsm +++ b/common/modules/commands.jsm @@ -1596,6 +1596,7 @@ var Commands = Module("commands", { dactyl.echomsg(_("command.yank.yankedLine" + (lines == 1 ? "" : "s"), lines)); }, { + argCount: "1", completer: function (context) modules.completion[/^:/.test(context.filter) ? "ex" : "javascript"](context), literal: 0 }); diff --git a/common/modules/io.jsm b/common/modules/io.jsm index c265eea2..53bc9257 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -841,7 +841,7 @@ unlet s:cpo_save modules.autocommands.trigger("ShellCmdPost", {}); }, { - argCount: "?", // TODO: "1" - probably not worth supporting weird Vim edge cases. The dream is dead. --djk + argCount: "1", bang: true, // This is abominably slow. // completer: function (context) completion.shellCommand(context), diff --git a/common/modules/javascript.jsm b/common/modules/javascript.jsm index 686d81b2..d1098247 100644 --- a/common/modules/javascript.jsm +++ b/common/modules/javascript.jsm @@ -842,6 +842,7 @@ var JavaScript = Module("javascript", { .open(); } }, { + argCount: "?", bang: true, completer: function (context) modules.completion.javascript(context), hereDoc: true, diff --git a/common/tests/functional/testCommands.js b/common/tests/functional/testCommands.js index 555ee663..45e65e7f 100644 --- a/common/tests/functional/testCommands.js +++ b/common/tests/functional/testCommands.js @@ -45,14 +45,25 @@ function toolbarState(selector, state) var tests = { "!": { + error: [""], multiOutput: ["echo foo"] }, + get Clistkeys() this.listcommands, + Cmap: {}, + Cnoremap: {}, + Cunmap: {}, + get Ilistkeys() this.listcommands, + Imap: {}, + Inoremap: {}, + Iunmap: {}, abbreviate: { + error: ["!"], someOutput: ["", "abc"], noOutput: ["abc def", "-js abc def"], completions: ["", "abc ", "-js abc "] }, addons: { + error: ["!"], multiOutput: ["", "dactyl", "-type=extension", "-type=extension dactyl"], completions: [ "", @@ -75,6 +86,8 @@ var tests = { anyOutput: ["about:pentadactyl"], completions: [["", hasItems]] }, + get blistkeys() this.listcommands, + bmap: {}, bmark: { singleOutput: ["", "-tags=foo -title=bar -keyword=baz -charset=UTF-8 -post=quux about:pentadactyl"], error: ["-tags=foo -title=bar -keyword=baz -charset=nonExistentCharset -post=quux about:pentadactyl"], @@ -95,6 +108,7 @@ var tests = { "-max=1 -keyword=foo -tags=bar -title=baz about:" ] }, + bnoremap: {}, buffer: { anyOutput: ["", "1"], noOutput: ["!", "! 1"], @@ -104,15 +118,21 @@ var tests = { ] }, buffers: { + error: ["!"], multiOutput: ["", "1"], completions: ["", "1"] }, + bunmap: {}, cd: { + error: ["!"], singleOutput: ["", "~/"], completions: ["", "~/"] }, + get clistkeys() this.listcommands, + cmap: {}, + cnoremap: {}, colorscheme: { - error: ["", "some-nonexistent-scheme"] + error: ["!", "", "some-nonexistent-scheme"] }, command: { init: ["delc!"], @@ -131,15 +151,22 @@ var tests = { ["-group=user ", hasItems] ] }, - contexts: {}, // Not testable in this manner + completions: { + error: ["!", ""] + }, + contexts: { // Not testable in this manner + error: ["!"] + }, cookies: { anyOutput: ["dactyl.sf.net", "dactyl.sf.net list"], - error: [""], + error: ["!", ""], completions: [ "", ["dactyl.sf.net ", hasItems] ] }, + cunabbreviate: {}, + cunmap: {}, delbmarks: { anyOutput: ["", "about:pentadactyl"] }, delcommand: [ { @@ -157,8 +184,12 @@ var tests = { error: ["foo"] } ], + delgroup: { + error: ["!", "", "builtin"], + completions: [""] + }, delmacros: { - error: [""], + error: ["", "! foo"], noOutput: ["x"], completions: ["", "x"] }, @@ -168,17 +199,27 @@ var tests = { completions: ["", "-name=", "-name=foo ", "-index=", "-index="] }, dialog: { + error: ["!", ""], // Skip implementation for now completions: [ ["", hasntNullItems] ] }, - doautoall: {}, // Skip for now - doautocmd: {}, // Skip for now + dlclear: { + error: ["!"] + }, + doautoall: { + error: ["!"] + }, + doautocmd: { + error: ["!"] + }, downloads: { + error: ["!"], multiOutput: ["", "dactyl", "dactyl"] }, echo: { + error: ["!"], singleOutput: [ ["' - '", " - "] ], @@ -199,25 +240,35 @@ var tests = { __proto__: this.echo, }), get echomsg() this.echo, - else: {}, // Skip for now - elseif: {}, // Skip for now + else: { + error: ["!", "foo"] + }, + elseif: { + error: ["!", ""] + }, emenu: { noOutput: ["View.Zoom.Zoom In", "View.Zoom.Zoom Out"], - error: [""], + error: ["!", ""], completions: [ ["", hasItems], ["View.", hasItems] ] }, - endif: {}, // Skip for now + endif: { + error: ["!", "foo"] + }, execute: { + error: ["!"], noOutput: ["", "'js " + "".quote() + "'"], someOutput: ["'ls'"], completions: [["", hasItems]] }, + exit: { + error: ["foo"] + }, extadd: { completions: [["", hasItems]], - error: [""] + error: ["!", ""] }, extdelete: { completions: [["", hasItems]], @@ -239,12 +290,14 @@ var tests = { noOutput: [""], error: [""] }, - finish: { noOutput: [""] }, + finish: { + error: ["!", "foo"], + noOutput: [""] + }, forward: { noOutput: [""] }, - frameonly: { noOutput: [""] }, - delgroup: { - error: ["builtin"], - completions: [""] + frameonly: { + error: ["!", "foo"], + noOutput: [""] }, group: { multiOutput: [""], @@ -263,6 +316,7 @@ var tests = { }, hardcopy: {}, // Skip for now help: { + error: ["!"], noOutput: ["", "intro"], cleanup: ["tabdelete", "tabdelete"], completions: [ @@ -272,6 +326,7 @@ var tests = { }, get helpall() this.help, highlight: { + error: ["!"], multiOutput: ["", "Help"], noOutput: [ "Help foo: bar;", @@ -299,7 +354,15 @@ var tests = { "-sort=+date about:" ] }, - if: {}, // Skip for now + if: { + error: ["!", ""], + }, + iabbreviate: {}, + get ilistkeys() this.listcommands, + imap: {}, + inoremap: {}, + iunabbreviate: {}, + iunmap: {}, javascript: { noOutput: ["''", "'\\n'", "
foo bar
", "window", "<"], singleOutput: [""], multiOutput: ["g"] }, + nunmap: {}, open: { + error: ["!"], noOutput: ["about:blank | about:home"], completions: [ ["", hasItems], @@ -443,13 +527,18 @@ var tests = { pageinfo: { multiOutput: ["", "fgm"], completions: [["", hasItems]], - error: ["abcdefghijklmnopqrstuvwxyz", "f g m"] + error: ["!", "abcdefghijklmnopqrstuvwxyz", "f g m"] }, pagestyle: { + error: ["!"], completions: [""] }, - preferences: {}, // Skip for now + pintab: {}, + preferences: { + error: ["foo"] + }, pwd: { + error: ["!", "foo"], singleOutput: [""] }, qmark: { @@ -457,13 +546,16 @@ var tests = { "m", "m foo bar" ], - error: ["", "#"], + error: ["!", "", "#"], completions: [ ["", hasItems], ["m ", hasItems] ] }, qmarks: [ + { + error: ["!"] + }, { init: ["delqmarks a-zA-Z0-9"], error: ["", "x"], @@ -474,20 +566,29 @@ var tests = { completions: [["", hasItems]] } ], - quit: {}, // Skip for now - quitall: {}, // Skip for now + quit: { + error: ["foo"] + }, + quitall: { + error: ["!", "foo"] + }, redraw: { + error: ["!", "foo"], noOutput: [""] }, - rehash: {}, // Skip for now + rehash: { + error: ["!"] + }, reload: { + error: ["foo"], noOutput: [""] }, reloadall: { + error: ["foo"], noOutput: [""] }, restart: { - error: ["foo"] + error: ["!", "foo"] }, runtime: { init: [ @@ -504,6 +605,7 @@ var tests = { "some-nonexistent/good.penta" ], error: [ + "", "some-nonexistent/bad.js", "some-nonexistent/bad.penta" ], @@ -542,9 +644,12 @@ var tests = { }, saveas: {}, sbclose: { + error: ["!", "foo"], noOutput: [""] }, - scriptnames: {}, + scriptnames: { + error: ["!", "foo"] + }, set: { multiOutput: [ "vb?", "cpt?", "messages?", "titlestring?", "au?", "eht?", @@ -598,6 +703,7 @@ var tests = { ] }, silent: { + error: ["!"], noOutput: [ "echo 'foo'", "echo " + "foo\nbar".quote(), @@ -616,6 +722,7 @@ var tests = { ".pentadactyl/some-nonexistent/good.penta" ], error: [ + "", ".pentadactyl/some-nonexistent/really-nonexistent.js", "~/.pentadactyl/some-nonexistent/bad.js", "~/.pentadactyl/some-nonexistent/bad.penta", @@ -632,9 +739,16 @@ var tests = { ["resource://dactyl/", hasItems] ] }), - stop: { noOutput: [""] }, - stopall: { noOutput: [""] }, + stop: { + error: ["!", "foo"], + noOutput: [""] + }, + stopall: { + error: ["!", "foo"], + noOutput: [""] + }, style: { + error: ["!"], cleanup: ["delstyle -n foo"], noOutput: [ "-name=foo http://does.not.exist/* div { display: inline; }", @@ -675,21 +789,29 @@ var tests = { ] }, tab: { - error: ["", "some-nonexistent-command"], + error: ["!", "", "some-nonexistent-command"], noOutput: ["js ''"], anyOutput: ["echo 'foo'"], completions: [["", hasItems]] }, - tabattach: {}, - tabdetach: {}, + tabattach: { + error: ["!", ""] + }, + tabdetach: { + error: ["!", "foo"] + }, tabdo: { - error: ["", "some-nonexistent-command"], + error: ["!", "", "some-nonexistent-command"], noOutput: ["js ''"], anyOutput: ["echo 'foo'"], completions: [["", hasItems]] }, - tabduplicate: {}, - tablast: {}, + tabduplicate: { + error: ["foo"] + }, + tablast: { + error: ["!", "foo"] + }, tabmove: { error: [""], noOutput: ["1", "$", "999", "-1", "+1", "! +1", "! -1", "-999", "+999", "! +999", "! -999"], @@ -698,16 +820,27 @@ var tests = { ["1", hasItems] ] }, - tabnext: {}, - tabonly: {}, + tabnext: { + error: ["!", "foo"] + }, + tabonly: { + error: ["!", "foo"] + }, tabopen: {}, - tabprevious: {}, - tabrewind: {}, + tabprevious: { + error: ["!", "foo"] + }, + tabrewind: { + error: ["!", "foo"] + }, time: { error: ["", ":some-nonexistent-command"/*, "some_nonexistent_reference"*/], // FIXME singleOutput: [":js null", "null"] }, + get tlistkeys() this.listcommands, + tmap: {}, + tnoremap: {}, toolbarhide: { init: [ ["tbs Navigation Toolbar", toolbarState("#nav-bar", true)], @@ -718,7 +851,7 @@ var tests = { ["Navigation Toolbar", toolbarState("#nav-bar", false)], ["Bookmarks Toolbar", toolbarState("#PersonalToolbar", false)] ], - error: ["", "foo"] + error: ["!", "", "foo"] }, toolbarshow: { completions: [["", hasItems]], @@ -726,7 +859,7 @@ var tests = { ["Navigation Toolbar", toolbarState("#nav-bar", true)], ["Bookmarks Toolbar", toolbarState("#PersonalToolbar", true)] ], - error: ["", "foo"] + error: ["!", "", "foo"] }, toolbartoggle: { completions: [["", hasItems]], @@ -738,15 +871,25 @@ var tests = { ["Navigation Toolbar", toolbarState("#nav-bar", false)], ["Bookmarks Toolbar", toolbarState("#PersonalToolbar", false)] ], - error: ["", "foo"] + error: ["!", "", "foo"] }, + tunmap: {}, unabbreviate: { noOutput: ["abc", "! "], error: [""] }, - undo: {}, - undoall: {}, - unlet: {}, + undo: { + error: ["!"] + }, + undoall: { + error: ["!", "foo"] + }, + unpintab: { + error: ["!"] + }, + unlet: { + error: [""], + }, unmap: { noOutput: [ "i", @@ -762,8 +905,11 @@ var tests = { "-group=" ] }, - verbose: {}, + verbose: { + error: ["!", ""] + }, version: { + error: ["foo"], multiOutput: [ ["", function (msg) { var res = /(\w+dactyl) (\S+) \(([\^)]+)\) running on:\nMozilla/; @@ -772,11 +918,25 @@ var tests = { ] }, viewsource: {}, - winclose: {}, - window: {}, - winonly: {}, - winopen: {}, - wqall: {}, + get vlistkeys() this.listcommands, + vmap: {}, + vnoremap: {}, + vunmap: {}, + winclose: { + error: ["!", "foo"] + }, + window: { + error: ["!", ""] + }, + winonly: { + error: ["!", "foo"] + }, + winopen: { + error: ["!"] + }, + wqall: { + error: ["!", "foo"] + }, yank: { multiOutput: [ ["foo".quote(), /foo/], @@ -784,6 +944,7 @@ var tests = { [":addons", /Pentadactyl/] ], error: [ + "!", "", ":echoerr " + "foo".quote() ], completions: [ diff --git a/pentadactyl/content/config.js b/pentadactyl/content/config.js index f235982f..6b067005 100644 --- a/pentadactyl/content/config.js +++ b/pentadactyl/content/config.js @@ -248,7 +248,7 @@ var Config = Module("config", ConfigBase, { }); }, { - argCount: "+", + argCount: "1", completer: function (context) completion.ex(context), literal: 0, subCommand: 0 diff --git a/teledactyl/content/mail.js b/teledactyl/content/mail.js index 9a6da8a9..56531474 100644 --- a/teledactyl/content/mail.js +++ b/teledactyl/content/mail.js @@ -453,7 +453,7 @@ const Mail = Module("mail", { "Copy selected messages", function (args) { mail._moveOrCopy(true, args.literalArg); }, { - argCount: 1, + argCount: "1", completer: function (context) completion.mailFolder(context), literal: 0 }); @@ -462,7 +462,7 @@ const Mail = Module("mail", { "Move selected messages", function (args) { mail._moveOrCopy(false, args.literalArg); }, { - argCount: 1, + argCount: "1", completer: function (context) completion.mailFolder(context), literal: 0 });