text:
var Slideshow = {};

Slideshow.Options = {
  effectPairs: {
    appear: ['Appear',    'Fade'],
    grow:   ['Grow',      'Shrink'],
    blind:  ['BlindDown', 'BlindUp'],
    slide:  ['SlideDown', 'SlideUp']
  },
  defaults: {
    minFrames:      2,
    delay:          5,
    randomize:      false,
    repeat:         false,
    effectPair:     'appear',
    showEffect:     null,
    showOptions:    {},
    hideEffect:     null,
    hideOptions:    {},
    beforeChange:   null,
    afterChange:    null,
    startPaused:    false
  }
};

Effect.Slideshow = Class.create();
Object.extend(Object.extend(Effect.Slideshow.prototype, Effect.Base.prototype), {
  initialize: function (element, options) {
    this.element = $(element);
    this._shared_initialize(options);
  },
  _shared_initialize: function (options) {
    Element.cleanWhitespace(this.element);

    this.options = Slideshow.Options.defaults;
    Object.extend(this.options, options);
    if (this.options.showEffect && this.options.hideEffect) {
      this._effectPair = { show: null, hide: null };
      for (var direction in this._effectPair) {
        var effect = this.options[direction + 'Effect'];
        if (typeof effect == 'function') {
          this._effectPair[direction] = effect;
        }
        else {
          this._effectPair[direction] = this._effectHandler[effect];
        }
      }
    }
    else if (this.options.effectPair == 'random') {
      this._usedEffectPairs    = [];
      this._unusedEffectPairs  = [];
      for (type in Slideshow.Options.effectPairs) {
        this._unusedEffectPairs.push(type);
      }
    }
    else if (Slideshow.Options.effectPairs[this.options.effectPair]) {
      this._effectPair = this._buildEffectPair(Slideshow.Options.effectPairs[this.options.effectPair]);
    }
    else {
      throw('Slideshow requires a valid effectPair or showEffect AND hideEffect to work');
    }
    this.options.delay = parseInt(this.options.delay * 1000);
    this._isRandom = this.options.randomize;

    var showTime = parseInt((this.options.showOptions.duration || 1.0) * 1000);
    var hideTime = parseInt((this.options.hideOptions.duration || 1.0) * 1000);
    if (showTime > hideTime) {
      this.options.delay += showTime;
    }
    else {
      this.options.delay += hideTime;
    }

    this._usedFrames   = [];
    this._unusedFrames = $A(this.element.childNodes);
    this._unusedFrames.each( function (el) { Element.hide(el); } );

    this.isPaused = this.options.startPaused || false;
    this.isDone   = false;
    this._nextFrame();
  },
  _effectHandler: function (effect) {
    var name = effect;
    return function (element, options) {
      new Effect[name](element, options);
    };
  },
  _buildEffectPair: function (presets) {
    return { show: this._effectHandler(presets[0]), hide: this._effectHandler(presets[1]) };
  },
  _getNextFrame: function () {
    if (! this._unusedFrames.length) {
      if (this.options.repeat && this._usedFrames.length) {
        this._unusedFrames = this._usedFrames;
        this._usedFrames   = [this._unusedFrames.pop()];
      }
      else {
        this.isDone = true;
        return null;
      }
    }

    var nextFrame = null;
    var numUnused = this._unusedFrames.length;
    if (this._isRandom && numUnused > 1) {
      var index = Math.floor(Math.random()*numUnused);
      nextFrame = this._unusedFrames[index];
      this._unusedFrames.splice(index, 1);
    }
    else {
      nextFrame = this._unusedFrames.shift();
    }
    this._usedFrames.push(nextFrame);

    return nextFrame;
  },
  _nextFrame: function () {
    if (! this.isPaused) {
      this._changeFrame();
    }
  },
  _changeFrame: function () {
    if (this.options.beforeChange) {
      this.options.beforeChange(this);
    }
    var newFrame = this._getNextFrame();
    if (newFrame) {
      if (this.options.effectPair == 'random') {
        if (! this._unusedEffectPairs.length) {
          this._unusedEffectPairs  = this._usedEffectPairs;
          this._usedEffectPairs    = [ this._unusedEffectPairs.pop() ];
        }
        if (this._unusedEffectPairs.length) {
          var index = Math.floor(Math.random()*this._unusedEffectPairs.length);
          var nextPair = this._unusedEffectPairs[index];
          this._unusedEffectPairs.splice(index, 1);
          this._usedEffectPairs.push(nextPair);
          this._effectPair = this._buildEffectPair(Slideshow.Options.effectPairs[nextPair]);
        }
        else {
          throw('Could not determine next random effectPair');
        }
      }
      var currZ = 1;
      if (this.currentFrame) {
        this.currentFrame.style.zIndex = (this.currentFrame.style && this.currentFrame.style.zIndex)
          ? this.currentFrame.style.zIndex : '1';
        currZ = parseInt(this.currentFrame.style.zIndex);
        this._effectPair['hide'](this.currentFrame, this.options.hideOptions);
      }
      newFrame.style.zIndex = '' + (++currZ);
      this._effectPair['show'](newFrame, this.options.showOptions);
      this.currentFrame = newFrame;

      if (this.options.afterChange) {
        this.options.afterChange(this);
      }

      if (! this.isPaused) {
        setTimeout(this._nextFrame.bind(this), this.options.delay);
      }
    }
  },
  pause: function () {
    this.isPaused = true;
  },
  play: function () {
    this.isPaused = false;
    this._isRandom = this.options.randomize;
    this._nextFrame();
  },
  goBack: function () {
    this._isRandom = false;
    this.pause();
    if (this._usedFrames.length > 1) {
      this._unusedFrames.unshift(this._usedFrames.pop());
      this._unusedFrames.unshift(this._usedFrames.pop());
    }
    else if (this.options.repeat) {
      this._unusedFrames.unshift(this._usedFrames.pop());
      this._unusedFrames.unshift(this._unusedFrames.pop());
    }
    this._changeFrame();
  },
  goForward: function () {
    this._isRandom = false;
    this.pause();
    this._changeFrame();
  },
  repeat: function () {
    this.options.repeat = true;
    if (this.isDone) {
      this.isDone = false;
      this._nextFrame();
    }
  },
  stopRepeating: function () {
    this.options.repeat = false;
  },
  addFrames: function(html) {
    var temp = document.createElement('DIV');
    temp.innerHTML = html;
    Element.cleanWhitespace(temp);
    var newChildren = temp.childNodes.length;
    for (var i=0; i<newChildren; i++) {
      var addedFrame = temp.childNodes[i];
      Element.hide(addedFrame);
      this.element.appendChild(addedFrame);
      this._unusedFrames.push(addedFrame);
    }
  }
} );

Ajax.Slideshow = Class.create();
Object.extend(Object.extend(Ajax.Slideshow.prototype, Effect.Slideshow.prototype), {
  initialize: function (element, url, options) {
    this.element    = $(element);
    this.url        = url;
    options             = options || {};
    this._doAjax    = true;
    if (options.beforeChange) {
      this._oldBeforeChange = options.beforeChange;
      options.beforeChange = function () { this._oldBeforeChange(this); this._requestFrames(); }.bind(this);
    }
    else {
      options.beforeChange = this._requestFrames.bind(this);
    }
    this._shared_initialize(options);
  },
  _requestFrames: function () {
    if (this._doAjax && this._unusedFrames.length <= this.options.minFrames) {
      new Ajax.Request(this.url, { method: 'get', onComplete: this._addFrames.bindAsEventListener(this) });
    }
  },
  _addFrames: function (request) {
    if (request.responseText) {
      this.addFrames(request.responseText);
      if (this.options.afterRequest) {
        this.options.afterRequest(this);
      }
      if (this.isDone) {
        this.isDone = false;
        this._nextFrame();
      }
    }
    else {
      // nothing returned means no more images to load, so stop trying
      this.stopRequesting();
    }
  },
  stopRequesting: function () {
    this.options.beforeChange = this._oldBeforeChange || null;
  },
  changeUrl: function (url) {
    this.url = url;
  }
} );

Slideshow.Local = Class.create();
Object.extend(Object.extend(Slideshow.Local.prototype, Effect.Slideshow.prototype), {
  initialize: function (element, frames, options) {
    this.element        = $(element);
    this._spareFrames   = frames;
    options             = options || {};
    if (options.beforeChange) {
      var _oldBeforeChange = options.beforeChange;
      options.beforeChange = function () { _oldBeforeChange(this); this._addFrames(); }.bind(this);
    }
    else {
      options.beforeChange = this._addFrames.bind(this);
    }
    this._shared_initialize(options);
  },
  _addFrames: function () {
    if (this._unusedFrames.length <= this.options.minFrames && this._spareFrames.length) {
      var newFrame = this._spareFrames.shift();
      if (newFrame.indexOf('<') == -1) {
        var img = document.createElement('IMG');
        img.src = newFrame;
        Element.hide(img);
        this.element.appendChild(img);
        this._unusedFrames.push(img);
      }
      else {
        this.addFrames(newFrame);
      }
    }
    else {
      this.options.beforeChange = this._oldBeforeChange || null;
    }
  }
} );

redpajama_set_name: RedPajamaGithub


text:
package fakes

import (
	"fmt"

	"github.com/youtube/vitess/go/sqltypes"
	"github.com/youtube/vitess/go/vt/tabletserver/queryservice"
	"github.com/youtube/vitess/go/vt/tabletserver/querytypes"
	"golang.org/x/net/context"

	querypb "github.com/youtube/vitess/go/vt/proto/query"
)

// ErrorQueryService is an implementation of QueryService that returns a
// configurable error for some of its methods.
//
// It is used as base for other, more specialised QueryService fakes e.g.
// StreamHealthQueryService.
type ErrorQueryService struct {
}

// Begin is part of QueryService interface
func (e *ErrorQueryService) Begin(ctx context.Context, target *querypb.Target) (int64, error) {
	return 0, fmt.Errorf("ErrorQueryService does not implement any method")
}

// Commit is part of QueryService interface
func (e *ErrorQueryService) Commit(ctx context.Context, target *querypb.Target, transactionID int64) error {
	return fmt.Errorf("ErrorQueryService does not implement any method")
}

// Rollback is part of QueryService interface
func (e *ErrorQueryService) Rollback(ctx context.Context, target *querypb.Target, transactionID int64) error {
	return fmt.Errorf("ErrorQueryService does not implement any method")
}

// Execute is part of QueryService interface
func (e *ErrorQueryService) Execute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, transactionID int64) (*sqltypes.Result, error) {
	return nil, fmt.Errorf("ErrorQueryService does not implement any method")
}

// StreamExecute is part of QueryService interface
func (e *ErrorQueryService) StreamExecute(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, sendReply func(*sqltypes.Result) error) error {
	return fmt.Errorf("ErrorQueryService does not implement any method")
}

// ExecuteBatch is part of QueryService interface
func (e *ErrorQueryService) ExecuteBatch(ctx context.Context, target *querypb.Target, queries []querytypes.BoundQuery, asTransaction bool, transactionID int64) ([]sqltypes.Result, error) {
	return nil, fmt.Errorf("ErrorQueryService does not implement any method")
}

// SplitQuery is part of QueryService interface
// TODO(erez): Remove once the migration to SplitQuery V2 is done.
func (e *ErrorQueryService) SplitQuery(ctx context.Context, target *querypb.Target, sql string, bindVariables map[string]interface{}, splitColumn string, splitCount int64) ([]querytypes.QuerySplit, error) {
	return nil, fmt.Errorf("ErrorQueryService does not implement any method")
}

// SplitQueryV2 is part of QueryService interface
func (e *ErrorQueryService) SplitQueryV2(
	ctx context.Context,
	target *querypb.Target,
	sql string,
	bindVariables map[string]interface{},
	splitColumns []string,
	splitCount int64,
	numRowsPerQueryPart int64,
	algorithm querypb.SplitQueryRequest_Algorithm,
) ([]querytypes.QuerySplit, error) {
	return nil, fmt.Errorf("ErrorQueryService does not implement any method")
}

// StreamHealthRegister is part of QueryService interface
func (e *ErrorQueryService) StreamHealthRegister(chan<- *querypb.StreamHealthResponse) (int, error) {
	return 0, fmt.Errorf("ErrorQueryService does not implement any method")
}

// StreamHealthUnregister is part of QueryService interface
func (e *ErrorQueryService) StreamHealthUnregister(int) error {
	return fmt.Errorf("ErrorQueryService does not implement any method")
}

// HandlePanic is part of QueryService interface
func (e *ErrorQueryService) HandlePanic(*error) {
}

// make sure ErrorQueryService implements QueryService
var _ queryservice.QueryService = &ErrorQueryService{}


text:
<?php

namespace Doctrine\DBAL\Cache;

use ArrayIterator;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\FetchMode;
use InvalidArgumentException;
use IteratorAggregate;
use PDO;

use function array_merge;
use function array_values;
use function count;
use function reset;

class ArrayStatement implements IteratorAggregate, ResultStatement
{
    /** @var mixed[] */
    private $data;

    /** @var int */
    private $columnCount = 0;

    /** @var int */
    private $num = 0;

    /** @var int */
    private $defaultFetchMode = FetchMode::MIXED;

    /**
     * @param mixed[] $data
     */
    public function __construct(array $data)
    {
        $this->data = $data;
        if (! count($data)) {
            return;
        }

        $this->columnCount = count($data[0]);
    }

    /**
     * {@inheritdoc}
     */
    public function closeCursor()
    {
        unset($this->data);

        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function columnCount()
    {
        return $this->columnCount;
    }

    /**
     * {@inheritdoc}
     */
    public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
    {
        if ($arg2 !== null || $arg3 !== null) {
            throw new InvalidArgumentException('Caching layer does not support 2nd/3rd argument to setFetchMode()');
        }

        $this->defaultFetchMode = $fetchMode;

        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function getIterator()
    {
        $data = $this->fetchAll();

        return new ArrayIterator($data);
    }

    /**
     * {@inheritdoc}
     */
    public function fetch($fetchMode = null, $cursorOrientation = PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
    {
        if (! isset($this->data[$this->num])) {
            return false;
        }

        $row       = $this->data[$this->num++];
        $fetchMode = $fetchMode ?: $this->defaultFetchMode;

        if ($fetchMode === FetchMode::ASSOCIATIVE) {
            return $row;
        }

        if ($fetchMode === FetchMode::NUMERIC) {
            return array_values($row);
        }

        if ($fetchMode === FetchMode::MIXED) {
            return array_merge($row, array_values($row));
        }

        if ($fetchMode === FetchMode::COLUMN) {
            return reset($row);
        }

        throw new InvalidArgumentException('Invalid fetch-style given for fetching result.');
    }

    /**
     * {@inheritdoc}
     */
    public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
    {
        $rows = [];
        while ($row = $this->fetch($fetchMode)) {
            $rows[] = $row;
        }

        return $rows;
    }

    /**
     * {@inheritdoc}
     */
    public function fetchColumn($columnIndex = 0)
    {
        $row = $this->fetch(FetchMode::NUMERIC);

        // TODO: verify that return false is the correct behavior
        return $row[$columnIndex] ?? false;
    }
}


text:
<?php

namespace DTS\eBaySDK\Finding\Types;

/**
 *
 * @property \DTS\eBaySDK\Finding\Enums\MapExposureEnum $minimumAdvertisedPriceExposure
 * @property \DTS\eBaySDK\Finding\Types\Amount $originalRetailPrice
 * @property \DTS\eBaySDK\Finding\Enums\PriceTreatmentEnum $pricingTreatment
 * @property boolean $soldOffEbay
 * @property boolean $soldOnEbay
 */
class DiscountPriceInfo extends \DTS\eBaySDK\Types\BaseType
{
    /**
     * @var array Properties belonging to objects of this class.
     */
    private static $propertyTypes = array(
        'minimumAdvertisedPriceExposure' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'minimumAdvertisedPriceExposure'
        ),
        'originalRetailPrice' => array(
            'type' => 'DTS\eBaySDK\Finding\Types\Amount',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'originalRetailPrice'
        ),
        'pricingTreatment' => array(
            'type' => 'string',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'pricingTreatment'
        ),
        'soldOffEbay' => array(
            'type' => 'boolean',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'soldOffEbay'
        ),
        'soldOnEbay' => array(
            'type' => 'boolean',
            'unbound' => false,
            'attribute' => false,
            'elementName' => 'soldOnEbay'
        )
    );

    /**
     * @param array $values Optional properties and values to assign to the object.
     */
    public function __construct(array $values = array())
    {
        list($parentValues, $childValues) = self::getParentValues(self::$propertyTypes, $values);

        parent::__construct($parentValues);

        if (!array_key_exists(__CLASS__, self::$properties)) {
            self::$properties[__CLASS__] = array_merge(self::$properties[get_parent_class()], self::$propertyTypes);
        }

        if (!array_key_exists(__CLASS__, self::$xmlNamespaces)) {
            self::$xmlNamespaces[__CLASS__] = 'http://www.ebay.com/marketplace/search/v1/services';
        }

        $this->setValues(__CLASS__, $childValues);
    }
}


text:
require 'abstract_unit'
require 'logger'
require 'pp' # require 'pp' early to prevent hidden_methods from not picking up the pretty-print methods until too late

# Provide some controller to run the tests on.
module Submodule
  class ContainedEmptyController < ActionController::Base
  end

  class ContainedNonEmptyController < ActionController::Base
    def public_action
      render :nothing => true
    end

    hide_action :hidden_action
    def hidden_action
      raise "Noooo!"
    end

    def another_hidden_action
    end
    hide_action :another_hidden_action
  end

  class SubclassedController < ContainedNonEmptyController
    hide_action :public_action # Hiding it here should not affect the superclass.
  end
end

class EmptyController < ActionController::Base
end

class NonEmptyController < ActionController::Base
  def public_action
    render :nothing => true
  end

  hide_action :hidden_action
  def hidden_action
  end
end

class MethodMissingController < ActionController::Base
  hide_action :shouldnt_be_called
  def shouldnt_be_called
    raise "NO WAY!"
  end

protected

  def method_missing(selector)
    render :text => selector.to_s
  end
end

class AnotherMethodMissingController < ActionController::Base
  cattr_accessor :_exception
  rescue_from Exception, :with => :_exception=

  protected
  def method_missing(*attrs, &block)
    super
  end
end

class DefaultUrlOptionsController < ActionController::Base
  def from_view
    render :inline => "<%= #{params[:route]} %>"
  end

  def default_url_options(options = nil)
    { :host => 'www.override.com', :action => 'new', :locale => 'en' }
  end
end

class UrlOptionsController < ActionController::Base
  def from_view
    render :inline => "<%= #{params[:route]} %>"
  end

  def url_options
    super.merge(:host => 'www.override.com', :action => 'new', :locale => 'en')
  end
end

class RecordIdentifierController < ActionController::Base
end

class ControllerClassTests < ActiveSupport::TestCase

  def test_controller_path
    assert_equal 'empty', EmptyController.controller_path
    assert_equal EmptyController.controller_path, EmptyController.new.controller_path
    assert_equal 'submodule/contained_empty', Submodule::ContainedEmptyController.controller_path
    assert_equal Submodule::ContainedEmptyController.controller_path, Submodule::ContainedEmptyController.new.controller_path
  end

  def test_controller_name
    assert_equal 'empty', EmptyController.controller_name
    assert_equal 'contained_empty', Submodule::ContainedEmptyController.controller_name
  end

  def test_record_identifier
    assert_respond_to RecordIdentifierController.new, :dom_id
    assert_respond_to RecordIdentifierController.new, :dom_class
  end
end

class ControllerInstanceTests < Test::Unit::TestCase
  def setup
    @empty = EmptyController.new
    @contained = Submodule::ContainedEmptyController.new
    @empty_controllers = [@empty, @contained, Submodule::SubclassedController.new]

    @non_empty_controllers = [NonEmptyController.new,
                              Submodule::ContainedNonEmptyController.new]
  end

  def test_action_methods
    @empty_controllers.each do |c|
      assert_equal Set.new, c.class.action_methods, "#{c.controller_path} should be empty!"
    end

    @non_empty_controllers.each do |c|
      assert_equal Set.new(%w(public_action)), c.class.action_methods, "#{c.controller_path} should not be empty!"
    end
  end

  def test_temporary_anonymous_controllers
    name = 'ExamplesController'
    klass = Class.new(ActionController::Base)
    Object.const_set(name, klass)

    controller = klass.new
    assert_equal "examples", controller.controller_path
  end
end

class PerformActionTest < ActionController::TestCase
  def use_controller(controller_class)
    @controller = controller_class.new

    # enable a logger so that (e.g.) the benchmarking stuff runs, so we can get
    # a more accurate simulation of what happens in "real life".
    @controller.logger = Logger.new(nil)

    @request     = ActionController::TestRequest.new
    @response    = ActionController::TestResponse.new
    @request.host = "www.nextangle.com"

    rescue_action_in_public!
  end

  def test_process_should_be_precise
    use_controller EmptyController
    exception = assert_raise AbstractController::ActionNotFound do
      get :non_existent
    end
    assert_equal exception.message, "The action 'non_existent' could not be found for EmptyController"
  end

  def test_get_on_priv_should_show_selector
    use_controller MethodMissingController
    get :shouldnt_be_called
    assert_response :success
    assert_equal 'shouldnt_be_called', @response.body
  end

  def test_method_missing_is_not_an_action_name
    use_controller MethodMissingController
    assert !@controller.__send__(:action_method?, 'method_missing')

    get :method_missing
    assert_response :success
    assert_equal 'method_missing', @response.body
  end

  def test_method_missing_should_recieve_symbol
    use_controller AnotherMethodMissingController
    get :some_action
    assert_kind_of NameError, @controller._exception
  end

  def test_get_on_hidden_should_fail
    use_controller NonEmptyController
    assert_raise(ActionController::UnknownAction) { get :hidden_action }
    assert_raise(ActionController::UnknownAction) { get :another_hidden_action }
  end
end

class UrlOptionsTest < ActionController::TestCase
  tests UrlOptionsController

  def setup
    super
    @request.host = 'www.example.com'
    rescue_action_in_public!
  end

  def test_url_options_override
    with_routing do |set|
      set.draw do
        match 'from_view', :to => 'url_options#from_view', :as => :from_view
        match ':controller/:action'
      end

      get :from_view, :route => "from_view_url"

      assert_equal 'http://www.override.com/from_view?locale=en', @response.body
      assert_equal 'http://www.override.com/from_view?locale=en', @controller.send(:from_view_url)
      assert_equal 'http://www.override.com/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options')
    end
  end

  def test_url_helpers_does_not_become_actions
    with_routing do |set|
      set.draw do
        match "account/overview"
      end

      @controller.class.send(:include, set.url_helpers)
      assert !@controller.class.action_methods.include?("account_overview_path")
    end
  end
end

class DefaultUrlOptionsTest < ActionController::TestCase
  tests DefaultUrlOptionsController

  def setup
    super
    @request.host = 'www.example.com'
    rescue_action_in_public!
  end

  def test_default_url_options_override
    with_routing do |set|
      set.draw do
        match 'from_view', :to => 'default_url_options#from_view', :as => :from_view
        match ':controller/:action'
      end

      get :from_view, :route => "from_view_url"

      assert_equal 'http://www.override.com/from_view?locale=en', @response.body
      assert_equal 'http://www.override.com/from_view?locale=en', @controller.send(:from_view_url)
      assert_equal 'http://www.override.com/default_url_options/new?locale=en', @controller.url_for(:controller => 'default_url_options')
    end
  end

  def test_default_url_options_are_used_in_non_positional_parameters
    with_routing do |set|
      set.draw do
        scope("/:locale") do
          resources :descriptions
        end
        match ':controller/:action'
      end

      get :from_view, :route => "description_path(1)"

      assert_equal '/en/descriptions/1', @response.body
      assert_equal '/en/descriptions', @controller.send(:descriptions_path)
      assert_equal '/pl/descriptions', @controller.send(:descriptions_path, "pl")
      assert_equal '/pl/descriptions', @controller.send(:descriptions_path, :locale => "pl")
      assert_equal '/pl/descriptions.xml', @controller.send(:descriptions_path, "pl", "xml")
      assert_equal '/en/descriptions.xml', @controller.send(:descriptions_path, :format => "xml")
      assert_equal '/en/descriptions/1', @controller.send(:description_path, 1)
      assert_equal '/pl/descriptions/1', @controller.send(:description_path, "pl", 1)
      assert_equal '/pl/descriptions/1', @controller.send(:description_path, 1, :locale => "pl")
      assert_equal '/pl/descriptions/1.xml', @controller.send(:description_path, "pl", 1, "xml")
      assert_equal '/en/descriptions/1.xml', @controller.send(:description_path, 1, :format => "xml")
    end
  end

end

class EmptyUrlOptionsTest < ActionController::TestCase
  tests NonEmptyController

  def setup
    super
    @request.host = 'www.example.com'
    rescue_action_in_public!
  end

  def test_ensure_url_for_works_as_expected_when_called_with_no_options_if_default_url_options_is_not_set
    get :public_action
    assert_equal "http://www.example.com/non_empty/public_action", @controller.url_for
  end

  def test_named_routes_with_path_without_doing_a_request_first
    @controller = EmptyController.new
    @controller.request = @request

    with_routing do |set|
      set.draw do
        resources :things
      end

      assert_equal '/things', @controller.send(:things_path)
    end
  end
end


text:
/**
 * \file
 *
 * Play a stereo audio stream using Apple's HAL layer.
 *
 * Apple tends to recommend to use the AUHAL audio unit however since
 * the stream we are using is fairly standard, most hardware would
 * support it and we stay as close as we can to the hardware layer
 * this way.
 */

#include <CoreAudio/AudioHardware.h>
#include <CoreAudio/CoreAudioTypes.h>

#include <micros/api.h>

#include "../clock.h"

//! what are the selected channels for our stereo stream
struct StereoChannelDesc {
        int channels[2];
        struct Clock* clock;
};

OSStatus audio_callback(AudioDeviceID           inDevice,
                        const AudioTimeStamp*   inNow,
                        const AudioBufferList*  inInputData,
                        const AudioTimeStamp*   inInputTime,
                        AudioBufferList*        outOutputData,
                        const AudioTimeStamp*   inOutputTime,
                        void*                   inClientData)
{
        struct StereoChannelDesc const * const selected_channels =
                        static_cast<struct StereoChannelDesc*>(inClientData);

        struct {
                float* buffer;
                int stride;
                int frame_count;
        } output[2] = {
                { NULL, 1, 0 },
                { NULL, 1, 0 },
        };

        // find buffers to bind our channels to
        int current_channel = 1;
        for (UInt32 i = 0; i < outOutputData->mNumberBuffers; i++) {
                AudioBuffer* const buffer = &outOutputData->mBuffers[i];
                float* const samples = static_cast<float*> (buffer->mData);
                int const frame_count =
                        buffer->mDataByteSize / buffer->mNumberChannels / sizeof samples[0];
                int const stride = buffer->mNumberChannels;

                for (UInt32 j = 0; j < buffer->mNumberChannels; j++) {
                        if (samples) {
                                for (int oi = 0; oi < 2; oi++) {
                                        if (current_channel == selected_channels->channels[oi]) {
                                                output[oi].buffer = &samples[j];
                                                output[oi].stride = stride;
                                                output[oi].frame_count = frame_count;
                                        }
                                }
                        }
                        current_channel++;
                }
        }

        if (output[0].frame_count != output[1].frame_count) {
                printf("err: %d is not %d\n", output[0].frame_count, output[1].frame_count);
                return noErr;
        }

        if (!output[0].buffer || !output[1].buffer) {
                printf("err: no left/right buffer\n");
                return noErr;
        }

        // ask our client to generate content into temporary buffers
        int const frame_count = output[0].frame_count;
        double left_client_buffer[frame_count];
        double right_client_buffer[frame_count];

        memset(left_client_buffer, 0, sizeof left_client_buffer);
        memset(right_client_buffer, 0, sizeof right_client_buffer);

        render_next_2chn_48khz_audio
        (clock_ticks_to_microseconds(selected_channels->clock,
                                     inOutputTime->mHostTime),
         frame_count,
         left_client_buffer,
         right_client_buffer);

        for (int i = 0; i < frame_count; i++) {
                output[0].buffer[i * output[0].stride] = (float) left_client_buffer[i];
        }

        for (int i = 0; i < frame_count; i++) {
                output[1].buffer[i * output[1].stride] = (float) right_client_buffer[i];
        }

        return noErr;
}

#define HW_PROPERTY_ADDRESS(key) \
        { key, kAudioObjectPropertyScopeGlobal, kAudioObjectPropertyElementMaster, }

#define HW_OUTPUT_PROPERTY_ADDRESS(key) \
        { key, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster, }

#define OS_SUCCESS(call) ((call) == noErr)
#define THEN_DO(expr) ((expr), 1)

#define FAIL_WITH(...) (THEN_DO(printf(__VA_ARGS__)) && 0)
#define BREAK_ON_ERROR(expr) \
        if (!(expr)) {                                                  \
                return;							\
        }

static AudioDeviceID mainDeviceID;
static AudioDeviceIOProcID mainIOProcID;

extern void close_stream()
{
        if (mainDeviceID && mainIOProcID) {
                (void) (OS_SUCCESS(AudioDeviceStop(mainDeviceID, audio_callback))
                        && OS_SUCCESS(AudioDeviceDestroyIOProcID(mainDeviceID, mainIOProcID))
                        || FAIL_WITH("could not close device"));
                mainDeviceID = 0;
                mainIOProcID = 0;
                printf("closed stream\n");
        }
}

extern void open_stereo48khz_stream(struct Clock* clock)
{
        double const preferred_hz = 48000.0;

        AudioDeviceID outputDevice;
        {
                UInt32 size = sizeof outputDevice;
                AudioObjectPropertyAddress const address =
                        HW_PROPERTY_ADDRESS(kAudioHardwarePropertyDefaultOutputDevice);

                BREAK_ON_ERROR
                ((OS_SUCCESS(AudioObjectGetPropertyData
                             (kAudioObjectSystemObject, &address, 0, NULL, &size, &outputDevice))
                  && outputDevice != 0)
                 || FAIL_WITH("could not query default output device\n"));
        }

        UInt32 left_right_channels[2];
        {
                UInt32 property_size;
                AudioObjectPropertyAddress property;

                property_size = sizeof left_right_channels;
                property = HW_OUTPUT_PROPERTY_ADDRESS
                           (kAudioDevicePropertyPreferredChannelsForStereo);

                BREAK_ON_ERROR
                (OS_SUCCESS(AudioObjectGetPropertyData
                            (outputDevice,
                             &property,
                             0, NULL,
                             &property_size,
                             &left_right_channels))
                 || FAIL_WITH("could not query stereo channels"));
        }

        struct StereoChannelDesc* channel_desc = new StereoChannelDesc();
        channel_desc->clock = clock;
        {
                AudioObjectPropertyAddress streams_address =
                        HW_OUTPUT_PROPERTY_ADDRESS(kAudioDevicePropertyStreams);
                UInt32 streams_size;

                BREAK_ON_ERROR
                (OS_SUCCESS(AudioObjectGetPropertyDataSize
                            (outputDevice,
                             &streams_address,
                             0,
                             NULL,
                             &streams_size))
                 || FAIL_WITH("could not query streams size"))

                char streams_buffer[streams_size];
                AudioStreamID* streams = (AudioStreamID*) streams_buffer;
                int const streams_n = streams_size / sizeof streams[0];

                BREAK_ON_ERROR
                (OS_SUCCESS(AudioObjectGetPropertyData
                            (outputDevice,
                             &streams_address,
                             0,
                             NULL,
                             &streams_size,
                             streams))
                 || FAIL_WITH("could not query streams"))

                for (int streams_i = 0; streams_i < streams_n; streams_i++) {
                        AudioStreamID candidate_stream = streams[streams_i];

                        UInt32 starting_channel;
                        {
                                UInt32 size = sizeof starting_channel;
                                AudioObjectPropertyAddress const address =
                                        HW_PROPERTY_ADDRESS(kAudioStreamPropertyStartingChannel);

                                if (!(OS_SUCCESS(AudioObjectGetPropertyData
                                                 (candidate_stream,
                                                  &address,
                                                  0,
                                                  NULL,
                                                  &size,
                                                  &starting_channel))
                                      || FAIL_WITH("could not query starting channel")) ||
                                    (starting_channel != left_right_channels[0] &&
                                     starting_channel != left_right_channels[1])) {
                                        continue;
                                }
                        }

                        UInt32 property_size;
                        AudioObjectPropertyAddress const property_address =
                                HW_PROPERTY_ADDRESS(kAudioStreamPropertyAvailableVirtualFormats);

                        BREAK_ON_ERROR
                        (OS_SUCCESS(AudioObjectGetPropertyDataSize
                                    (candidate_stream,
                                     &property_address,
                                     0,
                                     NULL,
                                     &property_size))
                         || FAIL_WITH("could not get formats size"));

                        char buffer[property_size];
                        AudioStreamRangedDescription* descriptions =
                                (AudioStreamRangedDescription*) buffer;
                        int const descriptions_n = property_size / sizeof descriptions[0];

                        BREAK_ON_ERROR
                        (OS_SUCCESS(AudioObjectGetPropertyData
                                    (candidate_stream,
                                     &property_address,
                                     0,
                                     NULL,
                                     &property_size,
                                     descriptions))
                         || FAIL_WITH("could not get formats"))

                        int i;
                        for (i = 0; i < descriptions_n; i++) {
                                AudioStreamRangedDescription desc = descriptions[i];
                                if (desc.mFormat.mFormatID != kAudioFormatLinearPCM) {
                                        continue;
                                }

                                bool is_variadic = kAudioStreamAnyRate == desc.mFormat.mSampleRate &&
                                                   preferred_hz >= desc.mSampleRateRange.mMinimum &&
                                                   preferred_hz <= desc.mSampleRateRange.mMaximum;
                                if (!is_variadic &&
                                    fabs(preferred_hz - desc.mFormat.mSampleRate) >= 0.01) {
                                        continue;
                                }

                                if (desc.mFormat.mFormatFlags !=
                                    (kAudioFormatFlagIsFloat | kAudioFormatFlagIsPacked)) {
                                        continue;
                                }

                                desc.mFormat.mSampleRate = preferred_hz;
                                UInt32 property_size = sizeof desc.mFormat;
                                AudioObjectPropertyAddress const property_address =
                                        HW_PROPERTY_ADDRESS(kAudioStreamPropertyVirtualFormat);

                                BREAK_ON_ERROR
                                (OS_SUCCESS(AudioObjectSetPropertyData
                                            (candidate_stream,
                                             &property_address,
                                             0,
                                             NULL,
                                             property_size,
                                             &desc.mFormat))
                                 || FAIL_WITH("could not set stream format"))

                                /* mark the channel as configured */
                                if (desc.mFormat.mChannelsPerFrame < 2) {
                                        if (left_right_channels[0] == starting_channel) {
                                                channel_desc->channels[0] = starting_channel;
                                                left_right_channels[0] = 0;
                                        } else if (left_right_channels[1] == starting_channel) {
                                                channel_desc->channels[1] = starting_channel;
                                                left_right_channels[1] = 0;
                                        }
                                } else {
                                        channel_desc->channels[0] = left_right_channels[0];
                                        channel_desc->channels[1] = left_right_channels[1];

                                        left_right_channels[0] = 0;
                                        left_right_channels[1] = 0;
                                }
                                break;
                        }
                }

                if (left_right_channels[0] != 0 ||
                    left_right_channels[1] != 0) {
                        printf("%s: error at %s:%d\n", __func__, __FILE__, __LINE__);
                        return;
                }

                {

                        AudioDeviceIOProcID procID;
                        BREAK_ON_ERROR
                        (OS_SUCCESS(AudioDeviceCreateIOProcID
                                    (outputDevice,
                                     audio_callback,
                                     channel_desc,
                                     &procID))
                         || FAIL_WITH("could not create AudioIOProc"));

                        mainDeviceID = outputDevice;
                        mainIOProcID = procID;

                        BREAK_ON_ERROR
                        (OS_SUCCESS(AudioDeviceStart(outputDevice, procID))
                         || FAIL_WITH("could not start output device"));
                }
                atexit(close_stream);
        }
}


text:
package org.elasticsearch.search.aggregations.metrics;

public class MinTests extends AbstractNumericMetricTestCase<MinAggregationBuilder> {

    @Override
    protected MinAggregationBuilder doCreateTestAggregatorFactory() {
        return new MinAggregationBuilder(randomAlphaOfLengthBetween(3, 10));
    }

}


text:
package au.gov.qld.pub.orders.service;

import java.util.Date;

import org.joda.time.LocalDateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
public class ScheduleService {
    private static final Logger LOG = LoggerFactory.getLogger(ScheduleService.class);
    private final OrderService orderService;
    private final int maxAge;
    private final int cleanupPaidOrderDays;
    private final int cleanupUnpaidOrderDays;

    @Autowired
    public ScheduleService(ConfigurationService config, OrderService orderService) {
        this.maxAge = config.getMaxAgeForRetry();
        this.cleanupPaidOrderDays = config.getDeletePaidOrderDays();
        this.cleanupUnpaidOrderDays = config.getDeleteUnpaidOrderDays();
        this.orderService = orderService;
    }

    @Scheduled(fixedDelayString = "${scheduler.statusCheck.delay}")
    public void statusCheck() {
        LOG.info("Scheduled task: {} starting", "statusCheck");
        Date minCreated = new LocalDateTime().minusMillis(maxAge).toDate();

        for (String orderId : orderService.findUnpaidOrderIds(minCreated)) {
            try {
                orderService.notifyPayment(orderId);
            } catch (ServiceException e) {
                LOG.info(e.getMessage(), e);
            }
        }

        LOG.info("Scheduled task: {} finished", "statusCheck");
    }

    @Scheduled(fixedDelay = 3600000l)
    public void cleanup() {
        LOG.info("Scheduled task: {} starting", "cleanup");
        if (cleanupPaidOrderDays >= 0) {
            orderService.deleteOlderThan(new LocalDateTime().minusDays(cleanupPaidOrderDays), true);
        }
        if (cleanupUnpaidOrderDays >= 0) {
            orderService.deleteOlderThan(new LocalDateTime().minusDays(cleanupUnpaidOrderDays), false);
        }
        LOG.info("Scheduled task: {} finished", "cleanup");
    }

}


text:
namespace app { namespace Uno { namespace Time { namespace Text { struct FixedFormatPattern__Uno_Time_Text_OffsetPattern_OffsetBucket; } } } }
namespace app { namespace Uno { namespace Time { namespace Text { struct OffsetPattern_OffsetBucket; } } } }
namespace app { namespace Uno { namespace Time { namespace Text { struct ParseResult__Uno_Time_Offset; } } } }
namespace app { namespace Uno { namespace Time { struct Offset; } } }

namespace app {
namespace Uno {
namespace Time {
namespace Text {

struct OffsetPattern;

extern ::uStaticStrong< OffsetPattern*> OffsetPattern__General;

struct OffsetPattern__uType : ::uClassType
{
};

OffsetPattern__uType* OffsetPattern__typeof();

void OffsetPattern___ObjInit(OffsetPattern* __this);
::uString* OffsetPattern__Format(OffsetPattern* __this, ::app::Uno::Time::Offset value);
OffsetPattern* OffsetPattern__get_GeneralIsoPattern(::uStatic* __this);
int OffsetPattern__GetHour(OffsetPattern* __this, ::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value);
int OffsetPattern__GetMinute(OffsetPattern* __this, ::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value);
int OffsetPattern__GetSecond(OffsetPattern* __this, ::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value);
int OffsetPattern__GetSign(OffsetPattern* __this, ::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value);
OffsetPattern* OffsetPattern__New_1(::uStatic* __this);
::app::Uno::Time::Text::ParseResult__Uno_Time_Offset* OffsetPattern__Parse(OffsetPattern* __this, ::uString* text);
void OffsetPattern__SetHour(OffsetPattern* __this, ::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value, int hour);
void OffsetPattern__SetMinute(OffsetPattern* __this, ::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value, int minute);
void OffsetPattern__SetSecond(OffsetPattern* __this, ::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value, int second);
void OffsetPattern__SetSign(OffsetPattern* __this, ::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value, int sign);

struct OffsetPattern : ::uObject
{
    ::uStrong< ::app::Uno::Time::Text::FixedFormatPattern__Uno_Time_Text_OffsetPattern_OffsetBucket*> _generalPattern;

    void _ObjInit() { OffsetPattern___ObjInit(this); }
    ::uString* Format(::app::Uno::Time::Offset value);
    int GetHour(::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value) { return OffsetPattern__GetHour(this, value); }
    int GetMinute(::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value) { return OffsetPattern__GetMinute(this, value); }
    int GetSecond(::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value) { return OffsetPattern__GetSecond(this, value); }
    int GetSign(::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value) { return OffsetPattern__GetSign(this, value); }
    ::app::Uno::Time::Text::ParseResult__Uno_Time_Offset* Parse(::uString* text) { return OffsetPattern__Parse(this, text); }
    void SetHour(::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value, int hour) { OffsetPattern__SetHour(this, value, hour); }
    void SetMinute(::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value, int minute) { OffsetPattern__SetMinute(this, value, minute); }
    void SetSecond(::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value, int second) { OffsetPattern__SetSecond(this, value, second); }
    void SetSign(::app::Uno::Time::Text::OffsetPattern_OffsetBucket* value, int sign) { OffsetPattern__SetSign(this, value, sign); }
};

}}}}

#include <app/Uno.Time.Offset.h>

namespace app {
namespace Uno {
namespace Time {
namespace Text {

inline ::uString* OffsetPattern::Format(::app::Uno::Time::Offset value) { return OffsetPattern__Format(this, value); }

}}}}

#endif


text:
@implementation SRGSParserTest

- (void)setUp {
    p = [[[SRGSParser alloc] init] autorelease];
}

- (void)test {
    NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"example1" ofType:@"srgs"];
    s = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];

    a = [p assemblyWithString:s];
    result = [p bestMatchFor:a];
    TDNotNil(result);
    NSLog(@"\n\n\n result: %@ \n\n\n", result);
//    TDEqualObjects(@"[#, ABNF, 1.0, ;]#/ABNF/1.0/;^", [result description]);
}

- (void)testSelfIdentHeader {
    s = @"#ABNF 1.0;";
    a = [p assemblyWithString:s];
    result = [p.selfIdentHeader bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[#, ABNF, 1.0, ;]#/ABNF/1.0/;^", [result description]);

    s = @"#ABNF 1.0 UTF;";
    a = [p assemblyWithString:s];
    result = [p.selfIdentHeader bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[#, ABNF, 1.0, UTF, ;]#/ABNF/1.0/UTF/;^", [result description]);
}

- (void)testRuleName {
    s = @"$foobar";
    a = [p assemblyWithString:s];
    result = [p.ruleName bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[$, foobar]$/foobar^", [result description]);
}

- (void)testWeight {
    s = @"/4.0/";
    a = [PKTokenAssembly assemblyWithString:s];
    result = [p.weight bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[/, 4.0, /]//4.0//^", [result description]);
}

- (void)testProbability {
    s = @"/4.0/";
    a = [PKTokenAssembly assemblyWithString:s];
    result = [p.probability bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[/, 4.0, /]//4.0//^", [result description]);
}

- (void)testRepeat {
    s = @"1 - 4";
    a = [p assemblyWithString:s];
    result = [p.repeat bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[1, -, 4]1/-/4^", [result description]);

    s = @"1-4";
    a = [p assemblyWithString:s];
    result = [p.repeat bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[1, -, 4]1/-/4^", [result description]);
}

- (void)testToken {
    s = @"foobar";
    a = [p assemblyWithString:s];
    result = [p.token bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[foobar]foobar^", [result description]);

    s = @"'foobar'";
    a = [p assemblyWithString:s];
    result = [p.token bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"['foobar']'foobar'^", [result description]);
}

- (void)testTag {
    s = @"{foobar}";
    a = [p assemblyWithString:s];
    result = [p.tag bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[{, foobar, }]{/foobar/}^", [result description]);

    s = @"{bar baz}";
    a = [p assemblyWithString:s];
    result = [p.tag bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[{, bar, baz, }]{/bar/baz/}^", [result description]);

    s = @"{bar 1.2 baz}";
    a = [p assemblyWithString:s];
    result = [p.tag bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[{, bar, 1.2, baz, }]{/bar/1.2/baz/}^", [result description]);

    s = @"{!{'foobar'}!}";
    a = [p assemblyWithString:s];
    result = [p.tag bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[{, !, {, 'foobar', }, !, }]{/!/{/'foobar'/}/!/}^", [result description]);

    s = @"{!{'foobar' baz}!}";
    a = [p assemblyWithString:s];
    result = [p.tag bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[{, !, {, 'foobar', baz, }, !, }]{/!/{/'foobar'/baz/}/!/}^", [result description]);
}

- (void)testBaseDecl {
    s = @"base url-goes-here;";
    a = [p assemblyWithString:s];
    result = [p.baseDecl bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[base, url-goes-here, ;]base/url-goes-here/;^", [result description]);
}

- (void)testLanguageDecl {
    s = @"language en-us;";
    a = [p assemblyWithString:s];
    result = [p.languageDecl bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[language, en-us, ;]language/en-us/;^", [result description]);
}

- (void)testModeDecl {
    s = @"mode voice;";
    a = [p assemblyWithString:s];
    result = [p.modeDecl bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[mode, voice, ;]mode/voice/;^", [result description]);

    s = @"mode dtmf;";
    a = [p assemblyWithString:s];
    result = [p.modeDecl bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[mode, dtmf, ;]mode/dtmf/;^", [result description]);
}

- (void)testRootRuleDecl {
    s = @"root $foobar;";
    a = [p assemblyWithString:s];
    result = [p.rootRuleDecl bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[root, $, foobar, ;]root/$/foobar/;^", [result description]);
}

- (void)testLanguageAttachment {
    s = @"!en-us";
    a = [p assemblyWithString:s];
    result = [p.languageAttachment bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[!, en-us]!/en-us^", [result description]);
}

- (void)testRepeatOperator {
    s = @"<0-2 /0.6/>";
    a = [p assemblyWithString:s];
    result = [p.repeatOperator bestMatchFor:a];
    TDNotNil(result);
    TDEqualObjects(@"[<, 0, -, 2, /, 0.6, /, >]</0/-/2///0.6///>^", [result description]);
}

@end


text:
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: google/cloud/bigquery/reservation/v1/reservation.proto

package com.google.cloud.bigquery.reservation.v1;

/**
 *
 *
 *

 * An assignment allows a project to submit jobs
 * of a certain type using slots from the specified reservation.
 *

 *
 * Protobuf type {@code google.cloud.bigquery.reservation.v1.Assignment}
 */
public final class Assignment extends com.google.protobuf.GeneratedMessageV3
    implements
    // @@protoc_insertion_point(message_implements:google.cloud.bigquery.reservation.v1.Assignment)
    AssignmentOrBuilder {
  private static final long serialVersionUID = 0L;
  // Use Assignment.newBuilder() to construct.
  private Assignment(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
    super(builder);
  }

  private Assignment() {
    name_ = "";
    assignee_ = "";
    jobType_ = 0;
    state_ = 0;
  }

  @java.lang.Override
  @SuppressWarnings({"unused"})
  protected java.lang.Object newInstance(UnusedPrivateParameter unused) {
    return new Assignment();
  }

  @java.lang.Override
  public final com.google.protobuf.UnknownFieldSet getUnknownFields() {
    return this.unknownFields;
  }

  public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
    return com.google.cloud.bigquery.reservation.v1.ReservationProto
        .internal_static_google_cloud_bigquery_reservation_v1_Assignment_descriptor;
  }

  @java.lang.Override
  protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internalGetFieldAccessorTable() {
    return com.google.cloud.bigquery.reservation.v1.ReservationProto
        .internal_static_google_cloud_bigquery_reservation_v1_Assignment_fieldAccessorTable
        .ensureFieldAccessorsInitialized(
            com.google.cloud.bigquery.reservation.v1.Assignment.class,
            com.google.cloud.bigquery.reservation.v1.Assignment.Builder.class);
  }

  /**
   *
   *
   *

   * Types of job, which could be specified when using the reservation.
   *

   *
   * Protobuf enum {@code google.cloud.bigquery.reservation.v1.Assignment.JobType}
   */
  public enum JobType implements com.google.protobuf.ProtocolMessageEnum {
    /**
     *
     *
     *

     * Invalid type. Requests with this value will be rejected with
     * error code `google.rpc.Code.INVALID_ARGUMENT`.
     *

     *
     * JOB_TYPE_UNSPECIFIED = 0;
     */
    JOB_TYPE_UNSPECIFIED(0),
    /**
     *
     *
     *

     * Pipeline (load/export) jobs from the project will use the reservation.
     *

     *
     * PIPELINE = 1;
     */
    PIPELINE(1),
    /**
     *
     *
     *

     * Query jobs from the project will use the reservation.
     *

     *
     * QUERY = 2;
     */
    QUERY(2),
    /**
     *
     *
     *

     * BigQuery ML jobs that use services external to BigQuery for model
     * training. These jobs will not utilize idle slots from other reservations.
     *

     *
     * ML_EXTERNAL = 3;
     */
    ML_EXTERNAL(3),
    UNRECOGNIZED(-1),
    ;

    /**
     *
     *
     *

     * Invalid type. Requests with this value will be rejected with
     * error code `google.rpc.Code.INVALID_ARGUMENT`.
     *

     *
     * JOB_TYPE_UNSPECIFIED = 0;
     */
    public static final int JOB_TYPE_UNSPECIFIED_VALUE = 0;
    /**
     *
     *
     *

     * Pipeline (load/export) jobs from the project will use the reservation.
     *

     *
     * PIPELINE = 1;
     */
    public static final int PIPELINE_VALUE = 1;
    /**
     *
     *
     *

     * Query jobs from the project will use the reservation.
     *

     *
     * QUERY = 2;
     */
    public static final int QUERY_VALUE = 2;
    /**
     *
     *
     *

     * BigQuery ML jobs that use services external to BigQuery for model
     * training. These jobs will not utilize idle slots from other reservations.
     *

     *
     * ML_EXTERNAL = 3;
     */
    public static final int ML_EXTERNAL_VALUE = 3;

    public final int getNumber() {
      if (this == UNRECOGNIZED) {
        throw new java.lang.IllegalArgumentException(
            "Can't get the number of an unknown enum value.");
      }
      return value;
    }

    /**
     * @param value The numeric wire value of the corresponding enum entry.
     * @return The enum associated with the given numeric wire value.
     * @deprecated Use {@link #forNumber(int)} instead.
     */
    @java.lang.Deprecated
    public static JobType valueOf(int value) {
      return forNumber(value);
    }

    /**
     * @param value The numeric wire value of the corresponding enum entry.
     * @return The enum associated with the given numeric wire value.
     */
    public static JobType forNumber(int value) {
      switch (value) {
        case 0:
          return JOB_TYPE_UNSPECIFIED;
        case 1:
          return PIPELINE;
        case 2:
          return QUERY;
        case 3:
          return ML_EXTERNAL;
        default:
          return null;
      }
    }

    public static com.google.protobuf.Internal.EnumLiteMap<JobType> internalGetValueMap() {
      return internalValueMap;
    }

    private static final com.google.protobuf.Internal.EnumLiteMap<JobType> internalValueMap =
        new com.google.protobuf.Internal.EnumLiteMap<JobType>() {
          public JobType findValueByNumber(int number) {
            return JobType.forNumber(number);
          }
        };

    public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() {
      if (this == UNRECOGNIZED) {
        throw new java.lang.IllegalStateException(
            "Can't get the descriptor of an unrecognized enum value.");
      }
      return getDescriptor().getValues().get(ordinal());
    }

    public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() {
      return getDescriptor();
    }

    public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() {
      return com.google.cloud.bigquery.reservation.v1.Assignment.getDescriptor()
          .getEnumTypes()
          .get(0);
    }

    private static final JobType[] VALUES = values();

    public static JobType valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
      if (desc.getType() != getDescriptor()) {
        throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type.");
      }
      if (desc.getIndex() == -1) {
        return UNRECOGNIZED;
      }
      return VALUES[desc.getIndex()];
    }

    private final int value;

    private JobType(int value) {
      this.value = value;
    }

    // @@protoc_insertion_point(enum_scope:google.cloud.bigquery.reservation.v1.Assignment.JobType)
  }

  /**
   *
   *
   *

   * Assignment will remain in PENDING state if no active capacity commitment is
   * present. It will become ACTIVE when some capacity commitment becomes
   * active.
   *

   *
   * Protobuf enum {@code google.cloud.bigquery.reservation.v1.Assignment.State}
   */
  public enum State implements com.google.protobuf.ProtocolMessageEnum {
    /**
     *
     *
     *

     * Invalid state value.
     *

     *
     * STATE_UNSPECIFIED = 0;
     */
    STATE_UNSPECIFIED(0),
    /**
     *
     *
     *

     * Queries from assignee will be executed as on-demand, if related
     * assignment is pending.
     *

     *
     * PENDING = 1;
     */
    PENDING(1),
    /**
     *
     *
     *

     * Assignment is ready.
     *

     *
     * ACTIVE = 2;
     */
    ACTIVE(2),
    UNRECOGNIZED(-1),
    ;

    /**
     *
     *
     *

     * Invalid state value.
     *

     *
     * STATE_UNSPECIFIED = 0;
     */
    public static final int STATE_UNSPECIFIED_VALUE = 0;
    /**
     *
     *
     *

     * Queries from assignee will be executed as on-demand, if related
     * assignment is pending.
     *

     *
     * PENDING = 1;
     */
    public static final int PENDING_VALUE = 1;
    /**
     *
     *
     *

     * Assignment is ready.
     *

     *
     * ACTIVE = 2;
     */
    public static final int ACTIVE_VALUE = 2;

    public final int getNumber() {
      if (this == UNRECOGNIZED) {
        throw new java.lang.IllegalArgumentException(
            "Can't get the number of an unknown enum value.");
      }
      return value;
    }

    /**
     * @param value The numeric wire value of the corresponding enum entry.
     * @return The enum associated with the given numeric wire value.
     * @deprecated Use {@link #forNumber(int)} instead.
     */
    @java.lang.Deprecated
    public static State valueOf(int value) {
      return forNumber(value);
    }

    /**
     * @param value The numeric wire value of the corresponding enum entry.
     * @return The enum associated with the given numeric wire value.
     */
    public static State forNumber(int value) {
      switch (value) {
        case 0:
          return STATE_UNSPECIFIED;
        case 1:
          return PENDING;
        case 2:
          return ACTIVE;
        default:
          return null;
      }
    }

    public static com.google.protobuf.Internal.EnumLiteMap<State> internalGetValueMap() {
      return internalValueMap;
    }

    private static final com.google.protobuf.Internal.EnumLiteMap<State> internalValueMap =
        new com.google.protobuf.Internal.EnumLiteMap<State>() {
          public State findValueByNumber(int number) {
            return State.forNumber(number);
          }
        };

    public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() {
      if (this == UNRECOGNIZED) {
        throw new java.lang.IllegalStateException(
            "Can't get the descriptor of an unrecognized enum value.");
      }
      return getDescriptor().getValues().get(ordinal());
    }

    public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() {
      return getDescriptor();
    }

    public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() {
      return com.google.cloud.bigquery.reservation.v1.Assignment.getDescriptor()
          .getEnumTypes()
          .get(1);
    }

    private static final State[] VALUES = values();

    public static State valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) {
      if (desc.getType() != getDescriptor()) {
        throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type.");
      }
      if (desc.getIndex() == -1) {
        return UNRECOGNIZED;
      }
      return VALUES[desc.getIndex()];
    }

    private final int value;

    private State(int value) {
      this.value = value;
    }

    // @@protoc_insertion_point(enum_scope:google.cloud.bigquery.reservation.v1.Assignment.State)
  }

  public static final int NAME_FIELD_NUMBER = 1;
  private volatile java.lang.Object name_;
  /**
   *
   *
   *

   * Output only. Name of the resource. E.g.:
   * `projects/myproject/locations/US/reservations/team1-prod/assignments/123`.
   * The assignment_id must only contain lower case alphanumeric characters or
   * dashes and the max length is 64 characters.
   *

   *
   * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
   *
   * @return The name.
   */
  @java.lang.Override
  public java.lang.String getName() {
    java.lang.Object ref = name_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      name_ = s;
      return s;
    }
  }
  /**
   *
   *
   *

   * Output only. Name of the resource. E.g.:
   * `projects/myproject/locations/US/reservations/team1-prod/assignments/123`.
   * The assignment_id must only contain lower case alphanumeric characters or
   * dashes and the max length is 64 characters.
   *

   *
   * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
   *
   * @return The bytes for name.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getNameBytes() {
    java.lang.Object ref = name_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      name_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int ASSIGNEE_FIELD_NUMBER = 4;
  private volatile java.lang.Object assignee_;
  /**
   *
   *
   *

   * The resource which will use the reservation. E.g.
   * `projects/myproject`, `folders/123`, or `organizations/456`.
   *

   *
   * string assignee = 4;
   *
   * @return The assignee.
   */
  @java.lang.Override
  public java.lang.String getAssignee() {
    java.lang.Object ref = assignee_;
    if (ref instanceof java.lang.String) {
      return (java.lang.String) ref;
    } else {
      com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
      java.lang.String s = bs.toStringUtf8();
      assignee_ = s;
      return s;
    }
  }
  /**
   *
   *
   *

   * The resource which will use the reservation. E.g.
   * `projects/myproject`, `folders/123`, or `organizations/456`.
   *

   *
   * string assignee = 4;
   *
   * @return The bytes for assignee.
   */
  @java.lang.Override
  public com.google.protobuf.ByteString getAssigneeBytes() {
    java.lang.Object ref = assignee_;
    if (ref instanceof java.lang.String) {
      com.google.protobuf.ByteString b =
          com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
      assignee_ = b;
      return b;
    } else {
      return (com.google.protobuf.ByteString) ref;
    }
  }

  public static final int JOB_TYPE_FIELD_NUMBER = 3;
  private int jobType_;
  /**
   *
   *
   *

   * Which type of jobs will use the reservation.
   *

   *
   * .google.cloud.bigquery.reservation.v1.Assignment.JobType job_type = 3;
   *
   * @return The enum numeric value on the wire for jobType.
   */
  @java.lang.Override
  public int getJobTypeValue() {
    return jobType_;
  }
  /**
   *
   *
   *

   * Which type of jobs will use the reservation.
   *

   *
   * .google.cloud.bigquery.reservation.v1.Assignment.JobType job_type = 3;
   *
   * @return The jobType.
   */
  @java.lang.Override
  public com.google.cloud.bigquery.reservation.v1.Assignment.JobType getJobType() {
    @SuppressWarnings("deprecation")
    com.google.cloud.bigquery.reservation.v1.Assignment.JobType result =
        com.google.cloud.bigquery.reservation.v1.Assignment.JobType.valueOf(jobType_);
    return result == null
        ? com.google.cloud.bigquery.reservation.v1.Assignment.JobType.UNRECOGNIZED
        : result;
  }

  public static final int STATE_FIELD_NUMBER = 6;
  private int state_;
  /**
   *
   *
   *

   * Output only. State of the assignment.
   *

   *
   *
   * .google.cloud.bigquery.reservation.v1.Assignment.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY];
   *
   *
   * @return The enum numeric value on the wire for state.
   */
  @java.lang.Override
  public int getStateValue() {
    return state_;
  }
  /**
   *
   *
   *

   * Output only. State of the assignment.
   *

   *
   *
   * .google.cloud.bigquery.reservation.v1.Assignment.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY];
   *
   *
   * @return The state.
   */
  @java.lang.Override
  public com.google.cloud.bigquery.reservation.v1.Assignment.State getState() {
    @SuppressWarnings("deprecation")
    com.google.cloud.bigquery.reservation.v1.Assignment.State result =
        com.google.cloud.bigquery.reservation.v1.Assignment.State.valueOf(state_);
    return result == null
        ? com.google.cloud.bigquery.reservation.v1.Assignment.State.UNRECOGNIZED
        : result;
  }

  private byte memoizedIsInitialized = -1;

  @java.lang.Override
  public final boolean isInitialized() {
    byte isInitialized = memoizedIsInitialized;
    if (isInitialized == 1) return true;
    if (isInitialized == 0) return false;

    memoizedIsInitialized = 1;
    return true;
  }

  @java.lang.Override
  public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException {
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_);
    }
    if (jobType_
        != com.google.cloud.bigquery.reservation.v1.Assignment.JobType.JOB_TYPE_UNSPECIFIED
            .getNumber()) {
      output.writeEnum(3, jobType_);
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(assignee_)) {
      com.google.protobuf.GeneratedMessageV3.writeString(output, 4, assignee_);
    }
    if (state_
        != com.google.cloud.bigquery.reservation.v1.Assignment.State.STATE_UNSPECIFIED
            .getNumber()) {
      output.writeEnum(6, state_);
    }
    getUnknownFields().writeTo(output);
  }

  @java.lang.Override
  public int getSerializedSize() {
    int size = memoizedSize;
    if (size != -1) return size;

    size = 0;
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_);
    }
    if (jobType_
        != com.google.cloud.bigquery.reservation.v1.Assignment.JobType.JOB_TYPE_UNSPECIFIED
            .getNumber()) {
      size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, jobType_);
    }
    if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(assignee_)) {
      size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, assignee_);
    }
    if (state_
        != com.google.cloud.bigquery.reservation.v1.Assignment.State.STATE_UNSPECIFIED
            .getNumber()) {
      size += com.google.protobuf.CodedOutputStream.computeEnumSize(6, state_);
    }
    size += getUnknownFields().getSerializedSize();
    memoizedSize = size;
    return size;
  }

  @java.lang.Override
  public boolean equals(final java.lang.Object obj) {
    if (obj == this) {
      return true;
    }
    if (!(obj instanceof com.google.cloud.bigquery.reservation.v1.Assignment)) {
      return super.equals(obj);
    }
    com.google.cloud.bigquery.reservation.v1.Assignment other =
        (com.google.cloud.bigquery.reservation.v1.Assignment) obj;

    if (!getName().equals(other.getName())) return false;
    if (!getAssignee().equals(other.getAssignee())) return false;
    if (jobType_ != other.jobType_) return false;
    if (state_ != other.state_) return false;
    if (!getUnknownFields().equals(other.getUnknownFields())) return false;
    return true;
  }

  @java.lang.Override
  public int hashCode() {
    if (memoizedHashCode != 0) {
      return memoizedHashCode;
    }
    int hash = 41;
    hash = (19 * hash) + getDescriptor().hashCode();
    hash = (37 * hash) + NAME_FIELD_NUMBER;
    hash = (53 * hash) + getName().hashCode();
    hash = (37 * hash) + ASSIGNEE_FIELD_NUMBER;
    hash = (53 * hash) + getAssignee().hashCode();
    hash = (37 * hash) + JOB_TYPE_FIELD_NUMBER;
    hash = (53 * hash) + jobType_;
    hash = (37 * hash) + STATE_FIELD_NUMBER;
    hash = (53 * hash) + state_;
    hash = (29 * hash) + getUnknownFields().hashCode();
    memoizedHashCode = hash;
    return hash;
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseFrom(
      java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseFrom(
      java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseFrom(
      com.google.protobuf.ByteString data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseFrom(
      com.google.protobuf.ByteString data,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseFrom(byte[] data)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data);
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseFrom(
      byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws com.google.protobuf.InvalidProtocolBufferException {
    return PARSER.parseFrom(data, extensionRegistry);
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseDelimitedFrom(
      java.io.InputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input);
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseDelimitedFrom(
      java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(
        PARSER, input, extensionRegistry);
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseFrom(
      com.google.protobuf.CodedInputStream input) throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input);
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment parseFrom(
      com.google.protobuf.CodedInputStream input,
      com.google.protobuf.ExtensionRegistryLite extensionRegistry)
      throws java.io.IOException {
    return com.google.protobuf.GeneratedMessageV3.parseWithIOException(
        PARSER, input, extensionRegistry);
  }

  @java.lang.Override
  public Builder newBuilderForType() {
    return newBuilder();
  }

  public static Builder newBuilder() {
    return DEFAULT_INSTANCE.toBuilder();
  }

  public static Builder newBuilder(com.google.cloud.bigquery.reservation.v1.Assignment prototype) {
    return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
  }

  @java.lang.Override
  public Builder toBuilder() {
    return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this);
  }

  @java.lang.Override
  protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
    Builder builder = new Builder(parent);
    return builder;
  }
  /**
   *
   *
   *

   * An assignment allows a project to submit jobs
   * of a certain type using slots from the specified reservation.
   *

   *
   * Protobuf type {@code google.cloud.bigquery.reservation.v1.Assignment}
   */
  public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder<Builder>
      implements
      // @@protoc_insertion_point(builder_implements:google.cloud.bigquery.reservation.v1.Assignment)
      com.google.cloud.bigquery.reservation.v1.AssignmentOrBuilder {
    public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() {
      return com.google.cloud.bigquery.reservation.v1.ReservationProto
          .internal_static_google_cloud_bigquery_reservation_v1_Assignment_descriptor;
    }

    @java.lang.Override
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return com.google.cloud.bigquery.reservation.v1.ReservationProto
          .internal_static_google_cloud_bigquery_reservation_v1_Assignment_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              com.google.cloud.bigquery.reservation.v1.Assignment.class,
              com.google.cloud.bigquery.reservation.v1.Assignment.Builder.class);
    }

    // Construct using com.google.cloud.bigquery.reservation.v1.Assignment.newBuilder()
    private Builder() {}

    private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      super(parent);
    }

    @java.lang.Override
    public Builder clear() {
      super.clear();
      name_ = "";

      assignee_ = "";

      jobType_ = 0;

      state_ = 0;

      return this;
    }

    @java.lang.Override
    public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() {
      return com.google.cloud.bigquery.reservation.v1.ReservationProto
          .internal_static_google_cloud_bigquery_reservation_v1_Assignment_descriptor;
    }

    @java.lang.Override
    public com.google.cloud.bigquery.reservation.v1.Assignment getDefaultInstanceForType() {
      return com.google.cloud.bigquery.reservation.v1.Assignment.getDefaultInstance();
    }

    @java.lang.Override
    public com.google.cloud.bigquery.reservation.v1.Assignment build() {
      com.google.cloud.bigquery.reservation.v1.Assignment result = buildPartial();
      if (!result.isInitialized()) {
        throw newUninitializedMessageException(result);
      }
      return result;
    }

    @java.lang.Override
    public com.google.cloud.bigquery.reservation.v1.Assignment buildPartial() {
      com.google.cloud.bigquery.reservation.v1.Assignment result =
          new com.google.cloud.bigquery.reservation.v1.Assignment(this);
      result.name_ = name_;
      result.assignee_ = assignee_;
      result.jobType_ = jobType_;
      result.state_ = state_;
      onBuilt();
      return result;
    }

    @java.lang.Override
    public Builder clone() {
      return super.clone();
    }

    @java.lang.Override
    public Builder setField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.setField(field, value);
    }

    @java.lang.Override
    public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) {
      return super.clearField(field);
    }

    @java.lang.Override
    public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) {
      return super.clearOneof(oneof);
    }

    @java.lang.Override
    public Builder setRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) {
      return super.setRepeatedField(field, index, value);
    }

    @java.lang.Override
    public Builder addRepeatedField(
        com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) {
      return super.addRepeatedField(field, value);
    }

    @java.lang.Override
    public Builder mergeFrom(com.google.protobuf.Message other) {
      if (other instanceof com.google.cloud.bigquery.reservation.v1.Assignment) {
        return mergeFrom((com.google.cloud.bigquery.reservation.v1.Assignment) other);
      } else {
        super.mergeFrom(other);
        return this;
      }
    }

    public Builder mergeFrom(com.google.cloud.bigquery.reservation.v1.Assignment other) {
      if (other == com.google.cloud.bigquery.reservation.v1.Assignment.getDefaultInstance())
        return this;
      if (!other.getName().isEmpty()) {
        name_ = other.name_;
        onChanged();
      }
      if (!other.getAssignee().isEmpty()) {
        assignee_ = other.assignee_;
        onChanged();
      }
      if (other.jobType_ != 0) {
        setJobTypeValue(other.getJobTypeValue());
      }
      if (other.state_ != 0) {
        setStateValue(other.getStateValue());
      }
      this.mergeUnknownFields(other.getUnknownFields());
      onChanged();
      return this;
    }

    @java.lang.Override
    public final boolean isInitialized() {
      return true;
    }

    @java.lang.Override
    public Builder mergeFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      if (extensionRegistry == null) {
        throw new java.lang.NullPointerException();
      }
      try {
        boolean done = false;
        while (!done) {
          int tag = input.readTag();
          switch (tag) {
            case 0:
              done = true;
              break;
            case 10:
              {
                name_ = input.readStringRequireUtf8();

                break;
              } // case 10
            case 24:
              {
                jobType_ = input.readEnum();

                break;
              } // case 24
            case 34:
              {
                assignee_ = input.readStringRequireUtf8();

                break;
              } // case 34
            case 48:
              {
                state_ = input.readEnum();

                break;
              } // case 48
            default:
              {
                if (!super.parseUnknownField(input, extensionRegistry, tag)) {
                  done = true; // was an endgroup tag
                }
                break;
              } // default:
          } // switch (tag)
        } // while (!done)
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.unwrapIOException();
      } finally {
        onChanged();
      } // finally
      return this;
    }

    private java.lang.Object name_ = "";
    /**
     *
     *
     *

     * Output only. Name of the resource. E.g.:
     * `projects/myproject/locations/US/reservations/team1-prod/assignments/123`.
     * The assignment_id must only contain lower case alphanumeric characters or
     * dashes and the max length is 64 characters.
     *

     *
     * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     * @return The name.
     */
    public java.lang.String getName() {
      java.lang.Object ref = name_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        name_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     *

     * Output only. Name of the resource. E.g.:
     * `projects/myproject/locations/US/reservations/team1-prod/assignments/123`.
     * The assignment_id must only contain lower case alphanumeric characters or
     * dashes and the max length is 64 characters.
     *

     *
     * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     * @return The bytes for name.
     */
    public com.google.protobuf.ByteString getNameBytes() {
      java.lang.Object ref = name_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        name_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     *

     * Output only. Name of the resource. E.g.:
     * `projects/myproject/locations/US/reservations/team1-prod/assignments/123`.
     * The assignment_id must only contain lower case alphanumeric characters or
     * dashes and the max length is 64 characters.
     *

     *
     * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     * @param value The name to set.
     * @return This builder for chaining.
     */
    public Builder setName(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }

      name_ = value;
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Output only. Name of the resource. E.g.:
     * `projects/myproject/locations/US/reservations/team1-prod/assignments/123`.
     * The assignment_id must only contain lower case alphanumeric characters or
     * dashes and the max length is 64 characters.
     *

     *
     * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     * @return This builder for chaining.
     */
    public Builder clearName() {

      name_ = getDefaultInstance().getName();
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Output only. Name of the resource. E.g.:
     * `projects/myproject/locations/US/reservations/team1-prod/assignments/123`.
     * The assignment_id must only contain lower case alphanumeric characters or
     * dashes and the max length is 64 characters.
     *

     *
     * string name = 1 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     * @param value The bytes for name to set.
     * @return This builder for chaining.
     */
    public Builder setNameBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);

      name_ = value;
      onChanged();
      return this;
    }

    private java.lang.Object assignee_ = "";
    /**
     *
     *
     *

     * The resource which will use the reservation. E.g.
     * `projects/myproject`, `folders/123`, or `organizations/456`.
     *

     *
     * string assignee = 4;
     *
     * @return The assignee.
     */
    public java.lang.String getAssignee() {
      java.lang.Object ref = assignee_;
      if (!(ref instanceof java.lang.String)) {
        com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref;
        java.lang.String s = bs.toStringUtf8();
        assignee_ = s;
        return s;
      } else {
        return (java.lang.String) ref;
      }
    }
    /**
     *
     *
     *

     * The resource which will use the reservation. E.g.
     * `projects/myproject`, `folders/123`, or `organizations/456`.
     *

     *
     * string assignee = 4;
     *
     * @return The bytes for assignee.
     */
    public com.google.protobuf.ByteString getAssigneeBytes() {
      java.lang.Object ref = assignee_;
      if (ref instanceof String) {
        com.google.protobuf.ByteString b =
            com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref);
        assignee_ = b;
        return b;
      } else {
        return (com.google.protobuf.ByteString) ref;
      }
    }
    /**
     *
     *
     *

     * The resource which will use the reservation. E.g.
     * `projects/myproject`, `folders/123`, or `organizations/456`.
     *

     *
     * string assignee = 4;
     *
     * @param value The assignee to set.
     * @return This builder for chaining.
     */
    public Builder setAssignee(java.lang.String value) {
      if (value == null) {
        throw new NullPointerException();
      }

      assignee_ = value;
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * The resource which will use the reservation. E.g.
     * `projects/myproject`, `folders/123`, or `organizations/456`.
     *

     *
     * string assignee = 4;
     *
     * @return This builder for chaining.
     */
    public Builder clearAssignee() {

      assignee_ = getDefaultInstance().getAssignee();
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * The resource which will use the reservation. E.g.
     * `projects/myproject`, `folders/123`, or `organizations/456`.
     *

     *
     * string assignee = 4;
     *
     * @param value The bytes for assignee to set.
     * @return This builder for chaining.
     */
    public Builder setAssigneeBytes(com.google.protobuf.ByteString value) {
      if (value == null) {
        throw new NullPointerException();
      }
      checkByteStringIsUtf8(value);

      assignee_ = value;
      onChanged();
      return this;
    }

    private int jobType_ = 0;
    /**
     *
     *
     *

     * Which type of jobs will use the reservation.
     *

     *
     * .google.cloud.bigquery.reservation.v1.Assignment.JobType job_type = 3;
     *
     * @return The enum numeric value on the wire for jobType.
     */
    @java.lang.Override
    public int getJobTypeValue() {
      return jobType_;
    }
    /**
     *
     *
     *

     * Which type of jobs will use the reservation.
     *

     *
     * .google.cloud.bigquery.reservation.v1.Assignment.JobType job_type = 3;
     *
     * @param value The enum numeric value on the wire for jobType to set.
     * @return This builder for chaining.
     */
    public Builder setJobTypeValue(int value) {

      jobType_ = value;
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Which type of jobs will use the reservation.
     *

     *
     * .google.cloud.bigquery.reservation.v1.Assignment.JobType job_type = 3;
     *
     * @return The jobType.
     */
    @java.lang.Override
    public com.google.cloud.bigquery.reservation.v1.Assignment.JobType getJobType() {
      @SuppressWarnings("deprecation")
      com.google.cloud.bigquery.reservation.v1.Assignment.JobType result =
          com.google.cloud.bigquery.reservation.v1.Assignment.JobType.valueOf(jobType_);
      return result == null
          ? com.google.cloud.bigquery.reservation.v1.Assignment.JobType.UNRECOGNIZED
          : result;
    }
    /**
     *
     *
     *

     * Which type of jobs will use the reservation.
     *

     *
     * .google.cloud.bigquery.reservation.v1.Assignment.JobType job_type = 3;
     *
     * @param value The jobType to set.
     * @return This builder for chaining.
     */
    public Builder setJobType(com.google.cloud.bigquery.reservation.v1.Assignment.JobType value) {
      if (value == null) {
        throw new NullPointerException();
      }

      jobType_ = value.getNumber();
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Which type of jobs will use the reservation.
     *

     *
     * .google.cloud.bigquery.reservation.v1.Assignment.JobType job_type = 3;
     *
     * @return This builder for chaining.
     */
    public Builder clearJobType() {

      jobType_ = 0;
      onChanged();
      return this;
    }

    private int state_ = 0;
    /**
     *
     *
     *

     * Output only. State of the assignment.
     *

     *
     *
     * .google.cloud.bigquery.reservation.v1.Assignment.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     *
     * @return The enum numeric value on the wire for state.
     */
    @java.lang.Override
    public int getStateValue() {
      return state_;
    }
    /**
     *
     *
     *

     * Output only. State of the assignment.
     *

     *
     *
     * .google.cloud.bigquery.reservation.v1.Assignment.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     *
     * @param value The enum numeric value on the wire for state to set.
     * @return This builder for chaining.
     */
    public Builder setStateValue(int value) {

      state_ = value;
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Output only. State of the assignment.
     *

     *
     *
     * .google.cloud.bigquery.reservation.v1.Assignment.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     *
     * @return The state.
     */
    @java.lang.Override
    public com.google.cloud.bigquery.reservation.v1.Assignment.State getState() {
      @SuppressWarnings("deprecation")
      com.google.cloud.bigquery.reservation.v1.Assignment.State result =
          com.google.cloud.bigquery.reservation.v1.Assignment.State.valueOf(state_);
      return result == null
          ? com.google.cloud.bigquery.reservation.v1.Assignment.State.UNRECOGNIZED
          : result;
    }
    /**
     *
     *
     *

     * Output only. State of the assignment.
     *

     *
     *
     * .google.cloud.bigquery.reservation.v1.Assignment.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     *
     * @param value The state to set.
     * @return This builder for chaining.
     */
    public Builder setState(com.google.cloud.bigquery.reservation.v1.Assignment.State value) {
      if (value == null) {
        throw new NullPointerException();
      }

      state_ = value.getNumber();
      onChanged();
      return this;
    }
    /**
     *
     *
     *

     * Output only. State of the assignment.
     *

     *
     *
     * .google.cloud.bigquery.reservation.v1.Assignment.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY];
     *
     *
     * @return This builder for chaining.
     */
    public Builder clearState() {

      state_ = 0;
      onChanged();
      return this;
    }

    @java.lang.Override
    public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.setUnknownFields(unknownFields);
    }

    @java.lang.Override
    public final Builder mergeUnknownFields(
        final com.google.protobuf.UnknownFieldSet unknownFields) {
      return super.mergeUnknownFields(unknownFields);
    }

    // @@protoc_insertion_point(builder_scope:google.cloud.bigquery.reservation.v1.Assignment)
  }

  // @@protoc_insertion_point(class_scope:google.cloud.bigquery.reservation.v1.Assignment)
  private static final com.google.cloud.bigquery.reservation.v1.Assignment DEFAULT_INSTANCE;

  static {
    DEFAULT_INSTANCE = new com.google.cloud.bigquery.reservation.v1.Assignment();
  }

  public static com.google.cloud.bigquery.reservation.v1.Assignment getDefaultInstance() {
    return DEFAULT_INSTANCE;
  }

  private static final com.google.protobuf.Parser<Assignment> PARSER =
      new com.google.protobuf.AbstractParser<Assignment>() {
        @java.lang.Override
        public Assignment parsePartialFrom(
            com.google.protobuf.CodedInputStream input,
            com.google.protobuf.ExtensionRegistryLite extensionRegistry)
            throws com.google.protobuf.InvalidProtocolBufferException {
          Builder builder = newBuilder();
          try {
            builder.mergeFrom(input, extensionRegistry);
          } catch (com.google.protobuf.InvalidProtocolBufferException e) {
            throw e.setUnfinishedMessage(builder.buildPartial());
          } catch (com.google.protobuf.UninitializedMessageException e) {
            throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial());
          } catch (java.io.IOException e) {
            throw new com.google.protobuf.InvalidProtocolBufferException(e)
                .setUnfinishedMessage(builder.buildPartial());
          }
          return builder.buildPartial();
        }
      };

  public static com.google.protobuf.Parser<Assignment> parser() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.protobuf.Parser<Assignment> getParserForType() {
    return PARSER;
  }

  @java.lang.Override
  public com.google.cloud.bigquery.reservation.v1.Assignment getDefaultInstanceForType() {
    return DEFAULT_INSTANCE;
  }
}


text:
============
Installation
============

General Options
---------------

At the command line::

    $ pip install pymoskito

Or, if you have virtualenvwrapper installed::

    $ mkvirtualenv pymoskito
    $ pip install pymoskito

From the repository::

    $ git clone https://github.com/cklb/pymoskito
    $ python setup.py install

For Windows
-----------

PyMoskito depends on Qt5 and VTK .

Qt5 is already included in the most python distributions, to have an easy start
we recommend to use Winpython_ .

The wheel for the *VTK* package (Version >= 7) can be obtained from
http://www.lfd.uci.edu/~gohlke/pythonlibs/#vtk .
It can be installed using the Winpython Control Panel or directly via::

    $ pip install VTK-VERSION_NAME_HERE.whl

from your winpython shell.

.. _Winpython: https://winpython.github.io/

Troubleshooting
---------------

**Missing dependencies (windows)**

If the provided packages on your system are to old, pip may feel obligated to
update them. Since the majority of packages now provide ready to use wheels
for windows on pypi_ this should work automatically.
If for some reason this process fails, you will most certainly find an
appropriate wheel here_ . After downloading just navigate your shell into the
directory and call::

    $ pip install PACKAGE_NAME.whl

to install it.

.. _pypi: https://pypi.python.org/pypi
.. _here: https://www.lfd.uci.edu/~gohlke/pythonlibs/

**Missing vtk libraries (linux)**

If importing ``vtk`` fails with something similar to::

    >>> Import Error: vtkIOAMRPython module not found

then look at the output of::

    $ ldd PATH/TO/SITE-PKGS/vtk/vtkIOAMRPython.so

to see which libs are missing.

**GUI looks blurry on high-dpi displays**

You may add the line::

    os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "1"

before you import pymoskito to enable autoscaling in Qt.


text:
require 'shellwords'

module Serverspec
  module Commands
    class Darwin < Base
      class NotImplementedError < Exception; end

      def check_file_md5checksum file, expected
        "openssl md5 #{escape(file)} | cut -d'=' -f2 | cut -c 2- | grep -E ^#{escape(expected)}$"
      end

      def check_mode file, mode
        regexp = "^#{mode}$"
        "stat -f %A #{escape(file)} | grep -- #{escape(regexp)}"
      end

      def check_owner file, owner
        regexp = "^#{owner}$"
        "stat -f %Su #{escape(file)} | grep -- #{escape(regexp)}"
      end

      def check_grouped file, group
        regexp = "^#{group}$"
        "stat -f %Sg #{escape(file)} | grep -- #{escape(regexp)}"
      end

      def get_mode(file)
        "stat -f %A #{escape(file)}"
      end

      def check_access_by_user file, user, access
        "sudo -u #{user} -s /bin/test -#{access} #{file}"
      end
    end
  end
end