Sha256: 1092bd0f6ff4317288b09e9382d046846294f0e7b4df94abbc41f5d788986514

Contents?: true

Size: 770 Bytes

Versions: 124

Compression:

Stored size: 770 Bytes

Contents

local conjecture = require('collatz-conjecture')

describe('collatz-conjecture', function()
  it('zero steps for one', function()
    assert.are.equal(0, conjecture(1))
  end)

  it('divide if even', function()
    assert.are.equal(4, conjecture(16))
  end)

  it('even and odd steps', function()
    assert.are.equal(9, conjecture(12))
  end)

  it('large number of even and odd steps', function()
    assert.are.equal(152, conjecture(1000000))
  end)

  it('zero is an error', function()
    assert.has_error(
      function() conjecture(0) end,
      'Only positive numbers are allowed'
    )
  end)

  it('negative value is an error', function()
    assert.has_error(
      function() conjecture(-15) end,
      'Only positive numbers are allowed'
    )
  end)
end)

Version data entries

124 entries across 124 versions & 1 rubygems

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