summaryrefslogtreecommitdiff
path: root/spec/ruby/library/stringscanner/getch_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/stringscanner/getch_spec.rb')
-rw-r--r--spec/ruby/library/stringscanner/getch_spec.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/spec/ruby/library/stringscanner/getch_spec.rb b/spec/ruby/library/stringscanner/getch_spec.rb
index c9c3eb6fd3..cd41b4336a 100644
--- a/spec/ruby/library/stringscanner/getch_spec.rb
+++ b/spec/ruby/library/stringscanner/getch_spec.rb
@@ -11,6 +11,13 @@ describe "StringScanner#getch" do
s.getch.should == "c"
end
+ it "scans newlines too" do
+ s = StringScanner.new("a\nc")
+ s.getch.should == "a"
+ s.getch.should == "\n"
+ s.getch.should == "c"
+ end
+
it "is multi-byte character sensitive" do
# Japanese hiragana "A" in EUC-JP
src = "\244\242".dup.force_encoding("euc-jp")
@@ -33,22 +40,20 @@ describe "StringScanner#getch" do
describe "#[] successive call with a capture group name" do
# https://github.com/ruby/strscan/issues/139
- ruby_version_is ""..."3.5" do # Don't run on 3.5.0dev that already contains not released fixes
version_is StringScanner::Version, "3.1.1"..."3.1.3" do # ruby_version_is "3.4.0"..."3.4.3"
it "returns nil" do
s = StringScanner.new("This is a test")
s.getch
s.should.matched?
- s[:a].should be_nil
+ s[:a].should == nil
end
end
- end
version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.3"
it "raises IndexError" do
s = StringScanner.new("This is a test")
s.getch
s.should.matched?
- -> { s[:a] }.should raise_error(IndexError)
+ -> { s[:a] }.should.raise(IndexError)
end
end
@@ -59,7 +64,6 @@ describe "StringScanner#getch" do
end
# https://github.com/ruby/strscan/issues/135
- ruby_version_is ""..."3.5" do # Don't run on 3.5.0dev that already contains not released fixes
version_is StringScanner::Version, "3.1.1"..."3.1.3" do # ruby_version_is "3.4.0"..."3.4.3"
it "ignores the previous matching with Regexp" do
s = StringScanner.new("This is a test")
@@ -70,10 +74,9 @@ describe "StringScanner#getch" do
s.getch
s.should.matched?
- s[:a].should be_nil
+ s[:a].should == nil
end
end
- end
version_is StringScanner::Version, "3.1.3" do # ruby_version_is "3.4.0"..."3.4.3"
it "ignores the previous matching with Regexp" do
s = StringScanner.new("This is a test")
@@ -84,7 +87,7 @@ describe "StringScanner#getch" do
s.getch
s.should.matched?
- -> { s[:a] }.should raise_error(IndexError)
+ -> { s[:a] }.should.raise(IndexError)
end
end
end