File: compare_spec.rb

package info (click to toggle)
ruby-hamster 3.0.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,932 kB
  • sloc: ruby: 16,915; makefile: 4
file content (31 lines) | stat: -rw-r--r-- 677 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require "spec_helper"
require "hamster/list"

describe Hamster::List do
  describe "#<=>" do
    [
      [[], [1]],
      [[1], [2]],
      [[1], [1, 2]],
      [[2, 3, 4], [3, 4, 5]]
    ].each do |items1, items2|
      context "with #{items1} and #{items2}" do
        it "returns -1" do
          (L[*items1] <=> L[*items2]).should be(-1)
        end
      end

      context "with #{items2} and #{items1}" do
        it "returns 1" do
          (L[*items2] <=> L[*items1]).should be(1)
        end
      end

      context "with #{items1} and #{items1}" do
        it "returns 0" do
          (L[*items1] <=> L[*items1]).should be(0)
        end
      end
    end
  end
end