@a-s8h/liblevenshtein
Version:
Various utilities regarding Levenshtein transducers.
179 lines (176 loc) • 4.14 kB
text/coffeescript
{levenshtein: {permutations}} = require '../../src/util/permutations'
module.exports =
'There should be no permutations on an empty list': (test) ->
test.deepEqual(permutations([]), [])
test.done()
'The only permutation on a singleton list should be the same list': (test) ->
test.deepEqual(permutations([1]), [[1]])
test.done()
'There should be 2-factorial, distinct permutations on a pair': (test) ->
test.deepEqual(permutations([1,2]),[
[]
[]
])
test.done()
'There should be 3-factorial, distinct permutations on a triple': (test) ->
test.deepEqual(permutations([1..3]), [
[]
[]
[]
[]
[]
[]
])
test.done()
'There should be 4-factorial, distinct permutations on a quadruple': (test) ->
test.deepEqual(permutations([1..4]), [
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
])
test.done()
'There should be 5-factorial, distinct permutations on a 5-tuple': (test) ->
test.deepEqual(permutations([1..5]), [
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
[]
])
test.done()