<commit_before>require 'rdf/spec'

RSpec.shared_examples 'an RDF::Repository' do
  include RDF::Spec::Matchers

  before :each do
    raise 'repository must be set with `let(:repository)' unless
      defined? repository

    @statements = RDF::Spec.quads
    if repository.empty? && repository.writable?
      repository.insert(*@statements)
    elsif repository.empty?
      raise "+@repository+ must respond to #<< or be pre-populated with the statements in #{RDF::Spec::TRIPLES_FILE} in a before(:each) block"
    end
  end

  let(:mutable) { repository }
  let(:dataset) { repository.supports?(:snapshots) ? repository.snapshot : repository }
  subject { repository }

  context 'as dataset' do
    require 'rdf/spec/dataset'
    it_behaves_like 'an RDF::Dataset'
  end

  context 'as transactable' do
    require 'rdf/spec/transactable'
    let(:transactable) { repository }
    it_behaves_like 'an RDF::Transactable'
  end
  
  context "when updating" do
    require 'rdf/spec/mutable'

    before { mutable.clear if mutable.mutable? }
    it_behaves_like 'an RDF::Mutable'
    
    describe '#delete_insert' do
      it 'updates transactionally' do
        if mutable.mutable? & mutable.supports?(:atomic_write)
          expect(mutable).to receive(:commit_transaction).and_call_original
          statement = RDF::Statement(:s, RDF::URI.new("urn:predicate:1"), :o)
                                    
          mutable.delete_insert([statement], [statement])
        end
      end
    end
  end

  describe "#transaction" do
    it 'gives an immutable transaction' do
      expect { subject.transaction { insert([]) } }.to raise_error TypeError<commit_msg>Use logical-and, not bit-wise and when checking for supporting atomic writes.<commit_after>require 'rdf/spec'

RSpec.shared_examples 'an RDF::Repository' do
  include RDF::Spec::Matchers

  before :each do
    raise 'repository must be set with `let(:repository)' unless
      defined? repository

    @statements = RDF::Spec.quads
    if repository.empty? && repository.writable?
      repository.insert(*@statements)
    elsif repository.empty?
      raise "+@repository+ must respond to #<< or be pre-populated with the statements in #{RDF::Spec::TRIPLES_FILE} in a before(:each) block"
    end
  end

  let(:mutable) { repository }
  let(:dataset) { repository.supports?(:snapshots) ? repository.snapshot : repository }
  subject { repository }

  context 'as dataset' do
    require 'rdf/spec/dataset'
    it_behaves_like 'an RDF::Dataset'
  end

  context 'as transactable' do
    require 'rdf/spec/transactable'
    let(:transactable) { repository }
    it_behaves_like 'an RDF::Transactable'
  end
  
  context "when updating" do
    require 'rdf/spec/mutable'

    before { mutable.clear if mutable.mutable? }
    it_behaves_like 'an RDF::Mutable'
    
    describe '#delete_insert' do
      it 'updates transactionally' do
        if mutable.mutable? && mutable.supports?(:atomic_writes)
          expect(mutable).to receive(:commit_transaction).and_call_original
          statement = RDF::Statement(:s, RDF::URI.new("urn:predicate:1"), :o)

          mutable.delete_insert([statement], [statement])
        end
      end
    end
  end

  describe "#transaction" do
    it 'gives an immutable transaction' do
      expect { subject.transaction { insert([]) } }.to raise_error TypeError
{'fraction_non_alphanumeric': 0.10916121356335515, 'fraction_numerical': 0.000594883997620464, 'mean_word_length': 3.3449612403100777, 'pattern_counts': {'":': 0, '<': 7, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1974113', 'n_tokens_mistral': 1028, 'n_tokens_neox': 1011, 'n_words': 265}