diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-09-20 20:18:52 +0000 |
commit | 1d15d5f08032acf1b7bceacbb450d617ff6e0931 (patch) | |
tree | a3785a79899302bc149e4a6e72f624ac27dc1f10 /spec/rubyspec/library/stringscanner/shared | |
parent | 75bfc6440d595bf339007f4fb280fd4d743e89c1 (diff) |
Move spec/rubyspec to spec/ruby for consistency
* Other ruby implementations use the spec/ruby directory.
[Misc #13792] [ruby-core:82287]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/rubyspec/library/stringscanner/shared')
11 files changed, 0 insertions, 291 deletions
diff --git a/spec/rubyspec/library/stringscanner/shared/bol.rb b/spec/rubyspec/library/stringscanner/shared/bol.rb deleted file mode 100644 index ebcdd7938f..0000000000 --- a/spec/rubyspec/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 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 diff --git a/spec/rubyspec/library/stringscanner/shared/concat.rb b/spec/rubyspec/library/stringscanner/shared/concat.rb deleted file mode 100644 index 28788d3ff1..0000000000 --- a/spec/rubyspec/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 be_false - end - - it "raises a TypeError if the given argument can't be converted to a String" do - lambda { StringScanner.new('hello').send(@method, :world) }.should raise_error(TypeError) - lambda { StringScanner.new('hello').send(@method, mock('x')) }.should raise_error(TypeError) - end -end - -describe :strscan_concat_fixnum, shared: true do - it "raises a TypeError" do - a = StringScanner.new("hello world") - lambda { a.send(@method, 333) }.should raise_error(TypeError) - b = StringScanner.new("") - lambda { b.send(@method, (256 * 3 + 64)) }.should raise_error(TypeError) - lambda { b.send(@method, -200) }.should raise_error(TypeError) - end - - it "doesn't call to_int on the argument" do - x = mock('x') - x.should_not_receive(:to_int) - - lambda { "".send(@method, x) }.should raise_error(TypeError) - end -end diff --git a/spec/rubyspec/library/stringscanner/shared/eos.rb b/spec/rubyspec/library/stringscanner/shared/eos.rb deleted file mode 100644 index ea04c764a2..0000000000 --- a/spec/rubyspec/library/stringscanner/shared/eos.rb +++ /dev/null @@ -1,17 +0,0 @@ -describe :strscan_eos, shared: true do - before :each do - @s = StringScanner.new("This is a test") - end - - it "returns true if the scan pointer is at the end of the string" do - @s.terminate - @s.send(@method).should be_true - - s = StringScanner.new('') - s.send(@method).should be_true - end - - it "returns false if the scan pointer is not at the end of the string" do - @s.send(@method).should be_false - end -end diff --git a/spec/rubyspec/library/stringscanner/shared/extract_range.rb b/spec/rubyspec/library/stringscanner/shared/extract_range.rb deleted file mode 100644 index 7e98540b1a..0000000000 --- a/spec/rubyspec/library/stringscanner/shared/extract_range.rb +++ /dev/null @@ -1,22 +0,0 @@ -describe :extract_range, shared: true do - it "returns an instance of String when passed a String subclass" do - cls = Class.new(String) - sub = cls.new("abc") - - s = StringScanner.new(sub) - ch = s.send(@method) - ch.should_not be_kind_of(cls) - ch.should be_an_instance_of(String) - end - - it "taints the returned String if the input was tainted" do - str = 'abc' - str.taint - - s = StringScanner.new(str) - - s.send(@method).tainted?.should be_true - s.send(@method).tainted?.should be_true - s.send(@method).tainted?.should be_true - end -end diff --git a/spec/rubyspec/library/stringscanner/shared/extract_range_matched.rb b/spec/rubyspec/library/stringscanner/shared/extract_range_matched.rb deleted file mode 100644 index fe695e8ac1..0000000000 --- a/spec/rubyspec/library/stringscanner/shared/extract_range_matched.rb +++ /dev/null @@ -1,22 +0,0 @@ -describe :extract_range_matched, shared: true do - it "returns an instance of String when passed a String subclass" do - cls = Class.new(String) - sub = cls.new("abc") - - s = StringScanner.new(sub) - s.scan(/\w{1}/) - - ch = s.send(@method) - ch.should_not be_kind_of(cls) - ch.should be_an_instance_of(String) - end - - it "taints the returned String if the input was tainted" do - str = 'abc' - str.taint - - s = StringScanner.new(str) - s.scan(/\w{1}/) - s.send(@method).tainted?.should be_true - end -end diff --git a/spec/rubyspec/library/stringscanner/shared/get_byte.rb b/spec/rubyspec/library/stringscanner/shared/get_byte.rb deleted file mode 100644 index 763ab6f4a4..0000000000 --- a/spec/rubyspec/library/stringscanner/shared/get_byte.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -*- encoding: binary -*- -describe :strscan_get_byte, shared: true do - it "scans one byte and returns it" do - s = StringScanner.new('abc5.') - s.send(@method).should == 'a' - s.send(@method).should == 'b' - s.send(@method).should == 'c' - s.send(@method).should == '5' - s.send(@method).should == '.' - end - - it "is not multi-byte character sensitive" do - s = StringScanner.new("\244\242") - s.send(@method).should == "\244" - s.send(@method).should == "\242" - end - - it "returns nil at the end of the string" do - # empty string case - s = StringScanner.new('') - s.send(@method).should == nil - s.send(@method).should == nil - - # non-empty string case - s = StringScanner.new('a') - s.send(@method) # skip one - s.send(@method).should == nil - end -end diff --git a/spec/rubyspec/library/stringscanner/shared/matched_size.rb b/spec/rubyspec/library/stringscanner/shared/matched_size.rb deleted file mode 100644 index 92174733f7..0000000000 --- a/spec/rubyspec/library/stringscanner/shared/matched_size.rb +++ /dev/null @@ -1,21 +0,0 @@ -describe :strscan_matched_size, shared: true do - before :each do - @s = StringScanner.new("This is a test") - end - - it "returns the size of the most recent match" do - @s.check(/This/) - @s.send(@method).should == 4 - @s.send(@method).should == 4 - @s.scan(//) - @s.send(@method).should == 0 - end - - it "returns nil if there was no recent match" do - @s.send(@method).should == nil - @s.check(/\d+/) - @s.send(@method).should == nil - @s.terminate - @s.send(@method).should == nil - end -end diff --git a/spec/rubyspec/library/stringscanner/shared/peek.rb b/spec/rubyspec/library/stringscanner/shared/peek.rb deleted file mode 100644 index 418ebb6536..0000000000 --- a/spec/rubyspec/library/stringscanner/shared/peek.rb +++ /dev/null @@ -1,47 +0,0 @@ -describe :strscan_peek, shared: true do - before :each do - @s = StringScanner.new('This is a test') - end - - it "returns at most the specified number of bytes from the current position" do - @s.send(@method, 4).should == "This" - @s.pos.should == 0 - @s.pos = 5 - @s.send(@method, 2).should == "is" - @s.send(@method, 1000).should == "is a test" - - s = StringScanner.new("été") - s.send(@method, 2).should == "é" - end - - it "returns an empty string when the passed argument is zero" do - @s.send(@method, 0).should == "" - end - - it "raises a ArgumentError when the passed argument is negative" do - lambda { @s.send(@method, -2) }.should raise_error(ArgumentError) - end - - it "raises a RangeError when the passed argument is a Bignum" do - lambda { @s.send(@method, bignum_value) }.should raise_error(RangeError) - end - - it "returns an instance of String when passed a String subclass" do - cls = Class.new(String) - sub = cls.new("abc") - - s = StringScanner.new(sub) - - ch = s.send(@method, 1) - ch.should_not be_kind_of(cls) - ch.should be_an_instance_of(String) - end - - it "taints the returned String if the input was tainted" do - str = 'abc' - str.taint - - s = StringScanner.new(str) - s.send(@method, 1).tainted?.should be_true - end -end diff --git a/spec/rubyspec/library/stringscanner/shared/pos.rb b/spec/rubyspec/library/stringscanner/shared/pos.rb deleted file mode 100644 index 80ded17b0f..0000000000 --- a/spec/rubyspec/library/stringscanner/shared/pos.rb +++ /dev/null @@ -1,52 +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 -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 - lambda { - @s.send(@method, -20) - }.should raise_error(RangeError) - end - - it "raises a RangeError when the passed argument is out of range" do - lambda { @s.send(@method, 20) }.should raise_error(RangeError) - end -end diff --git a/spec/rubyspec/library/stringscanner/shared/rest_size.rb b/spec/rubyspec/library/stringscanner/shared/rest_size.rb deleted file mode 100644 index 4c4f49e45c..0000000000 --- a/spec/rubyspec/library/stringscanner/shared/rest_size.rb +++ /dev/null @@ -1,18 +0,0 @@ -describe :strscan_rest_size, shared: true do - before :each do - @s = StringScanner.new('This is a test') - end - - it "returns the length of the rest of the string" do - @s.send(@method).should == 14 - @s.scan(/This/) - @s.send(@method).should == 10 - @s.terminate - @s.send(@method).should == 0 - end - - it "is equivalent to rest.size" do - @s.scan(/This/) - @s.send(@method).should == @s.rest.size - end -end diff --git a/spec/rubyspec/library/stringscanner/shared/terminate.rb b/spec/rubyspec/library/stringscanner/shared/terminate.rb deleted file mode 100644 index bf41d097e2..0000000000 --- a/spec/rubyspec/library/stringscanner/shared/terminate.rb +++ /dev/null @@ -1,8 +0,0 @@ -describe :strscan_terminate, shared: true do - it "set the scan pointer to the end of the string and clear matching data." do - s = StringScanner.new('This is a test') - s.send(@method) - s.bol?.should be_false - s.eos?.should be_true - end -end |