local U=require("\105\110\118\111\107\097\116\105\111\110\046\108\097\110\103\046\114\097\110\100\111\109")describe("\102\117\110\099\116\105\111\110",function()describe("\046\115\101\101\100",function()local e before_each(function()e=spy.on(math,"\114\097\110\100\111\109\115\101\101\100")end)after_each(function()e:revert()end)it("\115\101\101\100\115 \096\109\097\116\104\096\115 \114\097\110\100\111\109 \119\105\116\104 \116\104\101 \103\105\118\101\110 \118\097\108\117\101",function()U.seed(13);(assert.spy(e)).was.called_with(13)end)describe("\119\105\116\104 \100\101\102\097\117\108\116 \118\097\108\117\101",function()local Q before_each(function()Q=stub.new(_G,"\084\105\109\101",31)end)after_each(function()Q:revert()end)it("\115\101\101\100\115 \096\109\097\116\104\096\115 \114\097\110\100\111\109 \119\105\116\104 \097 \100\101\102\097\117\108\116 \118\097\108\117\101",function()U.seed();(assert.stub(Q)).was_called(1);(assert.spy(e)).was.called_with(31)end)end)end)end)
local rand = require("invokation.lang.random")

describe("function", function()
  describe(".seed", function()
    local spyMathRandomSeed

    before_each(function()
      spyMathRandomSeed = spy.on(math, "randomseed")
    end)

    after_each(function()
      spyMathRandomSeed:revert()
    end)

    it("seeds `math`s random with the given value", function()
      rand.seed(13)

      assert.spy(spyMathRandomSeed).was.called_with(13)
    end)

    describe("with default value", function()
      local stubTime

      before_each(function()
        -- selene: allow(global_usage)
        stubTime = stub.new(_G, "Time", 31)
      end)

      after_each(function()
        stubTime:revert()
      end)

      it("seeds `math`s random with a default value", function()
        rand.seed()

        assert.stub(stubTime).was_called(1)
        assert.spy(spyMathRandomSeed).was.called_with(31)
      end)
    end)
  end)
end)
