2015-01-17から1日間の記事一覧
function coin(x) { return Math.random() < x; } こういう関数があったとして、どうテストを書くのか。 ぱっと思いつくのはこういう感じで、Math.random 自体を上書きするやり方。 describe("coin(x)", function() { it("works", sinon.test(function() { t…
function coin(x) { return Math.random() < x; } こういう関数があったとして、どうテストを書くのか。 ぱっと思いつくのはこういう感じで、Math.random 自体を上書きするやり方。 describe("coin(x)", function() { it("works", sinon.test(function() { t…