browser_gcli_incomplete.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  1. /*
  2. * Copyright 2012, Mozilla Foundation and contributors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. "use strict";
  17. // THIS FILE IS GENERATED FROM SOURCE IN THE GCLI PROJECT
  18. // PLEASE TALK TO SOMEONE IN DEVELOPER TOOLS BEFORE EDITING IT
  19. const exports = {};
  20. function test() {
  21. helpers.runTestModule(exports, "browser_gcli_incomplete.js");
  22. }
  23. // var assert = require('../testharness/assert');
  24. // var helpers = require('./helpers');
  25. exports.testBasic = function (options) {
  26. return helpers.audit(options, [
  27. {
  28. setup: "tsu 2 extra",
  29. check: {
  30. args: {
  31. num: { value: 2, type: "Argument" }
  32. }
  33. },
  34. post: function () {
  35. var requisition = options.requisition;
  36. assert.is(requisition._unassigned.length,
  37. 1,
  38. "single unassigned: tsu 2 extra");
  39. assert.is(requisition._unassigned[0].param.type.isIncompleteName,
  40. false,
  41. "unassigned.isIncompleteName: tsu 2 extra");
  42. }
  43. },
  44. {
  45. setup: "tsu",
  46. check: {
  47. args: {
  48. num: { value: undefined, type: "BlankArgument" }
  49. }
  50. }
  51. },
  52. {
  53. setup: "tsg",
  54. check: {
  55. args: {
  56. solo: { type: "BlankArgument" },
  57. txt1: { type: "BlankArgument" },
  58. bool: { type: "BlankArgument" },
  59. txt2: { type: "BlankArgument" },
  60. num: { type: "BlankArgument" }
  61. }
  62. }
  63. }
  64. ]);
  65. };
  66. exports.testCompleted = function (options) {
  67. return helpers.audit(options, [
  68. {
  69. setup: "tsela<TAB>",
  70. check: {
  71. args: {
  72. command: { name: "tselarr", type: "Argument" },
  73. num: { type: "BlankArgument" },
  74. arr: { type: "ArrayArgument" }
  75. }
  76. }
  77. },
  78. {
  79. setup: "tsn dif ",
  80. check: {
  81. input: "tsn dif ",
  82. hints: "<text>",
  83. markup: "VVVVVVVV",
  84. cursor: 8,
  85. status: "ERROR",
  86. args: {
  87. command: { name: "tsn dif", type: "MergedArgument" },
  88. text: { type: "BlankArgument", status: "INCOMPLETE" }
  89. }
  90. }
  91. },
  92. {
  93. setup: "tsn di<TAB>",
  94. check: {
  95. input: "tsn dif ",
  96. hints: "<text>",
  97. markup: "VVVVVVVV",
  98. cursor: 8,
  99. status: "ERROR",
  100. args: {
  101. command: { name: "tsn dif", type: "Argument" },
  102. text: { type: "BlankArgument", status: "INCOMPLETE" }
  103. }
  104. }
  105. },
  106. // The above 2 tests take different routes to 'tsn dif '.
  107. // The results should be similar. The difference is in args.command.type.
  108. {
  109. setup: "tsg -",
  110. check: {
  111. input: "tsg -",
  112. hints: "-txt1 <solo> [options]",
  113. markup: "VVVVI",
  114. cursor: 5,
  115. status: "ERROR",
  116. args: {
  117. solo: { value: undefined, status: "INCOMPLETE" },
  118. txt1: { value: undefined, status: "VALID" },
  119. bool: { value: false, status: "VALID" },
  120. txt2: { value: undefined, status: "VALID" },
  121. num: { value: undefined, status: "VALID" }
  122. }
  123. }
  124. },
  125. {
  126. setup: "tsg -<TAB>",
  127. check: {
  128. input: "tsg --txt1 ",
  129. hints: "<string> <solo> [options]",
  130. markup: "VVVVIIIIIIV",
  131. cursor: 11,
  132. status: "ERROR",
  133. args: {
  134. solo: { value: undefined, status: "INCOMPLETE" },
  135. txt1: { value: undefined, status: "INCOMPLETE" },
  136. bool: { value: false, status: "VALID" },
  137. txt2: { value: undefined, status: "VALID" },
  138. num: { value: undefined, status: "VALID" }
  139. }
  140. }
  141. },
  142. {
  143. setup: "tsg --txt1 fred",
  144. check: {
  145. input: "tsg --txt1 fred",
  146. hints: " <solo> [options]",
  147. markup: "VVVVVVVVVVVVVVV",
  148. status: "ERROR",
  149. args: {
  150. solo: { value: undefined, status: "INCOMPLETE" },
  151. txt1: { value: "fred", status: "VALID" },
  152. bool: { value: false, status: "VALID" },
  153. txt2: { value: undefined, status: "VALID" },
  154. num: { value: undefined, status: "VALID" }
  155. }
  156. }
  157. },
  158. {
  159. setup: "tscook key value --path path --",
  160. check: {
  161. input: "tscook key value --path path --",
  162. hints: "domain [options]",
  163. markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVII",
  164. status: "ERROR",
  165. args: {
  166. key: { value: "key", status: "VALID" },
  167. value: { value: "value", status: "VALID" },
  168. path: { value: "path", status: "VALID" },
  169. domain: { value: undefined, status: "VALID" },
  170. secure: { value: false, status: "VALID" }
  171. }
  172. }
  173. },
  174. {
  175. setup: "tscook key value --path path --domain domain --",
  176. check: {
  177. input: "tscook key value --path path --domain domain --",
  178. hints: "secure [options]",
  179. markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVII",
  180. status: "ERROR",
  181. args: {
  182. key: { value: "key", status: "VALID" },
  183. value: { value: "value", status: "VALID" },
  184. path: { value: "path", status: "VALID" },
  185. domain: { value: "domain", status: "VALID" },
  186. secure: { value: false, status: "VALID" }
  187. }
  188. }
  189. }
  190. ]);
  191. };
  192. exports.testCase = function (options) {
  193. return helpers.audit(options, [
  194. {
  195. setup: "tsg AA",
  196. check: {
  197. input: "tsg AA",
  198. hints: " [options] -> aaa",
  199. markup: "VVVVII",
  200. status: "ERROR",
  201. args: {
  202. solo: { value: undefined, text: "AA", status: "INCOMPLETE" },
  203. txt1: { value: undefined, status: "VALID" },
  204. bool: { value: false, status: "VALID" },
  205. txt2: { value: undefined, status: "VALID" },
  206. num: { value: undefined, status: "VALID" }
  207. }
  208. }
  209. }
  210. ]);
  211. };
  212. exports.testIncomplete = function (options) {
  213. return helpers.audit(options, [
  214. {
  215. setup: "tsm a a -",
  216. check: {
  217. args: {
  218. abc: { value: "a", type: "Argument" },
  219. txt: { value: "a", type: "Argument" },
  220. num: { value: undefined, arg: " -", type: "Argument", status: "INCOMPLETE" }
  221. }
  222. }
  223. },
  224. {
  225. setup: "tsg -",
  226. check: {
  227. args: {
  228. solo: { type: "BlankArgument" },
  229. txt1: { type: "BlankArgument" },
  230. bool: { type: "BlankArgument" },
  231. txt2: { type: "BlankArgument" },
  232. num: { type: "BlankArgument" }
  233. }
  234. },
  235. post: function () {
  236. var requisition = options.requisition;
  237. assert.is(requisition._unassigned[0],
  238. requisition.getAssignmentAt(5),
  239. "unassigned -");
  240. assert.is(requisition._unassigned.length,
  241. 1,
  242. "single unassigned - tsg -");
  243. assert.is(requisition._unassigned[0].param.type.isIncompleteName,
  244. true,
  245. "unassigned.isIncompleteName: tsg -");
  246. }
  247. }
  248. ]);
  249. };
  250. exports.testRepeated = function (options) {
  251. return helpers.audit(options, [
  252. {
  253. setup: "tscook key value --path jjj --path kkk",
  254. check: {
  255. input: "tscook key value --path jjj --path kkk",
  256. hints: " [options]",
  257. markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVEEEEEEVEEE",
  258. cursor: 38,
  259. current: "__unassigned",
  260. status: "ERROR",
  261. options: [ ],
  262. message: "",
  263. predictions: [ ],
  264. unassigned: [ " --path", " kkk" ],
  265. args: {
  266. command: { name: "tscook" },
  267. key: {
  268. value: "key",
  269. arg: " key",
  270. status: "VALID",
  271. message: ""
  272. },
  273. value: {
  274. value: "value",
  275. arg: " value",
  276. status: "VALID",
  277. message: ""
  278. },
  279. path: {
  280. value: "jjj",
  281. arg: " --path jjj",
  282. status: "VALID",
  283. message: ""
  284. },
  285. domain: {
  286. value: undefined,
  287. arg: "",
  288. status: "VALID",
  289. message: ""
  290. },
  291. secure: {
  292. value: false,
  293. arg: "",
  294. status: "VALID",
  295. message: ""
  296. },
  297. }
  298. }
  299. }
  300. ]);
  301. };
  302. exports.testHidden = function (options) {
  303. return helpers.audit(options, [
  304. {
  305. setup: "tshidde",
  306. check: {
  307. input: "tshidde",
  308. hints: " -> tse",
  309. status: "ERROR"
  310. }
  311. },
  312. {
  313. setup: "tshidden",
  314. check: {
  315. input: "tshidden",
  316. hints: " [options]",
  317. markup: "VVVVVVVV",
  318. status: "VALID",
  319. args: {
  320. visible: { value: undefined, status: "VALID" },
  321. invisiblestring: { value: undefined, status: "VALID" },
  322. invisibleboolean: { value: false, status: "VALID" }
  323. }
  324. }
  325. },
  326. {
  327. setup: "tshidden --vis",
  328. check: {
  329. input: "tshidden --vis",
  330. hints: "ible [options]",
  331. markup: "VVVVVVVVVIIIII",
  332. status: "ERROR",
  333. args: {
  334. visible: { value: undefined, status: "VALID" },
  335. invisiblestring: { value: undefined, status: "VALID" },
  336. invisibleboolean: { value: false, status: "VALID" }
  337. }
  338. }
  339. },
  340. {
  341. setup: "tshidden --invisiblestrin",
  342. check: {
  343. input: "tshidden --invisiblestrin",
  344. hints: " [options]",
  345. markup: "VVVVVVVVVEEEEEEEEEEEEEEEE",
  346. status: "ERROR",
  347. args: {
  348. visible: { value: undefined, status: "VALID" },
  349. invisiblestring: { value: undefined, status: "VALID" },
  350. invisibleboolean: { value: false, status: "VALID" }
  351. }
  352. }
  353. },
  354. {
  355. setup: "tshidden --invisiblestring",
  356. check: {
  357. input: "tshidden --invisiblestring",
  358. hints: " <string> [options]",
  359. markup: "VVVVVVVVVIIIIIIIIIIIIIIIII",
  360. status: "ERROR",
  361. args: {
  362. visible: { value: undefined, status: "VALID" },
  363. invisiblestring: { value: undefined, status: "INCOMPLETE" },
  364. invisibleboolean: { value: false, status: "VALID" }
  365. }
  366. }
  367. },
  368. {
  369. setup: "tshidden --invisiblestring x",
  370. check: {
  371. input: "tshidden --invisiblestring x",
  372. hints: " [options]",
  373. markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVV",
  374. status: "VALID",
  375. args: {
  376. visible: { value: undefined, status: "VALID" },
  377. invisiblestring: { value: "x", status: "VALID" },
  378. invisibleboolean: { value: false, status: "VALID" }
  379. }
  380. }
  381. },
  382. {
  383. setup: "tshidden --invisibleboolea",
  384. check: {
  385. input: "tshidden --invisibleboolea",
  386. hints: " [options]",
  387. markup: "VVVVVVVVVEEEEEEEEEEEEEEEEE",
  388. status: "ERROR",
  389. args: {
  390. visible: { value: undefined, status: "VALID" },
  391. invisiblestring: { value: undefined, status: "VALID" },
  392. invisibleboolean: { value: false, status: "VALID" }
  393. }
  394. }
  395. },
  396. {
  397. setup: "tshidden --invisibleboolean",
  398. check: {
  399. input: "tshidden --invisibleboolean",
  400. hints: " [options]",
  401. markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVV",
  402. status: "VALID",
  403. args: {
  404. visible: { value: undefined, status: "VALID" },
  405. invisiblestring: { value: undefined, status: "VALID" },
  406. invisibleboolean: { value: true, status: "VALID" }
  407. }
  408. }
  409. },
  410. {
  411. setup: "tshidden --visible xxx",
  412. check: {
  413. input: "tshidden --visible xxx",
  414. markup: "VVVVVVVVVVVVVVVVVVVVVV",
  415. status: "VALID",
  416. hints: "",
  417. args: {
  418. visible: { value: "xxx", status: "VALID" },
  419. invisiblestring: { value: undefined, status: "VALID" },
  420. invisibleboolean: { value: false, status: "VALID" }
  421. }
  422. }
  423. }
  424. ]);
  425. };