Sha256: 2c5025904d0e116a227e094c8ec80ac08f667d09004be01d0a2f9f554b323cd1

Contents?: true

Size: 1.43 KB

Versions: 396

Compression:

Stored size: 1.43 KB

Contents

local diamond = require 'diamond'

describe('diamond', function()
  it('should generate the diamond for A', function()
    assert.are.equal('A\n', diamond('A'))
  end)

  it('should generate the diamond for B', function()
    local expected =
      ' A \n' ..
      'B B\n' ..
      ' A \n'

    assert.are.equal(expected, diamond('B'))
  end)

  it('should generate the diamond for C', function()
    local expected =
      '  A  \n' ..
      ' B B \n' ..
      'C   C\n' ..
      ' B B \n' ..
      '  A  \n'

    assert.are.equal(expected, diamond('C'))
  end)

  it('should generate the diamond for E', function()
    local expected =
      '    A    \n' ..
      '   B B   \n' ..
      '  C   C  \n' ..
      ' D     D \n' ..
      'E       E\n' ..
      ' D     D \n' ..
      '  C   C  \n' ..
      '   B B   \n' ..
      '    A    \n'

    assert.are.equal(expected, diamond('E'))
  end)

  it('should generate the diamond for H', function()
    local expected =
      '       A       \n' ..
      '      B B      \n' ..
      '     C   C     \n' ..
      '    D     D    \n' ..
      '   E       E   \n' ..
      '  F         F  \n' ..
      ' G           G \n' ..
      'H             H\n' ..
      ' G           G \n' ..
      '  F         F  \n' ..
      '   E       E   \n' ..
      '    D     D    \n' ..
      '     C   C     \n' ..
      '      B B      \n' ..
      '       A       \n'

    assert.are.equal(expected, diamond('H'))
  end)
end)

Version data entries

396 entries across 396 versions & 1 rubygems

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