~ubuntu-branches/ubuntu/trusty/ruby-parslet/trusty-proposed

« back to all changes in this revision

Viewing changes to spec/parslet/source/line_cache_spec.rb

  • Committer: Package Import Robot
  • Author(s): Axel Wagner
  • Date: 2014-01-25 19:05:00 UTC
  • Revision ID: package-import@ubuntu.com-20140125190500-teix25yb0dunago3
Tags: 1.5.0-1
Initial release (Closes: #735295)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'spec_helper'
 
2
 
 
3
describe Parslet::Source::RangeSearch do
 
4
  describe "<- #lbound" do
 
5
    context "for a simple array" do
 
6
      let(:ary) { [10, 20, 30, 40, 50] }
 
7
      before(:each) { ary.extend Parslet::Source::RangeSearch }
 
8
 
 
9
      it "should return correct answers for numbers not in the array" do
 
10
        ary.lbound(5).should == 0
 
11
        ary.lbound(15).should == 1
 
12
        ary.lbound(25).should == 2
 
13
        ary.lbound(35).should == 3
 
14
        ary.lbound(45).should == 4
 
15
      end
 
16
      it "should return correct answers for numbers in the array" do
 
17
        ary.lbound(10).should == 1
 
18
        ary.lbound(20).should == 2
 
19
        ary.lbound(30).should == 3
 
20
        ary.lbound(40).should == 4
 
21
      end
 
22
      it "should cover right edge case" do
 
23
        ary.lbound(50).should be_nil
 
24
        ary.lbound(51).should be_nil
 
25
      end 
 
26
      it "should cover left edge case" do
 
27
        ary.lbound(0).should == 0
 
28
      end
 
29
    end
 
30
    context "for an empty array" do
 
31
      let(:ary) { [] }
 
32
      before(:each) { ary.extend Parslet::Source::RangeSearch }
 
33
 
 
34
      it "should return nil" do
 
35
        ary.lbound(1).should be_nil
 
36
      end 
 
37
    end
 
38
  end
 
39
end
 
 
b'\\ No newline at end of file'