Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 33 lines (25 sloc) 0.81 kb
957c2c9 @brixen Standardize require lines.
brixen authored
1 require File.expand_path('../../../spec_helper', __FILE__)
32df23d @runpaint String#ord: Specify 1.8.8+ method.
runpaint authored
2
74e5245 @brixen Added with_feature guards to String for encoding.
brixen authored
3 with_feature :encoding do
32df23d @runpaint String#ord: Specify 1.8.8+ method.
runpaint authored
4 describe "String#ord" do
5 it "returns a Fixnum" do
6 'a'.ord.should be_an_instance_of(Fixnum)
7 end
8
9 it "returns the codepoint of the first character in the String" do
10 'a'.ord.should == 97
11 end
12
13
14 it "ignores subsequent characters" do
15 "\u{287}a".ord.should == "\u{287}".ord
16 end
17
18 ruby_version_is "1.9" do
19 it "understands multibyte characters" do
20 "\u{9879}".ord.should == 39033
21 end
22
23 it "is equivalent to #codepoints.first" do
24 "\u{981}\u{982}".ord.should == "\u{981}\u{982}".codepoints.first
25 end
26 end
27
28 it "raises an ArgumentError if called on an empty String" do
29 lambda { ''.ord }.should raise_error(ArgumentError)
30 end
31 end
32 end
Something went wrong with that request. Please try again.