blob: 0e2365b5ea555db8870c90e6907888e73a0b8112 (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 | RSpec.describe Range do
  context "intersection" do
    it "is nil (sic) for two distinct ranges" do
      expect( (1..2).intersection(3..4) ).to be_nil
    end
    it "is the smaller of two if one is part of the other" do
      expect( (1..2).intersection(0..3) ).to eq 1..2
      expect( (0..2).intersection(1..2) ).to eq 1..2
    end
    it "is the intersection otherwise" do
      expect( (1..3) & (2..4) ).to eq 2..3
      expect( (2..4) & (1..3) ).to eq 2..3
    end
  end
end
 |