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.180 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.179 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.178 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.177 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.176 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.175 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.174 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.173 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.172 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.171 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.170 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.169 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.167 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.166 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.165 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.164 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.163 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.162 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.161 tracks/lua/exercises/matrix/matrix_spec.lua
trackler-2.2.1.160 tracks/lua/exercises/matrix/matrix_spec.lua