This file is indexed.

/usr/lib/nodejs/commist/test.js is in node-commist 1.0.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
var test      = require('tape').test
  , commist   = require('./')
  , minimist  = require('minimist')

test('registering a command', function(t) {
  t.plan(2)

  var program = commist()
    , result

  program.register('hello', function(args) {
    t.deepEqual(args, ['a', '-x', '23'])
  })

  result = program.parse(['hello', 'a', '-x', '23'])

  t.notOk(result, 'must return null, the command have been handled')
})

test('registering two commands', function(t) {
  t.plan(1)

  var program = commist()
    , result

  program.register('hello', function(args) {
    t.ok(false, 'must pick the right command')
  })

  program.register('world', function(args) {
    t.deepEqual(args, ['a', '-x', '23'])
  })

  program.parse(['world', 'a', '-x', '23'])
})

test('registering two commands (bis)', function(t) {
  t.plan(1)

  var program = commist()
    , result

  program.register('hello', function(args) {
    t.deepEqual(args, ['a', '-x', '23'])
  })

  program.register('world', function(args) {
    t.ok(false, 'must pick the right command')
  })

  program.parse(['hello', 'a', '-x', '23'])
})

test('registering two words commands', function(t) {
  t.plan(1)

  var program = commist()
    , result

  program.register('hello', function(args) {
    t.ok(false, 'must pick the right command')
  })

  program.register('hello world', function(args) {
    t.deepEqual(args, ['a', '-x', '23'])
  })

  program.parse(['hello', 'world', 'a', '-x', '23'])
})

test('registering two words commands (bis)', function(t) {
  t.plan(1)

  var program = commist()
    , result

  program.register('hello', function(args) {
    t.deepEqual(args, ['a', '-x', '23'])
  })

  program.register('hello world', function(args) {
    t.ok(false, 'must pick the right command')
  })

  program.parse(['hello', 'a', '-x', '23'])
})

test('registering ambiguous commands throws exception', function(t) {
  var program = commist()
    , result

  function noop() {}

  program.register('hello', noop)
  program.register('hello world', noop)
  program.register('hello world matteo', noop)

  try {
    program.register('hello world', noop)
    t.ok(false, 'must throw if double-registering the same command')
  } catch(err) {
  }

  t.end()
})

test('looking up commands', function(t) {
  var program = commist()
    , result

  function noop1() {}
  function noop2() {}
  function noop3() {}

  program.register('hello', noop1)
  program.register('hello world matteo', noop3)
  program.register('hello world', noop2)

  t.equal(program.lookup('hello')[0].func, noop1)
  t.equal(program.lookup('hello world matteo')[0].func, noop3)
  t.equal(program.lookup('hello world')[0].func, noop2)

  t.end()
})

test('looking up commands with abbreviations', function(t) {
  var program = commist()
    , result

  function noop1() {}
  function noop2() {}
  function noop3() {}

  program.register('hello', noop1)
  program.register('hello world matteo', noop3)
  program.register('hello world', noop2)

  t.equal(program.lookup('hel')[0].func, noop1)
  t.equal(program.lookup('hel wor mat')[0].func, noop3)
  t.equal(program.lookup('hel wor')[0].func, noop2)

  t.end()
})

test('executing commands from abbreviations', function(t) {
  t.plan(1)

  var program = commist()
    , result

  program.register('hello', function(args) {
    t.deepEqual(args, ['a', '-x', '23'])
  })

  program.register('hello world', function(args) {
    t.ok(false, 'must pick the right command')
  })

  program.parse(['hel', 'a', '-x', '23'])
})

test('a command must be at least 3 chars', function(t) {
  var program = commist()
    , result

  function noop1() {}

  try {
    program.register('h', noop1)
    t.ok(false, 'not thrown')
  } catch(err) {
  }

  t.end()
})

test('a command part must be at least 3 chars', function(t) {
  var program = commist()
    , result

  function noop1() {}

  try {
    program.register('h b', noop1)
    t.ok(false, 'not thrown')
  } catch(err) {
  }

  t.end()
})