blob: a97c26af83fc3a711305e49ba7d36e3248595048 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
require_relative '../../spec_helper'
require 'strscan'
describe "StringScanner#check" do
before :each do
@s = StringScanner.new("This is a test")
end
it "returns the value that scan would return, without advancing the scan pointer" do
@s.check(/This/).should == "This"
@s.matched.should == "This"
@s.pos.should == 0
@s.check(/is/).should == nil
@s.matched.should == nil
end
it "treats String as the pattern itself" do
@s.check("This").should == "This"
@s.matched.should == "This"
@s.pos.should == 0
@s.check(/is/).should == nil
@s.matched.should == nil
end
end
|