Sha256: a73bb57b15227d08569eb91d1f88455616dcc8405197cbebcb1a4c5a72c495d4

Contents?: true

Size: 608 Bytes

Versions: 15

Compression:

Stored size: 608 Bytes

Contents

describe "Array#&" do
  it "creates an array with elements common to both arrays (intersection)" do
    ([] & []).should == []
    ([1, 2] & []).should == []
    ([] & [1, 2]).should == []
    ([1, 3, 5] & [1, 2, 3]).should == [1, 3]
  end

  it "creates an array with no duplicates" do
    ([1, 1, 3, 5] & [1, 2, 3]).uniq!.should == nil
  end

  it "creates an array with elements in order they are first encountered" do
    ([1, 2, 3, 2, 5] & [5, 2, 3, 4]).should == [2, 3, 5]
  end

  it "does not modify the original Array" do
    a = [1, 1, 3, 5]
    a & [1, 2, 3]
    a.should == [1, 1, 3, 5]
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
opal-0.3.41 spec/core/array/intersection_spec.rb
opal-0.3.40 spec/core/array/intersection_spec.rb
opal-0.3.39 spec/core/array/intersection_spec.rb
opal-0.3.38 spec/core/array/intersection_spec.rb
opal-0.3.37 spec/core/array/intersection_spec.rb
opal-0.3.36 spec/core/array/intersection_spec.rb
opal-0.3.35 spec/core/array/intersection_spec.rb
opal-0.3.34 spec/core/array/intersection_spec.rb
opal-0.3.33 spec/core/array/intersection_spec.rb
opal-0.3.32 spec/core/array/intersection_spec.rb
opal-0.3.31 spec/core/array/intersection_spec.rb
opal-0.3.30 spec/core/array/intersection_spec.rb
opal-0.3.29 spec/core/array/intersection_spec.rb
opal-0.3.28 spec/core/array/intersection_spec.rb
opal-0.3.27 spec/core/array/intersection_spec.rb