Sha256: 8c3b9041892decc957ff24a3b4fea5749ac69c2f1baf5f5946159d3191780651

Contents?: true

Size: 1.64 KB

Versions: 200

Compression:

Stored size: 1.64 KB

Contents

local compute = require('hamming').compute

describe('hamming', function ()
  it('identical strands', function ()
    assert.are.equal(0, compute('A', 'A'))
  end)

  it('long identical strands', function ()
    assert.are.equal(0, compute('GGACTGA', 'GGACTGA'))
  end)

  it('complete distance in single nucleotide strands', function ()
    assert.are.equal(1, compute('A', 'G'))
  end)

  it('complete distance in small strands', function ()
    assert.are.equal(2, compute('AG', 'CT'))
  end)

  it('small distance in small strands', function ()
    assert.are.equal(1, compute('AT', 'CT'))
  end)

  it('small distance', function ()
    assert.are.equal(1, compute('GGACG', 'GGTCG'))
  end)

  it('small distance in long strands', function ()
    assert.are.equal(2, compute('ACCAGGG', 'ACTATGG'))
  end)

  it('non unique character in first strand', function ()
    assert.are.equal(1, compute('AGA', 'AGG'))
  end)

  it('non unique character in second strand', function ()
    assert.are.equal(1, compute('AGG', 'AGA'))
  end)

  it('same nucleotides in different positions', function ()
    assert.are.equal(2, compute('TAG', 'GAT'))
  end)

  it('large distance', function ()
    assert.are.equal(4, compute('GATACA', 'GCATAA'))
  end)

  it('large distance in off-by-one strand', function ()
    assert.are.equal(9, compute('GGACGGATTCTG', 'AGGACGGATTCT'))
  end)

  it('empty strands', function ()
    assert.are.equal(0, compute('', ''))
  end)

  it('disallow first strand longer', function ()
    assert.are.equal(-1, compute('AATG', 'AAA'))
  end)

  it('disallow second strand longer', function ()
    assert.are.equal(-1, compute('ATA', 'AGTG'))
  end)
end)

Version data entries

200 entries across 200 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.97 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.96 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.95 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.94 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.93 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.92 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.91 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.90 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.89 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.88 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.87 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.86 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.85 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.84 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.83 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.82 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.81 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.80 tracks/lua/exercises/hamming/hamming_spec.lua
trackler-2.2.1.79 tracks/lua/exercises/hamming/hamming_spec.lua