Sha256: b02392291e83a4003859905a7f034b387c8372d3dddd6780ffd0ef77b7b3ea10

Contents?: true

Size: 981 Bytes

Versions: 396

Compression:

Stored size: 981 Bytes

Contents

local Matrix = require('matrix')

describe('matrix', function()
  it('should allow rows to be extracted', function()
    local matrix = Matrix('1 2 3\n4 5 6\n7 8 9')
    assert.same({ 1, 2, 3 }, matrix.row(1))
    assert.same({ 4, 5, 6 }, matrix.row(2))
    assert.same({ 7, 8, 9 }, matrix.row(3))
  end)

  it('should allow columns to be extracted', function()
    local matrix = Matrix('1 2 3\n4 5 6\n7 8 9')
    assert.same({ 1, 4, 7 }, matrix.column(1))
    assert.same({ 2, 5, 8 }, matrix.column(2))
    assert.same({ 3, 6, 9 }, matrix.column(3))
  end)

  it('should support values of varying sizes', function()
    local matrix = Matrix('1 2 3\n4 12345 6\n7 8 9')
    assert.same({ 4, 12345, 6 }, matrix.row(2))
    assert.same({ 2, 12345, 8 }, matrix.column(2))
  end)

  it('should support matrices of varying sizes', function()
    local matrix = Matrix('1 2\n3 4\n5 6')
    assert.same({ 3, 4 }, matrix.row(2))
    assert.same({ 2, 4, 6 }, matrix.column(2))
  end)
end)

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.119 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.118 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.117 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.116 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.115 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.114 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.113 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.111 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.110 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.109 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.108 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.107 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.106 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.105 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.104 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.103 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.102 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.101 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.100 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.99 tracks/lua/exercises/matrix/matrix_spec.lua