<commit_before>require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))

require 'tempfile'

GirFFI.setup :Regress

describe "Pretty-printing" do
  describe "for the Regress module" do
    it "runs without throwing an exception" do
      Regress._builder.pretty_print
    end

    it "results in valid Ruby" do
      tmp = Tempfile.new "gir_ffi"
      tmp.write Regress._builder.pretty_print
      tmp.flush
      is_ok = `ruby -c #{tmp.path}`
      assert_equal "Syntax OK\n", is_ok
    end
  end
end<commit_msg>Add failing test for syntax validity of pretty_printed GLib module.<commit_after>require File.expand_path('../gir_ffi_test_helper.rb', File.dirname(__FILE__))

require 'tempfile'

GirFFI.setup :Regress

describe "Pretty-printing" do
  def assert_syntax_ok str
    tmp = Tempfile.new "gir_ffi"
    tmp.write str
    tmp.flush
    is_ok = `ruby -c #{tmp.path} 2>&1`
    assert_equal "Syntax OK\n", is_ok
  end

  describe "for the Regress module" do
    it "runs without throwing an exception" do
      Regress._builder.pretty_print
    end

    it "results in valid Ruby" do
      assert_syntax_ok Regress._builder.pretty_print
    end
  end

  describe "for the GLib module" do
    it "results in valid Ruby" do
      assert_syntax_ok GLib._builder.pretty_print
    end
  end
end
{'fraction_non_alphanumeric': 0.08453922315308454, 'fraction_numerical': 0.0015232292460015233, 'mean_word_length': 3.238709677419355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '1994574', 'n_tokens_mistral': 458, 'n_tokens_neox': 437, 'n_words': 127}