browser_gcli_split.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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_split.js");
  22. }
  23. // var assert = require('../testharness/assert');
  24. var cli = require("gcli/cli");
  25. exports.testSplitSimple = function (options) {
  26. var args = cli.tokenize("s");
  27. options.requisition._split(args);
  28. assert.is(args.length, 0);
  29. assert.is(options.requisition.commandAssignment.arg.text, "s");
  30. };
  31. exports.testFlatCommand = function (options) {
  32. var args = cli.tokenize("tsv");
  33. options.requisition._split(args);
  34. assert.is(args.length, 0);
  35. assert.is(options.requisition.commandAssignment.value.name, "tsv");
  36. args = cli.tokenize("tsv a b");
  37. options.requisition._split(args);
  38. assert.is(options.requisition.commandAssignment.value.name, "tsv");
  39. assert.is(args.length, 2);
  40. assert.is(args[0].text, "a");
  41. assert.is(args[1].text, "b");
  42. };
  43. exports.testJavascript = function (options) {
  44. if (!options.requisition.system.commands.get("{")) {
  45. assert.log("Skipping testJavascript because { is not registered");
  46. return;
  47. }
  48. var args = cli.tokenize("{");
  49. options.requisition._split(args);
  50. assert.is(args.length, 1);
  51. assert.is(args[0].text, "");
  52. assert.is(options.requisition.commandAssignment.arg.text, "");
  53. assert.is(options.requisition.commandAssignment.value.name, "{");
  54. };
  55. // BUG 663081 - add tests for sub commands