Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix CType#toprint 1.9 specs

  • Loading branch information...
commit 4b8233ac2db2f9c17d0c0bbd9ddb2b78db089e3d 1 parent a1df233
@ileitch ileitch authored
Showing with 33 additions and 12 deletions.
  1. +33 −12 spec/core/ctype/toprint_spec.rb
View
45 spec/core/ctype/toprint_spec.rb
@@ -24,20 +24,41 @@
Rubinius::CType.toprint(35).to_a.should == table.to_a
end
- it "returns an octal value for values 0..31 except for control characters" do
- a = []
- (0..31).each { |c| a << Rubinius::CType.toprint(c) }
- a.should == [
- "\\000", "\\001", "\\002", "\\003", "\\004", "\\005", "\\006",
- "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\016", "\\017",
- "\\020", "\\021", "\\022", "\\023", "\\024", "\\025", "\\026",
- "\\027", "\\030", "\\031", "\\032", "\\e", "\\034", "\\035", "\\036", "\\037"
- ]
+ ruby_version_is ""..."1.9" do
+ it "returns an octal value for values 0..31 except for control characters" do
+ a = []
+ (0..31).each { |c| a << Rubinius::CType.toprint(c) }
+ a.should == [
+ "\\000", "\\001", "\\002", "\\003", "\\004", "\\005", "\\006",
+ "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\016", "\\017",
+ "\\020", "\\021", "\\022", "\\023", "\\024", "\\025", "\\026",
+ "\\027", "\\030", "\\031", "\\032", "\\e", "\\034", "\\035", "\\036", "\\037"
+ ]
+ end
+
+ it "returns the octal value for values 127..255" do
+ (127..255).each do |c|
+ Rubinius::CType.toprint(c).should == ("\\%03o" % c.to_s(8).oct)
+ end
+ end
end
- it "returns the octal value for values 127..255" do
- (127..255).each do |c|
- Rubinius::CType.toprint(c).should == ("\\%03o" % c.to_s(8).oct)
+ ruby_version_is "1.9" do
+ it "returns an hex value for values 0..31 except for control characters" do
+ a = []
+ (0..31).each { |c| a << Rubinius::CType.toprint(c) }
+ a.should == [
+ "\\x00", "\\x01", "\\x02", "\\x03", "\\x04", "\\x05", "\\x06",
+ "\\a", "\\b", "\\t", "\\n", "\\v", "\\f", "\\r", "\\x0E", "\\x0F",
+ "\\x10", "\\x11", "\\x12", "\\x13", "\\x14", "\\x15", "\\x16", "\\x17",
+ "\\x18", "\\x19", "\\x1A", "\\e", "\\x1C", "\\x1D", "\\x1E", "\\x1F"
+ ]
+ end
+
+ it "returns the hex value for values 127..255" do
+ (127..255).each do |c|
+ Rubinius::CType.toprint(c).should == ("\\x%02X" % c.to_s(16).hex)
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.