<commit_before>shared_context 'requires render thread' do
  before(:all) do
    # We can't use rspec mocks in before(:all)

    # Subclass MixerApplication to noop some methods.
    # Also make start() wait until render thread is actually started
    class MixerApplicationMock < RenderMix::MixerApplication
      attr_reader :mixer
      attr_reader :root_visual_context
      attr_reader :visual_context_manager
      attr_reader :root_audio_context
      attr_reader :audio_context_manager

      def initialize(mixer, asset_locations)
        super
      end
      def simpleInitApp
        super
        @mutex.synchronize { @condvar.signal }
      end
      def simpleUpdate(tpf); end
      def simpleRender(render_manager); end
      def start
        super
        @mutex.synchronize { @condvar.wait(@mutex) }
      end
    end

    class MixerMock < RenderMix::Mixer
      attr_reader :app
      attr_reader :tpf
      def initialize(width, height, framerate)
        super
        @tpf = framerate.denominator / framerate.numerator.to_f
        @app = create_mixer_application
      end
      def create_mixer_application
        MixerApplicationMock.new(self, @asset_locations)
      end
    end

    mixer = MixerMock.new(640, 480, Rational(30))
    @app = mixer.app
    @app.start
  end

  def on_render_thread(&block)
    result = @app.enqueue(&block)
    result.get
=begin XXX This sometimes rescues 'nil' http://stackoverflow.com/questions/8947954/jruby-makes-rescue-exception-nil-with-rescue-javasystem-out

  rescue java.util.concurrent.ExecutionException => e
    raise e.cause
=end
  end

  after(:all) do
    # Stop and wait for the app to finish
    @app.stop(true)
  end
end
<commit_msg>Run specs with offscreen surface.<commit_after>shared_context 'requires render thread' do
  before(:all) do
    # We can't use rspec mocks in before(:all)

    # Subclass MixerApplication to noop some methods.
    # Also make start() wait until render thread is actually started
    class MixerApplicationMock < RenderMix::MixerApplication
      attr_reader :mixer
      attr_reader :root_visual_context
      attr_reader :visual_context_manager
      attr_reader :root_audio_context
      attr_reader :audio_context_manager

      def initialize(mixer, asset_locations)
        super
      end
      def simpleInitApp
        super
        @mutex.synchronize { @condvar.signal }
      end
      def simpleUpdate(tpf); end
      def simpleRender(render_manager); end
      def start
        super(RenderMix::Jme::System::JmeContext::Type::OffscreenSurface)
        @mutex.synchronize { @condvar.wait(@mutex) }
      end
      def shutdown
        @mutex.synchronize do
          stop
          @condvar.wait(@mutex)
        end
      end
    end

    class MixerMock < RenderMix::Mixer
      attr_reader :app
      attr_reader :tpf
      def initialize(width, height, framerate)
        super
        @tpf = framerate.denominator / framerate.numerator.to_f
        @app = create_mixer_application
      end
      def create_mixer_application
        MixerApplicationMock.new(self, @asset_locations)
      end
    end

    mixer = MixerMock.new(640, 480, Rational(30))
    @app = mixer.app
    @app.start
  end

  def on_render_thread(&block)
    result = @app.enqueue(&block)
    result.get
=begin XXX This sometimes rescues 'nil' http://stackoverflow.com/questions/8947954/jruby-makes-rescue-exception-nil-with-rescue-javasystem-out

  rescue java.util.concurrent.ExecutionException => e
    raise e.cause
=end
  end

  after(:all) do
    # Stop and wait for the app to finish
    @app.shutdown
  end
end

{'fraction_non_alphanumeric': 0.07577433628318585, 'fraction_numerical': 0.008296460176991151, 'mean_word_length': 2.75987525987526, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, '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': '494207', 'n_tokens_mistral': 1129, 'n_tokens_neox': 1078, 'n_words': 274}