diff options
Diffstat (limited to 'spec/ruby/core/string/shared/codepoints.rb')
-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 |