<commit_before>require File.dirname(__FILE__) + '/../../spec_helper'

describe "CType#toprint" do
  it "returns escaped control characters" do
    a = []
    [?\n, ?\t, ?\a, ?\v, ?\f, ?\r, ?\e, ?\b].each { |c| a << c.toprint }
    a.should == ["\\n", "\\t", "\\a", "\\v", "\\f", "\\r", "\\e", "\\b"]
  end

  it "returns '\\\"' for '?\"'" do
    ?".toprint.should == "\\\""
  end

  it "returns '\\\\' for '?\\'" do
    ?\\.toprint.should == "\\\\"
  end

  it "returns '\\#' for '?#'" do
    ?#.toprint.should == "\\#"
  end

  it "returns an octal value for values 0..31 except for control characters" do
    a = []
    (0..31).each { |c| a << c.toprint }
    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 { |c| c.toprint.should == ("\\%03o" % c.to_s(8).oct) }
  end

  it "returns a regular character values 32..126 except for \\, \#, \"" do
    (32..126).each { |c| c.toprint.should == c.chr unless "\\\#\"".include? c.chr }
  end
end<commit_msg>Updated CType specs for '#' String#inspect mapping.<commit_after>require File.dirname(__FILE__) + '/../../spec_helper'

describe "CType#toprint" do
  it "returns escaped control characters" do
    a = []
    [?\n, ?\t, ?\a, ?\v, ?\f, ?\r, ?\e, ?\b].each { |c| a << c.toprint }
    a.should == ["\\n", "\\t", "\\a", "\\v", "\\f", "\\r", "\\e", "\\b"]
  end

  it "returns '\\\"' for '?\"'" do
    ?".toprint.should == "\\\""
  end

  it "returns '\\\\' for '?\\'" do
    ?\\.toprint.should == "\\\\"
  end

  it "returns a table of transforms for '?#'" do
    table = Rubinius::Tuple['#$', '\#$', '#@', '\#@', '#{', '\#{', '#', '#']
    ?#.toprint.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 << c.toprint }
    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 { |c| c.toprint.should == ("\\%03o" % c.to_s(8).oct) }
  end

  it "returns a regular character values 32..126 except for \\, \#, \"" do
    (32..126).each { |c| c.toprint.should == c.chr unless "\\\#\"".include? c.chr }
  end
end
{'fraction_non_alphanumeric': 0.3239693542502736, 'fraction_numerical': 0.07515505290040131, 'mean_word_length': 1.9934497816593886, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '645078', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1065, 'n_words': 287}