diff options
Diffstat (limited to 'spec/ruby/library/stringscanner/shared')
| -rw-r--r-- | spec/ruby/library/stringscanner/shared/bol.rb | 25 | ||||
| -rw-r--r-- | spec/ruby/library/stringscanner/shared/concat.rb | 30 | ||||
| -rw-r--r-- | spec/ruby/library/stringscanner/shared/pos.rb | 59 |
3 files changed, 0 insertions, 114 deletions
diff --git a/spec/ruby/library/stringscanner/shared/bol.rb b/spec/ruby/library/stringscanner/shared/bol.rb deleted file mode 100644 index ec5c2051b5..0000000000 --- a/spec/ruby/library/stringscanner/shared/bol.rb +++ /dev/null @@ -1,25 +0,0 @@ -describe :strscan_bol, shared: true do - it "returns true if the scan pointer is at the beginning of the line, false otherwise" do - s = StringScanner.new("This is a test") - s.send(@method).should == true - s.scan(/This/) - s.send(@method).should == false - s.terminate - s.send(@method).should == false - - s = StringScanner.new("hello\nworld") - s.bol?.should == true - s.scan(/\w+/) - s.bol?.should == false - s.scan(/\n/) - s.bol?.should == true - s.unscan - s.bol?.should == false - end - - it "returns true if the scan pointer is at the end of the line of an empty string." do - s = StringScanner.new('') - s.terminate - s.send(@method).should == true - end -end diff --git a/spec/ruby/library/stringscanner/shared/concat.rb b/spec/ruby/library/stringscanner/shared/concat.rb deleted file mode 100644 index 8138b0f8dc..0000000000 --- a/spec/ruby/library/stringscanner/shared/concat.rb +++ /dev/null @@ -1,30 +0,0 @@ -describe :strscan_concat, shared: true do - it "concatenates the given argument to self and returns self" do - s = StringScanner.new(+"hello ") - s.send(@method, 'world').should == s - s.string.should == "hello world" - s.eos?.should == false - end - - it "raises a TypeError if the given argument can't be converted to a String" do - -> { StringScanner.new('hello').send(@method, :world) }.should.raise(TypeError) - -> { StringScanner.new('hello').send(@method, mock('x')) }.should.raise(TypeError) - end -end - -describe :strscan_concat_fixnum, shared: true do - it "raises a TypeError" do - a = StringScanner.new("hello world") - -> { a.send(@method, 333) }.should.raise(TypeError) - b = StringScanner.new("") - -> { b.send(@method, (256 * 3 + 64)) }.should.raise(TypeError) - -> { b.send(@method, -200) }.should.raise(TypeError) - end - - it "doesn't call to_int on the argument" do - x = mock('x') - x.should_not_receive(:to_int) - - -> { StringScanner.new("").send(@method, x) }.should.raise(TypeError) - end -end diff --git a/spec/ruby/library/stringscanner/shared/pos.rb b/spec/ruby/library/stringscanner/shared/pos.rb deleted file mode 100644 index 91f80fdf08..0000000000 --- a/spec/ruby/library/stringscanner/shared/pos.rb +++ /dev/null @@ -1,59 +0,0 @@ -describe :strscan_pos, shared: true do - before :each do - @s = StringScanner.new("This is a test") - end - - it "returns the position of the scan pointer" do - @s.send(@method).should == 0 - @s.scan_until(/This is/) - @s.send(@method).should == 7 - @s.get_byte - @s.send(@method).should == 8 - @s.terminate - @s.send(@method).should == 14 - end - - it "returns 0 in the reset position" do - @s.reset - @s.send(@method).should == 0 - end - - it "returns the length of the string in the terminate position" do - @s.terminate - @s.send(@method).should == @s.string.length - end - - it "is not multi-byte character sensitive" do - s = StringScanner.new("abcädeföghi") - - s.scan_until(/ö/) - s.pos.should == 10 - end -end - -describe :strscan_pos_set, shared: true do - before :each do - @s = StringScanner.new("This is a test") - end - - it "modify the scan pointer" do - @s.send(@method, 5) - @s.rest.should == "is a test" - end - - it "positions from the end if the argument is negative" do - @s.send(@method, -2) - @s.rest.should == "st" - @s.pos.should == 12 - end - - it "raises a RangeError if position too far backward" do - -> { - @s.send(@method, -20) - }.should.raise(RangeError) - end - - it "raises a RangeError when the passed argument is out of range" do - -> { @s.send(@method, 20) }.should.raise(RangeError) - end -end |
