diff options
Diffstat (limited to 'spec/ruby/library/stringscanner/shared/bol.rb')
-rw-r--r-- | spec/ruby/library/stringscanner/shared/bol.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/spec/ruby/library/stringscanner/shared/bol.rb b/spec/ruby/library/stringscanner/shared/bol.rb new file mode 100644 index 0000000000..ebcdd7938f --- /dev/null +++ b/spec/ruby/library/stringscanner/shared/bol.rb @@ -0,0 +1,25 @@ +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 be_true + s.scan(/This/) + s.send(@method).should be_false + s.terminate + s.send(@method).should be_false + + s = StringScanner.new("hello\nworld") + s.bol?.should be_true + s.scan(/\w+/) + s.bol?.should be_false + s.scan(/\n/) + s.bol?.should be_true + s.unscan + s.bol?.should be_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 be_true + end +end |