Sha256: 442ac76187bfd9ff18604762f3a04aa0f2b86fcb3a6383ce6bad93155eb60816

Contents?: true

Size: 871 Bytes

Versions: 1

Compression:

Stored size: 871 Bytes

Contents

require 'spec_helper'

describe Fzip, 'array' do
  let(:tree) {
    [
      ['x', '+', 'y'],
      ['a', '*', 'b']
    ]
  }

  let(:zipper) { Fzip.array(tree) }

  it 'should return a zipper suitable for arrays' do
    expect(zipper.adapter).to be_an_instance_of(Fzip::ArrayAdapter)
  end

  it 'should allow navigating' do
    expect(zipper.down.down.right.right.left.node).to eq('+')
  end

  it 'should allow inserting nodes' do
    expect(zipper.down.down.right.insert_left(:foo).insert_right(:bar).root).to eq [["x", :foo, "+", :bar, "y"], ["a", "*", "b"]]
  end

  it 'should allow replacing nodes' do
    expect(zipper.down.right.down.right.replace(:foo).root).to eq [["x", "+", "y"], ["a", :foo, "b"]]
  end

  it 'should allow editing with a block' do
    expect(zipper.down.right.down.right.edit{:foo}.root).to eq [["x", "+", "y"], ["a", :foo, "b"]]
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fzip-0.2.0 spec/fzip_spec.rb