File: hash_spec.rb

package info (click to toggle)
ruby-immutable-ruby 0.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,852 kB
  • sloc: ruby: 16,556; makefile: 4
file content (21 lines) | stat: -rw-r--r-- 496 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'spec_helper'

describe Immutable::List do
  describe '#hash' do
    context 'on a really big list' do
      it "doesn't run out of stack" do
        -> { BigList.hash }.should_not raise_error
      end
    end

    context 'on an empty list' do
      it 'returns 0' do
        expect(L.empty.hash).to eq(0)
      end
    end

    it 'values are sufficiently distributed' do
      (1..4000).each_slice(4).map { |a, b, c, d| L[a, b, c, d].hash }.uniq.size.should == 1000
    end
  end
end