diff options
author | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-21 15:38:59 +0000 |
---|---|---|
committer | eregon <eregon@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-02-21 15:38:59 +0000 |
commit | da7976235fbc2986925969646071bebe3702e49f (patch) | |
tree | 83bbf6a8e03cf990369feabe6c1c9d45c69f4c85 /spec/ruby/core/string/shared | |
parent | b8e389a0f3226c90e96e02e6396686a3bef6a456 (diff) |
Update to ruby/spec@7a16e01
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'spec/ruby/core/string/shared')
-rw-r--r-- | spec/ruby/core/string/shared/codepoints.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/spec/ruby/core/string/shared/codepoints.rb b/spec/ruby/core/string/shared/codepoints.rb index 589d2ee1d0..84a0e3ae39 100644 --- a/spec/ruby/core/string/shared/codepoints.rb +++ b/spec/ruby/core/string/shared/codepoints.rb @@ -1,5 +1,11 @@ # -*- encoding: binary -*- describe :string_codepoints, shared: true do + it "returns self" do + s = "foo" + result = s.send(@method) {} + result.should equal s + end + it "raises an ArgumentError when self has an invalid encoding and a method is called on the returned Enumerator" do s = "\xDF".force_encoding(Encoding::UTF_8) s.valid_encoding?.should be_false @@ -20,13 +26,13 @@ describe :string_codepoints, shared: true do lambda { s.send(@method) { } }.should raise_error(ArgumentError) end - it "returns codepoints as Fixnums" do + it "yields codepoints as Fixnums" do "glark\u{20}".send(@method).to_a.each do |codepoint| codepoint.should be_an_instance_of(Fixnum) end end - it "returns one codepoint for each character" do + it "yields one codepoint for each character" do s = "\u{9876}\u{28}\u{1987}" s.send(@method).to_a.size.should == s.chars.to_a.size end @@ -37,7 +43,7 @@ describe :string_codepoints, shared: true do s.send(@method).to_a.should == [38937] end - it "returns the codepoint corresponding to the character's position in the String's encoding" do + it "yields the codepoints corresponding to the character's position in the String's encoding" do "\u{787}".send(@method).to_a.should == [1927] end |