Skip to content

Commit

Permalink
Refuse to handle exclusive slices in
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesdabbs committed Apr 11, 2013
1 parent 6fc5628 commit 3306667
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/steffi/vector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def self.from_a ary
end

def self.from_slice slice
# FIXME: this only works for inclusive slices
raise "Slices should be inclusive" if slice.exclude_end?
new { |v| Igraph.vector_init_seq v.pointer, slice.first, slice.last }
end

Expand Down
4 changes: 4 additions & 0 deletions spec/steffi/vector_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
Steffi::Vector.from_slice(5..9).should have(5).members
end

it 'errors on exclusive slices' do
expect { Steffi::Vector.from_slice(5...9) }.to raise_error
end

# -----

subject { Steffi::Vector.from_a [2, 3, 4] }
Expand Down

0 comments on commit 3306667

Please sign in to comment.