You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
652 B
24 lines
652 B
1 year ago
|
require "minitest"
|
||
|
|
||
|
require "rank_king"
|
||
|
|
||
|
class TestRankKing < Minitest::Test
|
||
|
def setup
|
||
|
@pool = Pool.create(name: "pool")
|
||
|
@axis = Axis.create(pool: @pool, name: "axis")
|
||
|
@items = (?a..?d).map { Item.create(pool: @pool, title: _1) }
|
||
|
end
|
||
|
|
||
|
def test_rank_king
|
||
|
ratings = @pool.items.map {|item| Rating.first(axis: @axis, item:) || OS.rating }
|
||
|
original_sigma_sq = Math.sqrt(ratings.sum { _1.sigma ** 2 })
|
||
|
|
||
|
game = RankKing.suggest_game(@axis)
|
||
|
winner, loser = game.shuffle
|
||
|
RankKing.rank(@axis, winner:, loser:)
|
||
|
|
||
|
sigma_sq = Math.sqrt(@axis.ratings.sum { _1.sigma ** 2 })
|
||
|
assert original_sigma_sq > sigma_sq
|
||
|
end
|
||
|
end
|