text:
using Newtonsoft.Json;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web;
using System.Collections;
using System.Web.Hosting;
using Bonobo.Git.Server.Configuration;

namespace Bonobo.Git.Server.Data
{
    public class ADBackendStore<T> : IEnumerable<T> where T : INameProperty
    {
        public T this[string key]
        {
            get
            {
                T result = default(T);

                content.TryGetValue(key, out result);

                return result;
            }

            set
            {
                content.AddOrUpdate(key, value, (k, v) => value);
            }
        }

        private string storagePath;
        private ConcurrentDictionary<string, T> content;
        private readonly string hexchars = "0123456789abcdef";

        public ADBackendStore(string rootpath, string name)
        {
            storagePath = Path.Combine(GetRootPath(rootpath), name);
            content = LoadContent();
        }

        public bool Add(T item)
        {
            return content.TryAdd(item.Name, item) && Store(item);
        }

        public bool Remove(string key)
        {
            T removedItem;
            return content.TryRemove(key, out removedItem) && Delete(removedItem);
        }

        public bool Remove(T item)
        {
            return Remove(item.Name);
        }

        public void Update(T item)
        {
            if (content.TryUpdate(item.Name, item, content[item.Name]))
            {
                Store(item);
            }
        }

        public void AddOrUpdate(T item)
        {
            content.AddOrUpdate(item.Name, item, (k, v) => item);
            Store(item);
        }

        public IEnumerator<T> GetEnumerator()
        {
            return content.Values.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        private bool Store(T item)
        {
            bool result = false;

            try
            {
                string itemFilename = Path.Combine(storagePath, GetItemFilename(item));
                File.WriteAllText(itemFilename, JsonConvert.SerializeObject(item));
                result = true;
            }
            catch
            {
            }

            return result;
        }

        private bool Delete(T item)
        {
            bool result = false;

            try
            {
                string itemFilename = Path.Combine(storagePath, GetItemFilename(item));
                File.Delete(itemFilename);
                result = true;
            }
            catch
            {
            }

            return result;
        }

        private ConcurrentDictionary<string, T> LoadContent()
        {
            ConcurrentDictionary<string, T> result = new ConcurrentDictionary<string, T>();

            if (!Directory.Exists(storagePath))
            {
                Directory.CreateDirectory(storagePath);
            }

            foreach (string filename in Directory.EnumerateFileSystemEntries(storagePath, "*.json"))
            {
                try
                {
                    T item = JsonConvert.DeserializeObject<T>(File.ReadAllText(filename));
                    result.TryAdd(item.Name, item);
                }
                catch
                {
                }
            }

            return result;
        }

        private string GetRootPath(string path)
        {
            return Path.IsPathRooted(path) ? path : HostingEnvironment.MapPath(path);
        }

        private string GetItemFilename(T item)
        {
            StringBuilder result = new StringBuilder(45);

            byte[] hash = SHA1.Create().ComputeHash(Encoding.UTF8.GetBytes(item.Name));
            for (int i = 0; i < hash.Length; i++)
            {
                result.Append(hexchars[hash[i] >> 4]);
                result.Append(hexchars[hash[i] & 0x0f]);
            }
            result.Append(".json");

            return result.ToString();
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
package co.cask.tephra.distributed;

import org.apache.hadoop.conf.Configuration;
import org.apache.thrift.TException;
import org.apache.twill.discovery.DiscoveryServiceClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * An tx client provider that creates a new connection every time.
 */
public class SingleUseClientProvider extends AbstractClientProvider {

  private static final Logger LOG =
      LoggerFactory.getLogger(SingleUseClientProvider.class);

  public SingleUseClientProvider(Configuration conf, DiscoveryServiceClient discoveryServiceClient, int timeout) {
    super(conf, discoveryServiceClient);
    this.timeout = timeout;
  }

  final int timeout;

  @Override
  public TransactionServiceThriftClient getClient() throws TException {
    try {
      return this.newClient(timeout);
    } catch (TException e) {
      LOG.error("Unable to create new tx client: " + e.getMessage());
      throw e;
    }
  }

  @Override
  public void returnClient(TransactionServiceThriftClient client) {
    discardClient(client);
  }

  @Override
  public void discardClient(TransactionServiceThriftClient client) {
    client.close();
  }

  @Override
  public String toString() {
    return "Single-use(timeout = " + timeout + ")";
  }
}


text:
'use strict';
const auth = rootRequire('./util/auth');
const addTorrents = rootRequire('./api/add-torrents').addTorrents;

const MAGNET_REGEX = /magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32}/i;

function redirectToHome (req, res, next) {
  res.redirect('/');
}
redirectToHome['@raw'] = true;

function fastAdd (req) {
  const magnet = decodeURIComponent(req.url.substr(5));

  if (magnet.match(MAGNET_REGEX)) return addTorrents(req, [magnet]);
  return Promise.resolve();
}

module.exports = [auth.api, fastAdd, redirectToHome];


text:
//============================================================================
// Name        : Utils.h
// Author      : Jordan Frank (jordan.frank@cs.mcgill.ca)
// Copyright   : MIT
// Description : Some helpful utility methods.
//============================================================================

#include <stdlib.h>
#include <ANN/ANN.h>
#include <opencv/cxcore.h>

#ifndef ulong
#define ulong unsigned long
#endif
#ifndef uint
#define uint unsigned int
#endif

#ifndef UTILS_H_
#define UTILS_H_

typedef struct {
	unsigned long length;
	unsigned long exclude;
	uint verbosity;
	int delay;
	uint neighbours;
	uint seglength;
	uint indim;
	uint embdim;
	uint pcaembdim;
	char *column;
	char *infile;
	char *outfile;
	char dimset;
	char embset;
	char pcaembset;
	char delayset;
	char stdo;
	uint algorithm;
} Settings;

void get_embedding(Settings* settings, ANNcoord*& data, unsigned long &length);
void get_ann_points(ANNpointArray &dataPts, ANNcoord* series, unsigned long rows, uint cols);
void print_matrix(CvMat* matrix);

#define MAT_TYPE (sizeof(ANNcoord)==sizeof(float)) ? CV_32FC1 : CV_64FC1
#define FLOAT_SCAN "%G"
#define FLOAT_OUT "%.8G"

#endif /* UTILS_H_ */


text:
package com.loadburn.heron.storage.sql.mysql;

import com.loadburn.heron.storage.cache.ICache;
import com.loadburn.heron.storage.config.EntityMetadata;
import com.loadburn.heron.storage.sql.QueryImpl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * @author slacrey (scstlinfeng@yahoo.com)
 *         Date: 13-12-12
 */
public class MySQLQueryImpl extends QueryImpl {

    public MySQLQueryImpl(final EntityMetadata.EntityDescriptor entityDescriptor, final ICache cache,
                          final Connection connection, String query) {
        super(entityDescriptor, cache, connection, query);
    }

    @Override
    protected PreparedStatement prepareQueryStatement() throws SQLException {
        if (this.limit != null && this.offset != null) {
            this.query += " limit " + offset + "," + limit;
        } else if (this.limit != null) {
            this.query += " limit 0," + limit;
        }
        return connection().prepareStatement(this.query);
    }

}


text:
@protocol WebStatePrinter;
class GURL;

namespace base {
class DictionaryValue;
}  // namespace base

// Handles print requests from JavaScript window.print.
class PrintTabHelper : public web::WebStateObserver,
                       public web::WebStateUserData<PrintTabHelper> {
 public:
  explicit PrintTabHelper(web::WebState* web_state);
  ~PrintTabHelper() override;

  // Sets the |printer|, which is held weakly by this object.
  void set_printer(id<WebStatePrinter> printer);

 private:
  friend class web::WebStateUserData<PrintTabHelper>;

  // web::WebStateObserver overrides:
  void WebStateDestroyed(web::WebState* web_state) override;

  // Called when print message is sent by the web page.
  void OnPrintCommand(web::WebState* web_state,
                      const base::DictionaryValue& command,
                      const GURL& page_url,
                      bool user_initiated,
                      web::WebFrame* sender_frame);

  __weak id<WebStatePrinter> printer_;

  // Subscription for JS message.
  std::unique_ptr<web::WebState::ScriptCommandSubscription> subscription_;

  WEB_STATE_USER_DATA_KEY_DECL();

  DISALLOW_COPY_AND_ASSIGN(PrintTabHelper);
};

#endif  // IOS_CHROME_BROWSER_WEB_PRINT_TAB_HELPER_H_


text:
package org.jzp.code.solr.client.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 忽略注解
 *
 * @author jiazhipeng
 * @version 1.0
 * @date 2016-06-22
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface IgnoreField {

    String name() default "";
}


text:
package com.sibilantsolutions.grison.rx.event.action;

public class OperationConnectAction extends AbstractAction {
    public final String host;
    public final int port;

    public OperationConnectAction(String host, int port) {
        this.host = host;
        this.port = port;
    }
}


text:
(function() {
    d3.chart('HorizontalLegend', {
        initialize: function() {
            var chart = this;

            // assign a top level class to the chart
            chart.base
                .classed('HorizontalLegend', true);

            // default height and width from container.
            chart.w = chart.base.attr('width');
            chart.h = chart.base.attr('height');

            // labels base container
            var labelsBase = chart.base.append('g')
                .classed('labels', true)
                .attr('height', chart.h)
                .attr('width', chart.w);

            // labels layer
            var labelsLayer = chart.layer('labels', labelsBase, {
                dataBind : function(scale) {

                    // save scale - our data.
                    chart.scale = scale;

                    // in this case our data is the domain
                    // of the scale!
                    var domain = scale.domain();
                    return this.selectAll('text')
                        .data(domain);
                },

                insert : function() {

                    // create two
                    var t = this.append('text')
                        .attr('class', 'label');

                    // separate each label to each side.
                    t.attr('transform', function(d, i) {
                        if (i === 0) {
                            return 'translate(0,0)';
                        } else {
                            return 'translate(' + chart.w + ',0)';
                        }
                    })
                        .attr('text-anchor', function(d, i) {
                            if (i === 0) {
                                return 'start';
                            } else {
                                return 'end';
                            }
                        })
                        .attr('dy', chart.h - 3);

                    return t;
                }
            });

            // the actual boxes layer.
            var boxesBase = this.base
                .append('g')
                .classed('boxes', true)
                .attr('width', chart.base.attr('width'))
                .attr('height', chart.base.attr('height'));

            var boxesLayer = chart.layer('boxes', boxesBase, {

                // the data is a d3 color scale!
                dataBind : function(scale) {

                    // save scale
                    chart.scale = scale;

                    // generate data array from domain equal
                    // to the number of boxes our user wants
                    var domain = scale.domain(),
                        data = [];
                    for(var i = domain[0];
                        i <= domain[1];
                        i+= (domain[1]-domain[0])/chart.b) {
                        data.push(i);
                    }

                    // get the width of the labels on each end
                    var labels = chart.layer('labels').selectAll('text')[0],
                        leftWidth = labels[0].getBBox().width,
                        rightWidth = labels[1].getBBox().width;

                    // update box width to remove label widths
                    chart.box_width = (chart.w - rightWidth - leftWidth -
                    ((chart.b-1) * chart.pad)) / chart.b;

                    // make an x scale that starts after the left label
                    // and ends before the right label.
                    chart.position_scale = d3.scale.linear()
                        .domain(domain)
                        .range([
                            leftWidth + chart.pad,
                            chart.w - rightWidth - chart.box_width - chart.pad
                        ]);

                    // clear all boxes from previous render
                    this.selectAll('rect').remove();

                    // select rects for the boxes and bind our data.
                    return this.selectAll('rect').data(data);

                },
                insert : function() {
                    return this.append('rect')
                        .attr('y', 0)
                        .attr('height', chart.h);
                }
            });

            function _onBoxesEnter() {
                return this
                    .attr('x', function(d) {
                        return chart.position_scale(d);
                    })
                    .attr('width', chart.box_width)
                    .style('fill', chart.scale);
            }

            function _onLabelsEnter() {
                var domain = chart.scale.domain();

                return this.text(function(d) {
                    return d;
                    /* is this a percentage?
                    if (domain[0] === 0 && domain[1] <= 1) {
                        if (d > 0.01 || d === 0) {
                            return d3.format('%')(d);
                        } else {
                            return d3.format('.1%')(d.toFixed(2));
                        }
                    } else {
                        return d;
                    }
                    */
                });
            }

            //labelsLayer.on('enter', _onLabelsEnter);
            //labelsLayer.on('update', _onLabelsEnter);
            boxesLayer.on('enter', _onBoxesEnter);
            boxesLayer.on('update', _onBoxesEnter);

            return chart;
        },

        // padding between boxes.
        padding : function(newPadding) {
            if (!arguments.length) {
                return this.pad;
            }
            this.pad = newPadding;

            this.box_width = (this.w - ((this.b - 1) * this.pad)) / this.b;

            // only repaint if we have data (in this case the scale)
            if (this.scale) { this.draw(this.scale); }

            return this;
        },

        // how many boxes should one render
        boxes : function(newBoxes) {
            if (!arguments.length) {
                return this.b;
            }

            this.b = newBoxes;

            this.box_width = (this.w - ((this.b-1) * this.pad)) / this.b;

            // only repaint if we have data (in this case the scale)
            if (this.scale) { this.draw(this.scale); }

            return this;
        },

        // width of legend
        width : function(newWidth) {
            if (!arguments.length) {
                return this.w;
            }
            // save new width
            this.w = newWidth;

            // adjust the x scale range
            this.x =  d3.scale.linear()
                .range([0, this.w]);

            // adjust the base width
            this.base.attr('width', this.w);

            // only repaint if we have data (in this case the scale)
            if (this.scale) { this.draw(this.scale); }

            return this;
        },

        // height of legend
        height : function(newHeight) {
            if (!arguments.length) {
                return this.h;
            }

            // save new height
            this.h = newHeight;

            // adjust the base width
            this.base.attr('height', this.h);

            // only repaint if we have data (in this case the scale)
            if (this.scale) { this.draw(this.scale); }

            return this;
        }

    });
}());


text:
package org.scalatest

import org.scalatest.matchers.ShouldMatchers
import org.scalatest.events._

class SpecSuite extends FunSuite with SharedHelpers {

  test("three plain-old specifiers should be invoked in order") {
    class MySpec extends Spec with ShouldMatchers {
      var example1WasInvoked = false
      var example2WasInvokedAfterExample1 = false
      var example3WasInvokedAfterExample2 = false
      it("should get invoked") {
        example1WasInvoked = true
      }
      it("should also get invoked") {
        if (example1WasInvoked)
          example2WasInvokedAfterExample1 = true
      }
      it("should also also get invoked") {
        if (example2WasInvokedAfterExample1)
          example3WasInvokedAfterExample2 = true
      }
    }
    val a = new MySpec
    a.execute()
    assert(a.example1WasInvoked)
    assert(a.example2WasInvokedAfterExample1)
    assert(a.example3WasInvokedAfterExample2)
  }

  test("three plain-old specifiers should be invoked in order when two are surrounded by a plain-old describe") {
    class MySpec extends Spec with ShouldMatchers {
      var example1WasInvoked = false
      var example2WasInvokedAfterExample1 = false
      var example3WasInvokedAfterExample2 = false
      it("should get invoked") {
        example1WasInvoked = true
      }
      describe("Stack") {
        it("should also get invoked") {
          if (example1WasInvoked)
            example2WasInvokedAfterExample1 = true
        }
        it("should also also get invoked") {
          if (example2WasInvokedAfterExample1)
            example3WasInvokedAfterExample2 = true
        }
      }
    }
    val a = new MySpec
    a.execute()
    assert(a.example1WasInvoked)
    assert(a.example2WasInvokedAfterExample1)
    assert(a.example3WasInvokedAfterExample2)
  }

  test("two plain-old specifiers should show up in order of appearance in testNames") {
    class MySpec extends Spec with ShouldMatchers {
      var example1WasInvoked = false
      var example2WasInvokedAfterExample1 = false
      it("should get invoked") {
        example1WasInvoked = true
      }
      it("should also get invoked") {
        if (example1WasInvoked)
          example2WasInvokedAfterExample1 = true
      }
    }
    val a = new MySpec
    a.execute()
    assert(a.testNames.size === 2)
    assert(a.testNames.elements.toList(0) === "should get invoked")
    assert(a.testNames.elements.toList(1) === "should also get invoked")
  }

  test("plain-old specifier test names should include an enclosing describe string, separated by a space") {
    class MySpec extends Spec with ShouldMatchers {
      describe("A Stack") {
        it("must allow me to pop") {}
        it("must allow me to push") {}
      }
    }
    val a = new MySpec
    assert(a.testNames.size === 2)
    assert(a.testNames.elements.toList(0) === "A Stack must allow me to pop")
    assert(a.testNames.elements.toList(1) === "A Stack must allow me to push")
  }

  test("plain-old test names should properly nest plain-old descriptions in test names") {
    class MySpec extends Spec with ShouldMatchers {
      describe("A Stack") {
        describe("(when not empty)") {
          it("must allow me to pop") {}
        }
        describe("(when not full)") {
          it("must allow me to push") {}
        }
      }
    }
    val a = new MySpec
    assert(a.testNames.size === 2)
    assert(a.testNames.elements.toList(0) === "A Stack (when not empty) must allow me to pop")
    assert(a.testNames.elements.toList(1) === "A Stack (when not full) must allow me to push")
  }

  test("should be able to mix in BeforeAndAfter without any problems") {
    class MySpec extends Spec with ShouldMatchers with BeforeAndAfter {
      describe("A Stack") {
        describe("(when not empty)") {
          it("should allow me to pop") {}
        }
        describe("(when not full)") {
          it("should allow me to push") {}
        }
      }
    }
    val a = new MySpec
    a.execute()
  }

  // Test for good strings in report for top-level examples
  test("Top-level plain-old specifiers should yield good strings in a TestSucceeded report") {
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            if (testName.indexOf("must start with proper words") != -1)
              reportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      it("must start with proper words") {}
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
  }

  test("Top-level plain-old specifiers should yield good strings in a testSucceeded report") {
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            if (testName.indexOf("must start with proper words") != -1)
              reportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      it("must start with proper words") {}
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
  }

  test("Top-level plain-old specifiers should yield good strings in a testFailed report") {
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case event: TestFailed =>
            if (event.testName.indexOf("must start with proper words") != -1)
              reportHadCorrectTestName = true
            event.formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      it("must start with proper words") { fail() }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
  }

  // Tests for good strings in report for nested-one-level examples
  test("Nested-one-level plain-old specifiers should yield good strings in a TestSucceeded report") {
    var infoReportHadCorrectTestName = false
    var infoReportHadCorrectSpecText = false
    var infoReportHadCorrectFormattedSpecText = false
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    var infoProvidedHasBeenInvoked = false
    var theOtherMethodHasBeenInvoked = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case InfoProvided(ordinal, message, nameInfo, aboutAPendingTest, throwable, formatter, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the other method
            assert(!theOtherMethodHasBeenInvoked)
            infoProvidedHasBeenInvoked = true
            if (message.indexOf("My Spec") != -1)
              infoReportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "My Spec")
                  infoReportHadCorrectSpecText = true
                if (formattedText == "My Spec")
                  infoReportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the this method
            assert(infoProvidedHasBeenInvoked)
            theOtherMethodHasBeenInvoked = true
            if (testName.indexOf("My Spec must start with proper words") != -1)
              reportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      describe("My Spec") {
        it("must start with proper words") {}
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
    assert(infoReportHadCorrectTestName)
    assert(infoReportHadCorrectSpecText)
    assert(infoReportHadCorrectFormattedSpecText)
  }

  test("Nested-one-level plain-old specifiers should yield good strings in a testSucceeded report") {
    var infoReportHadCorrectTestName = false
    var infoReportHadCorrectSpecText = false
    var infoReportHadCorrectFormattedSpecText = false
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    var infoProvidedHasBeenInvoked = false
    var theOtherMethodHasBeenInvoked = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case InfoProvided(ordinal, message, nameInfo, aboutAPendingTest, throwable, formatter, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the other method
            assert(!theOtherMethodHasBeenInvoked)
            infoProvidedHasBeenInvoked = true
            if (message.indexOf("My Spec") != -1)
              infoReportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "My Spec")
                  infoReportHadCorrectSpecText = true
                if (formattedText == "My Spec")
                  infoReportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the this method
            assert(infoProvidedHasBeenInvoked)
            theOtherMethodHasBeenInvoked = true
            if (testName.indexOf("My Spec must start with proper words") != -1)
              reportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      describe("My Spec") {
        it("must start with proper words") {}
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
    assert(infoReportHadCorrectTestName)
    assert(infoReportHadCorrectSpecText)
    assert(infoReportHadCorrectFormattedSpecText)
  }

  test("Nested-one-level plain-old specifiers should yield good strings in a TestFailed report") {
    var infoReportHadCorrectTestName = false
    var infoReportHadCorrectSpecText = false
    var infoReportHadCorrectFormattedSpecText = false
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    var infoProvidedHasBeenInvoked = false
    var theOtherMethodHasBeenInvoked = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case InfoProvided(ordinal, message, nameInfo, aboutAPendingTest, throwable, formatter, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the other method
            assert(!theOtherMethodHasBeenInvoked)
            infoProvidedHasBeenInvoked = true
            if (message.indexOf("My Spec") != -1)
              infoReportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "My Spec")
                  infoReportHadCorrectSpecText = true
                if (formattedText == "My Spec")
                  infoReportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case event: TestFailed =>
            // infoProvided should be invoked before the this method
            assert(infoProvidedHasBeenInvoked)
            theOtherMethodHasBeenInvoked = true
            if (event.testName.indexOf("My Spec must start with proper words") != -1)
              reportHadCorrectTestName = true
            event.formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      describe("My Spec") {
        it("must start with proper words") { fail() }
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
    assert(infoReportHadCorrectTestName)
    assert(infoReportHadCorrectSpecText)
    assert(infoReportHadCorrectFormattedSpecText)
  }

  // Tests for good strings in report for nested-two-levels examples
  test("Nested-two-levels plain-old specifiers should yield good strings in a TestSucceeded report") {
    var infoReportHadCorrectTestName = false
    var infoReportHadCorrectSpecText = false
    var infoReportHadCorrectFormattedSpecText = false
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    var infoProvidedHasBeenInvoked = false
    var theOtherMethodHasBeenInvoked = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case InfoProvided(ordinal, message, nameInfo, aboutAPendingTest, throwable, formatter, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the other method
            assert(!theOtherMethodHasBeenInvoked)
            infoProvidedHasBeenInvoked = true
            if (message.indexOf("My Spec") != -1)
              infoReportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "My Spec")
                  infoReportHadCorrectSpecText = true
                if (formattedText == "My Spec")
                  infoReportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the this method
            assert(infoProvidedHasBeenInvoked)
            theOtherMethodHasBeenInvoked = true
            if (testName.indexOf("My Spec must start with proper words") != -1)
              reportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      describe("My") {
        describe("Spec") {
          it("must start with proper words") {}
        }
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
    assert(infoReportHadCorrectTestName)
    assert(infoReportHadCorrectSpecText)
    assert(infoReportHadCorrectFormattedSpecText)
  }

  test("Nested-two-levels plain-old specifiers should yield good strings in a testSucceeded report") {
    var infoReportHadCorrectTestName = false
    var infoReportHadCorrectSpecText = false
    var infoReportHadCorrectFormattedSpecText = false
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    var infoProvidedHasBeenInvoked = false
    var theOtherMethodHasBeenInvoked = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case InfoProvided(ordinal, message, nameInfo, aboutAPendingTest, throwable, formatter, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the other method
            assert(!theOtherMethodHasBeenInvoked)
            infoProvidedHasBeenInvoked = true
            if (message.indexOf("My Spec") != -1)
              infoReportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "My Spec")
                  infoReportHadCorrectSpecText = true
                if (formattedText == "My Spec")
                  infoReportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the this method
            assert(infoProvidedHasBeenInvoked)
            theOtherMethodHasBeenInvoked = true
            if (testName.indexOf("My Spec must start with proper words") != -1)
              reportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      describe("My") {
        describe("Spec") {
          it("must start with proper words") {}
        }
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
    assert(infoReportHadCorrectTestName)
    assert(infoReportHadCorrectSpecText)
    assert(infoReportHadCorrectFormattedSpecText)
  }

  test("Nested-two-levels plain-old specifiers should yield good strings in a TestFailed report") {
    var infoReportHadCorrectTestName = false
    var infoReportHadCorrectSpecText = false
    var infoReportHadCorrectFormattedSpecText = false
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    var infoProvidedHasBeenInvoked = false
    var theOtherMethodHasBeenInvoked = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case InfoProvided(ordinal, message, nameInfo, aboutAPendingTest, throwable, formatter, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the other method
            assert(!theOtherMethodHasBeenInvoked)
            infoProvidedHasBeenInvoked = true
            if (message.indexOf("My Spec") != -1)
              infoReportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "My Spec")
                  infoReportHadCorrectSpecText = true
                if (formattedText == "My Spec")
                  infoReportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case event: TestFailed =>
            // infoProvided should be invoked before the this method
            assert(infoProvidedHasBeenInvoked)
            theOtherMethodHasBeenInvoked = true
            if (event.testName.indexOf("My Spec must start with proper words") != -1)
              reportHadCorrectTestName = true
            event.formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      describe("My") {
        describe("Spec") {
          it("must start with proper words") { fail() }
        }
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
    assert(infoReportHadCorrectTestName)
    assert(infoReportHadCorrectSpecText)
    assert(infoReportHadCorrectFormattedSpecText)
  }

  // Test for good strings in report for top-level shared behavior examples
  test("Top-level 'shared behavior - fancy specifiers' should yield good strings in a TestSucceeded report") {
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            if (testName.indexOf("it should start with proper words") != -1)
              reportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "it should start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- it should start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec {
      def myBehavior(i: Int) {
        it("it should start with proper words") {}
      }
      it should behave like myBehavior(1)
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
  }

  test("Top-level 'shared behavior - plain-old specifiers' should yield good strings in a TestSucceeded report") {
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            if (testName.indexOf("must start with proper words") != -1)
              reportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec {
      def myBehavior(i: Int) {
        it("must start with proper words") {}
      }
      it should behave like myBehavior(1)
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
  }

  test("Top-level 'shared behavior - plain-old specifiers' should yield good strings in a testSucceeded report") {
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            if (testName.indexOf("must start with proper words") != -1)
              reportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec {
      def myBehavior(i: Int) {
        it("must start with proper words") {}
      }
      it should behave like myBehavior(1)
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
  }

  test("Top-level 'shared behavior - plain-old specifiers' should yield good strings in a TestFailed report") {
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case event: TestFailed =>
            if (event.testName.indexOf("must start with proper words") != -1)
              reportHadCorrectTestName = true
            event.formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "must start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- must start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec {
      def myBehavior(i: Int) {
        it("must start with proper words") { fail() }
      }
      it should behave like myBehavior(1)
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
  }

  // Tests for good strings in report for shared-behavior, nested-one-level specifiers
  test("Nested-one-level 'shared behavior' should yield good strings in a TestSucceeded report") {
    var infoReportHadCorrectTestName = false
    var infoReportHadCorrectSpecText = false
    var infoReportHadCorrectFormattedSpecText = false
    var reportHadCorrectTestName = false
    var reportHadCorrectSpecText = false
    var reportHadCorrectFormattedSpecText = false
    var infoProvidedHasBeenInvoked = false
    var theOtherMethodHasBeenInvoked = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case InfoProvided(ordinal, message, nameInfo, aboutAPendingTest, throwable, formatter, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the other method
            assert(!theOtherMethodHasBeenInvoked)
            infoProvidedHasBeenInvoked = true
            if (message.indexOf("My Spec") != -1)
              infoReportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "My Spec")
                  infoReportHadCorrectSpecText = true
                if (formattedText == "My Spec")
                  infoReportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            // infoProvided should be invoked before the this method
            assert(infoProvidedHasBeenInvoked)
            theOtherMethodHasBeenInvoked = true
            if (testName.indexOf("My Spec should start with proper words") != -1)
              reportHadCorrectTestName = true
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "should start with proper words")
                  reportHadCorrectSpecText = true
                if (formattedText == "- should start with proper words")
                  reportHadCorrectFormattedSpecText = true
              case _ =>
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec {
      def myBehavior(i: Int) {
        it("should start with proper words") {}
      }
      describe("My Spec") {
        it should behave like myBehavior(1)
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(reportHadCorrectTestName)
    assert(reportHadCorrectSpecText)
    assert(reportHadCorrectFormattedSpecText)
    assert(infoReportHadCorrectTestName)
    assert(infoReportHadCorrectSpecText)
    assert(infoReportHadCorrectFormattedSpecText)
  }

  // Huh? what was I testing here?
  test("An empty describe shouldn't throw an exception") {
    class MySpec extends Spec with ShouldMatchers {
      describe("this will be empty") {}
    }
    val a = new MySpec
    a.execute()
  }

  test("Only a passed test name should be invoked.") {
    var correctTestWasInvoked = false
    var wrongTestWasInvoked = false
    class MySpec extends Spec with ShouldMatchers {
      it("it should be invoked") {
        correctTestWasInvoked = true
      }
      it("it should not be invoked") {
        wrongTestWasInvoked = true
      }
    }
    val a = new MySpec
    a.run(Some("it should be invoked"), StubReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(correctTestWasInvoked)
    assert(!wrongTestWasInvoked)
  }

  test("Config map should make it through to runTest") {
    var foundMyGoodie = false
    class MySpec extends Spec with ShouldMatchers {
      override def runTest(testName: String, reporter: Reporter, stopper: Stopper, config: Map[String, Any], tracker: Tracker) {
        foundMyGoodie = config.contains("my goodie")
        super.runTest(testName, reporter, stopper, config, tracker)
      }
      it("it should find my goodie") {}
    }
    val a = new MySpec
    a.run(None, StubReporter, new Stopper {}, Filter(), Map("my goodie" -> "hi"), None, new Tracker)
    assert(foundMyGoodie)
  }

  // I think delete this one. Repeat.
  test("In a TestSucceeded report, the example name should start with '<description> should' if nested two levels inside describe clauses") {
    var testSucceededReportHadCorrectTestName = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            if (testName.indexOf("A Stack (when working right) should push and pop properly") != -1) {
              testSucceededReportHadCorrectTestName = true
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      describe("A Stack") {
        describe("(when working right)") {
          it("should push and pop properly") {}
        }
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(testSucceededReportHadCorrectTestName)
  }

  test("expectedTestCount is the number of plain-old specifiers if no shares") {
    class MySpec extends Spec with ShouldMatchers {
      it("must one") {}
      it("must two") {}
      describe("behavior") {
        it("must three") {}
        it("must four") {}
      }
      it("must five") {}
    }
    val a = new MySpec
    assert(a.expectedTestCount(Filter()) === 5)
  }

  // Testing strings sent in reports
  test("In a TestSucceeded report, the example name should be verbatim if top level if example registered with it") {
    var testSucceededReportHadCorrectTestName = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            if (testName.indexOf("this thing must start with proper words") != -1) {
              testSucceededReportHadCorrectTestName = true
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      it("this thing must start with proper words") {}
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(testSucceededReportHadCorrectTestName)
  }

  test("In a testSucceeded report, the example name should be verbatim if top level if example registered with it") {
    var testSucceededReportHadCorrectTestName = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            if (testName.indexOf("this thing must start with proper words") != -1) {
              testSucceededReportHadCorrectTestName = true
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      it("this thing must start with proper words") {}
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(testSucceededReportHadCorrectTestName)
  }

  test("In a TestFailed report, the example name should be verbatim if top level if example registered with it") {
    var testFailedReportHadCorrectTestName = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case event: TestFailed =>
            if (event.testName.indexOf("this thing must start with proper words") != -1)
              testFailedReportHadCorrectTestName = true
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      it("this thing must start with proper words") { fail() }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(testFailedReportHadCorrectTestName)
  }

  test("In a TestStarting report, the example name should start with '<description> ' if nested one level " +
        "inside a describe clause and registered with it") {
    var testSucceededReportHadCorrectTestName = false
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestStarting(_, _, _, testName, _, _, _, _, _) =>
            if (testName == "A Stack needs to push and pop properly") {
              testSucceededReportHadCorrectTestName = true
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      describe("A Stack") {
        it("needs to push and pop properly") {}
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(testSucceededReportHadCorrectTestName)
  }

  test("Specs should send defined formatters") {
    class MyReporter extends Reporter {

      var gotAnUndefinedFormatter = false
      var lastEventWithUndefinedFormatter: Option[Event] = None

      private def ensureFormatterIsDefined(event: Event) {
        if (!event.formatter.isDefined) {
          gotAnUndefinedFormatter = true
          lastEventWithUndefinedFormatter = Some(event)
        }
      }

      def apply(event: Event) {
        event match {
          case event: RunAborted => ensureFormatterIsDefined(event)
          case event: SuiteAborted => ensureFormatterIsDefined(event)
          case event: SuiteStarting => ensureFormatterIsDefined(event)
          case event: SuiteCompleted => ensureFormatterIsDefined(event)
          case event: TestStarting => ensureFormatterIsDefined(event)
          case event: TestSucceeded => ensureFormatterIsDefined(event)
          case event: TestIgnored => ensureFormatterIsDefined(event)
          case event: TestFailed => ensureFormatterIsDefined(event)
          case event: InfoProvided => ensureFormatterIsDefined(event)
          case _ =>
        }
      }
    }

    class MySpec extends Spec with ShouldMatchers {
      it("it should send defined formatters") {
        assert(true)
      }
      it("it should also send defined formatters") {
        assert(false)
      }
    }
    val a = new MySpec
    val myRep = new MyReporter
    a.run(None, myRep, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(!myRep.gotAnUndefinedFormatter, myRep.lastEventWithUndefinedFormatter.toString)
  }

  test("SpecText should come through correctly in a SpecReport when registering with it") {
    var testSucceededReportHadCorrectSpecText = false
    var lastSpecText: Option[String] = None
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "My spec text must have the proper words")
                  testSucceededReportHadCorrectSpecText = true
                else
                  lastSpecText = Some(rawText)
              case _ => throw new RuntimeException("Got a non-SpecReport")
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      it("My spec text must have the proper words") {}
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(testSucceededReportHadCorrectSpecText, lastSpecText match { case Some(s) => s; case None => "No report"})
  }

  test("Spec text should come through correctly in a SpecReport when registering with it when nested in one describe") {
    var testSucceededReportHadCorrectSpecText = false
    var lastSpecText: Option[String] = None
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "My short name must have the proper words")
                  testSucceededReportHadCorrectSpecText = true
                else
                  lastSpecText = Some(rawText)
              case _ => throw new RuntimeException("Got a non-SpecReport")
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      describe("A Stack") {
        it("My short name must have the proper words") {}
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(testSucceededReportHadCorrectSpecText, lastSpecText match { case Some(s) => s; case None => "No report"})
  }

  test("Spec text should come through correctly in a SpecReport when registering with it when nested in two describes") {
    var testSucceededReportHadCorrectSpecText = false
    var lastSpecText: Option[String] = None
    class MyReporter extends Reporter {
      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                if (rawText == "My short name must have the proper words")
                  testSucceededReportHadCorrectSpecText = true
                else
                  lastSpecText = Some(rawText)
              case _ => throw new RuntimeException("Got a non-SpecReport")
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with ShouldMatchers {
      describe("A Stack") {
        describe("(when empty)") {
          it("My short name must have the proper words") {}
        }
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(testSucceededReportHadCorrectSpecText, lastSpecText match { case Some(s) => s; case None => "No report"})
  }

  test("Should get infoProvided with description if one and only one describe clause") {

    val expectedSpecText = "A Stack"

    class MyReporter extends Reporter {
      var infoProvidedCalled = false
      var expectedMessageReceived = false
      def apply(event: Event) {
        event match {
          case event: InfoProvided =>
            event.formatter match {
              case Some(IndentedText(formattedText, rawText, indentationLevel)) =>
                infoProvidedCalled = true
                if (!expectedMessageReceived) {
                  expectedMessageReceived = (rawText == expectedSpecText)
                }
              case _ =>
            }
          case _ =>
        }
      }
    }

    class MySpec extends Spec with ShouldMatchers {
      describe("A Stack") {
        it("should allow me to push") {}
      }
    }

    val a = new MySpec
    val myRep = new MyReporter
    a.run(None, myRep, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(myRep.infoProvidedCalled)
    assert(myRep.expectedMessageReceived)
  }

  // Testing Shared behaviors
  test("a shared specifier invoked with 'should behave like a' should get invoked") {
    class MySpec extends Spec with BeforeAndAfter {
      var sharedExampleInvoked = false
      def invocationVerifier(i: Int) {
        it("should be invoked") {
          sharedExampleInvoked = true
        }
      }
      describe("A Stack") {
        describe("(when not empty)") {
          it("should allow me to pop") {}
          it should behave like invocationVerifier(1)
        }
        describe("(when not full)") {
          it("should allow me to push") {}
        }
      }
    }
    val a = new MySpec
    a.execute()
    assert(a.sharedExampleInvoked)
  }

  test("two examples in a shared behavior should get invoked") {
    class MySpec extends Spec with BeforeAndAfter {
      var sharedExampleInvoked = false
      var sharedExampleAlsoInvoked = false
      def invocationVerifier(i: Int) {
        it("should be invoked") {
          sharedExampleInvoked = true
        }
        it("should also be invoked") {
          sharedExampleAlsoInvoked = true
        }
      }
      describe("A Stack") {
        describe("(when not empty)") {
          it("should allow me to pop") {}
          it should behave like invocationVerifier(1)
        }
        describe("(when not full)") {
          it("should allow me to push") {}
        }
      }
    }
    val a = new MySpec
    a.execute()
    assert(a.sharedExampleInvoked)
    assert(a.sharedExampleAlsoInvoked)
  }

  test("three examples in a shared behavior should be invoked in order") {
    class MySpec extends Spec {
      var example1WasInvoked = false
      var example2WasInvokedAfterExample1 = false
      var example3WasInvokedAfterExample2 = false
      def invocationVerifier(i: Int) {
        it("should get invoked") {
          example1WasInvoked = true
        }
        it("should also get invoked") {
          if (example1WasInvoked)
            example2WasInvokedAfterExample1 = true
        }
        it("should also also get invoked") {
          if (example2WasInvokedAfterExample1)
            example3WasInvokedAfterExample2 = true
        }
      }
      it should behave like invocationVerifier(1)
    }
    val a = new MySpec
    a.execute()
    assert(a.example1WasInvoked)
    assert(a.example2WasInvokedAfterExample1)
    assert(a.example3WasInvokedAfterExample2)
  }

  test("three examples in a shared behavior should not get invoked at all if the behavior isn't used in a like clause") {
    class MySpec extends Spec with ShouldMatchers {
      var example1WasInvoked = false
      var example2WasInvokedAfterExample1 = false
      var example3WasInvokedAfterExample2 = false
      def invocationVerifier(i: Int) {
        it("should get invoked") {
          example1WasInvoked = true
        }
        it("should also get invoked") {
          if (example1WasInvoked)
            example2WasInvokedAfterExample1 = true
        }
        it("should also also get invoked") {
          if (example2WasInvokedAfterExample1)
            example3WasInvokedAfterExample2 = true
        }
      }
      // don't use it: behaves like (an InvocationVerifier())
    }
    val a = new MySpec
    a.execute()
    assert(!a.example1WasInvoked)
    assert(!a.example2WasInvokedAfterExample1)
    assert(!a.example3WasInvokedAfterExample2)
  }

  // Probably delete
  test("The test name for a shared specifier invoked with 'should behave like a' should be verbatim if top level") {
    var testSucceededReportHadCorrectTestName = false
    class MyReporter extends Reporter {

      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            if (testName.indexOf("it should be invoked") != -1) {
              testSucceededReportHadCorrectTestName = true
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec with BeforeAndAfter {
      var sharedExampleInvoked = false
      def invocationVerifier(i: Int) {
        it("it should be invoked") {
          sharedExampleInvoked = true
        }
      }
      it should behave like invocationVerifier(1)
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(testSucceededReportHadCorrectTestName)
  }

  ignore("The example name for a shared example invoked with 'it should behave like' should start with '<description> should' if nested one level in a describe clause") {
    var testSucceededReportHadCorrectTestName = false
    class MyReporter extends Reporter {

      def apply(event: Event) {
        event match {
          case TestSucceeded(ordinal, suiteName, suiteClassName, testName, duration, formatter, rerunnable, payload, threadName, timeStamp) =>
            if (testName.indexOf("A Stack should pop properly") != -1) {
              testSucceededReportHadCorrectTestName = true
            }
          case _ =>
        }
      }
    }
    class MySpec extends Spec {
      var sharedExampleInvoked = false
      def invocationVerifier(i: Int) {
        it("should pop properly") {
          sharedExampleInvoked = true
        }
      }
      describe("A Stack") {
        it should behave like invocationVerifier(1)
      }
    }
    val a = new MySpec
    a.run(None, new MyReporter, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(testSucceededReportHadCorrectTestName)
  }

  test("expectedTestCount should not include tests in shares if never called") {
    class MySpec extends Spec with ShouldMatchers {
      class Misbehavior extends Spec with ShouldMatchers {
        it("should six") {}
        it("should seven") {}
      }
      it("should one") {}
      it("should two") {}
      describe("behavior") {
        it("should three") {}
        it("should four") {}
      }
      it("should five") {}
    }
    val a = new MySpec
    assert(a.expectedTestCount(Filter()) === 5)
  }

  test("expectedTestCount should include tests in a share that is called") {
    class MySpec extends Spec {
      def misbehavior(i: Int) {
        it("should six") {}
        it("should seven") {}
      }
      it("should one") {}
      it("should two") {}
      describe("behavior") {
        it("should three") {}
        it should behave like misbehavior(1)
        it("should four") {}
      }
      it("should five") {}
    }
    val a = new MySpec
    assert(a.expectedTestCount(Filter()) === 7)
  }

  test("expectedTestCount should include tests in a share that is called twice") {
    class MySpec extends Spec {
      def misbehavior(i: Int) {
        it("should six") {}
        it("should seven") {}
      }
      it("should one") {}
      it("should two") {}
      describe("behavior") {
        it("should three") {}
        it should behave like misbehavior(1)
        it("should four") {}
      }
      it("should five") {}
      it should behave like misbehavior(1)
    }
    val a = new MySpec
    assert(a.expectedTestCount(Filter()) === 9)
  }

  test("Spec's expectedTestCount includes tests in nested suites") {
    class TwoTestSpec extends Spec {
      it("should count this test") {}
      it("should count this test also") {}
    }
    class MySpec extends Spec {

      override def nestedSuites = List(new TwoTestSpec, new TwoTestSpec, new TwoTestSpec)

      it("should count this here test") {}
    }
    val mySpec = new MySpec
    assert(mySpec.expectedTestCount(Filter()) === 7)
  }

  // End of Share stuff
  ignore("should be able to send info to the reporter") { // Can't do this yet, no info in Spec yet

    val expectedMessage = "this is the expected message"

    class MyReporter extends Reporter {
      var infoProvidedCalled = false
      var expectedMessageReceived = false

      def apply(event: Event) {
        event match {
          case event: InfoProvided =>
            infoProvidedCalled = true
            if (!expectedMessageReceived) {
              expectedMessageReceived = event.message.indexOf(expectedMessage) != -1
            }
          case _ =>
        }
      }
    }

    class MySpec extends Spec with ShouldMatchers {
      describe("A Stack") {
        describe("(when not empty)") {
          it("should allow me to pop") {
            info(expectedMessage)
            ()
          }
        }
        describe("(when not full)") {
          it("should allow me to push") {}
        }
      }
    }
    val a = new MySpec
    val myRep = new MyReporter
    a.run(None, myRep, new Stopper {}, Filter(), Map(), None, new Tracker)
    assert(myRep.infoProvidedCalled)
    assert(myRep.expectedMessageReceived)
  }

  test("that a null specText results in a thrown NPE at construction time") {
    intercept[NullPointerException] {
      new Spec {
        it(null) {}
      }
    }
    intercept[NullPointerException] {
      new Spec {
        ignore(null) {}
      }
    }
  }

  test("test durations are included in TestFailed and TestSucceeded events fired from Spec") {

    class MySpec extends Spec {
      it("should succeed") {}
      it("should fail") { fail() }
    }

    val mySpec = new MySpec
    val myReporter = new TestDurationReporter
    mySpec.run(None, myReporter, new Stopper {}, Filter(), Map(), None, new Tracker(new Ordinal(99)))
    assert(myReporter.testSucceededWasFiredAndHadADuration)
    assert(myReporter.testFailedWasFiredAndHadADuration)
  }

  test("suite durations are included in SuiteCompleted events fired from Spec") {

    class MySpec extends Spec {
      override def nestedSuites = List(new Suite {})
    }

    val mySuite = new MySpec
    val myReporter = new SuiteDurationReporter
    mySuite.run(None, myReporter, new Stopper {}, Filter(), Map(), None, new Tracker(new Ordinal(99)))
    assert(myReporter.suiteCompletedWasFiredAndHadADuration)
  }

  test("suite durations are included in SuiteAborted events fired from Spec") {

    class SuiteThatAborts extends Suite {
      override def run(testName: Option[String], reporter: Reporter, stopper: Stopper, filter: Filter,
              config: Map[String, Any], distributor: Option[Distributor], tracker: Tracker) {
        throw new RuntimeException("Aborting for testing purposes")
      }
    }

    class MySpec extends Spec {
      override def nestedSuites = List(new SuiteThatAborts {})
    }

    val mySuite = new MySpec
    val myReporter = new SuiteDurationReporter
    mySuite.run(None, myReporter, new Stopper {}, Filter(), Map(), None, new Tracker(new Ordinal(99)))
    assert(myReporter.suiteAbortedWasFiredAndHadADuration)
  }

  test("pending in a Spec should cause TestPending to be fired") {

    class MySpec extends Spec {
      it("should be pending") (pending)
    }

    val mySuite = new MySpec
    val myReporter = new PendingReporter
    mySuite.run(None, myReporter, new Stopper {}, Filter(), Map(), None, new Tracker(new Ordinal(99)))
    assert(myReporter.testPendingWasFired)
  }
}


text:
<?php

namespace Puli\Discovery\Tests;

use Puli\Discovery\Binding\BindingType;
use Puli\Discovery\Binding\EagerBinding;
use Puli\Discovery\Binding\ResourceBindingInterface;
use Puli\Discovery\ResourceDiscoveryInterface;
use Puli\Repository\Resource\Collection\ResourceCollection;
use Puli\Repository\Tests\Resource\TestFile;

/**
 * @since  1.0
 * @author Bernhard Schussek <bschussek@gmail.com>
 */
abstract class AbstractResourceDiscoveryTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @param ResourceBindingInterface[] $bindings
     *
     * @return ResourceDiscoveryInterface
     */
    abstract protected function createDiscovery(array $bindings = array());

    public function testFind()
    {
        $type1 = new BindingType('type1');
        $type2 = new BindingType('type2');

        $resource1 = new TestFile('/file1');
        $resource2 = new TestFile('/file2');

        $discovery = $this->createDiscovery(array(
            $binding1 = new EagerBinding('/file1', $resource1, $type1),
            $binding2 = new EagerBinding('/file2', $resource2, $type1),
            $binding3 = new EagerBinding('/file2', $resource2, $type2),
        ));

        $this->assertBindingsEqual(array($binding1, $binding2), $discovery->find('type1'));
        $this->assertBindingsEqual(array($binding3), $discovery->find('type2'));
    }

    public function testFindIgnoresUnknownType()
    {
        $discovery = $this->createDiscovery();

        $this->assertSame(array(), $discovery->find('foo'));
    }

    public function testGetBindings()
    {
        $type1 = new BindingType('type1');
        $type2 = new BindingType('type2');

        $resource1 = new TestFile('/file1');
        $resource2 = new TestFile('/data/file2');
        $resource3 = new TestFile('/data/file3');

        $coll = new ResourceCollection(array($resource2, $resource3));

        $discovery = $this->createDiscovery(array(
            $binding1 = new EagerBinding('/file1', $resource1, $type1),
            $binding2 = new EagerBinding('/data/file2', $resource2, $type1),
            $binding3 = new EagerBinding('/data/*', $coll, $type2),
        ));

        $this->assertBindingsEqual(array($binding1, $binding2, $binding3), $discovery->getBindings());
        $this->assertBindingsEqual(array($binding2, $binding3), $discovery->getBindings('/data/file2'));
        $this->assertBindingsEqual(array($binding3), $discovery->getBindings('/data/file2', 'type2'));
        $this->assertBindingsEqual(array($binding1, $binding2), $discovery->getBindings(null, 'type1'));
    }

    public function testGetNoBindings()
    {
        $discovery = $this->createDiscovery();

        $this->assertSame(array(), $discovery->getBindings());
    }

    public function testGetNoBindingsIgnoresUnknownPath()
    {
        $discovery = $this->createDiscovery();

        $this->assertSame(array(), $discovery->getBindings('foo'));
    }

    public function testGetNoBindingsIgnoresUnknownType()
    {
        $discovery = $this->createDiscovery();

        $this->assertSame(array(), $discovery->getBindings(null, 'foo'));
    }

    public function testGetType()
    {
        $type1 = new BindingType('type1');
        $type2 = new BindingType('type2');

        $resource1 = new TestFile('/file1');
        $resource2 = new TestFile('/file2');

        $discovery = $this->createDiscovery(array(
            $binding1 = new EagerBinding('/file1', $resource1, $type1),
            $binding3 = new EagerBinding('/file2', $resource2, $type2),
        ));

        $this->assertEquals($type1, $discovery->getType('type1'));
        $this->assertEquals($type2, $discovery->getType('type2'));
    }

    public function testGetTypes()
    {
        $type1 = new BindingType('type1');
        $type2 = new BindingType('type2');

        $resource1 = new TestFile('/file1');
        $resource2 = new TestFile('/file2');

        $discovery = $this->createDiscovery(array(
            $binding1 = new EagerBinding('/file1', $resource1, $type1),
            $binding3 = new EagerBinding('/file2', $resource2, $type2),
        ));

        $this->assertEquals(array('type1' => $type1, 'type2' => $type2), $discovery->getTypes());
    }

    /**
     * @expectedException \Puli\Discovery\Binding\NoSuchTypeException
     * @expectedExceptionMessage foobar
     */
    public function testGetTypeFailsIfUnknownType()
    {
        $discovery = $this->createDiscovery();

        $discovery->getType('foobar');
    }

    public function testIsDefined()
    {
        $type = new BindingType('type');
        $resource = new TestFile('/file');

        $discovery = $this->createDiscovery(array(
            $binding1 = new EagerBinding('/file', $resource, $type),
        ));

        $this->assertTrue($discovery->isDefined('type'));
        $this->assertFalse($discovery->isDefined('foo'));
    }

    /**
     * @param ResourceBindingInterface[] $expected
     * @param mixed                      $actual
     */
    private function assertBindingsEqual(array $expected, $actual)
    {
        $this->assertInternalType('array', $actual);
        $this->assertCount(count($expected), $actual);

        foreach ($expected as $key => $expectedBinding) {
            $this->assertArrayHasKey($key, $actual);

            $actualBinding = $actual[$key];
            $this->assertSame($expectedBinding->getPath(), $actualBinding->getPath());
            $this->assertEquals($expectedBinding->getType(), $actualBinding->getType());
            $this->assertEquals($expectedBinding->getParameters(), $actualBinding->getParameters());
            $this->assertEquals($expectedBinding->getResource(), $actualBinding->getResource());
            $this->assertEquals($expectedBinding->getResources(), $actualBinding->getResources());
        }
    }
}


text:
{{ model.title }}

{{ model.description }}

    <md-icon class="icon">location_city</md-icon>

      {{ model.location }}

    <md-icon class="icon">person</md-icon>

      {{ (creatorModel | async)?.displayName }}

    VER DETALLES


text:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<TITLE>
net.sourceforge.pmd.stat Class Hierarchy (PMD 4.2.5 API)
</TITLE>

<META NAME="date" CONTENT="2009-02-08">

<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../../stylesheet.css" TITLE="Style">

      Overview
      Package
      Class
      Use
    Tree
      Deprecated
      Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes

Hierarchy For Package net.sourceforge.pmd.stat

Package Hierarchies:
All Packages

Class Hierarchy

java.lang.Object

net.sourceforge.pmd.CommonAbstractRule (implements net.sourceforge.pmd.Rule)

net.sourceforge.pmd.AbstractJavaRule (implements net.sourceforge.pmd.ast.JavaParserVisitor)

net.sourceforge.pmd.stat.StatisticalRule

net.sourceforge.pmd.stat.DataPoint (implements java.lang.Comparable<T>)

net.sourceforge.pmd.stat.Metric

      Overview
      Package
      Class
      Use
    Tree
      Deprecated
      Index
      Help

 PREV
 NEXT

  FRAMES
 NO FRAMES

  All Classes

Copyright © 2002-2009 InfoEther. All Rights Reserved.


text:
package refscheduler.game.builder;

import refscheduler.game.Game;
import refscheduler.team.Team;
import refscheduler.timeslot.Timeslot;
import refscheduler.tournament.Tournament;
import refscheduler.volunteer.Volunteer;

import java.util.List;

public class GameBuilder {

    private Long id;
    private Tournament tournament;
    private Timeslot timeslot;
    private Team teamA;
    private Team teamB;
    private Volunteer headReferee;
    private List<Volunteer> assistantReferees;
    private Volunteer snitchReferee;
    private Volunteer snitch;
    private Long pitch;

    private GameBuilder() {

    }

    public static GameBuilder newGame() {
        return new GameBuilder();
    }

    public GameBuilder withId(final Long id) {
        this.id = id;
        return this;
    }

    public GameBuilder withTournament(final Tournament tournament) {
        this.tournament = tournament;
        return this;
    }

    public GameBuilder withTimeslot(final Timeslot timeslot) {
        this.timeslot = timeslot;
        return this;
    }

    public GameBuilder withTeamA(final Team teamA) {
        this.teamA = teamA;
        return this;
    }

    public GameBuilder withTeamB(final Team teamB) {
        this.teamB = teamB;
        return this;
    }

    public GameBuilder withHeadReferee(final Volunteer headReferee) {
        this.headReferee = headReferee;
        return this;
    }

    public GameBuilder withAssistantReferees(final List<Volunteer> assistantReferees) {
        this.assistantReferees = assistantReferees;
        return this;
    }

    public GameBuilder withSnitchReferee(final Volunteer snitchReferee) {
        this.snitchReferee = snitchReferee;
        return this;
    }

    public GameBuilder withSnitch(final Volunteer snitch) {
        this.snitch = snitch;
        return this;
    }

    public GameBuilder withPitch(final Long pitch) {
        this.pitch = pitch;
        return this;
    }

    public Game build() {
        Game game = new Game();
        game.setId(id);
        game.setTournament(tournament);
        game.setTimeslot(timeslot);
        game.setTeamA(teamA);
        game.setTeamB(teamB);
        game.setHeadReferee(headReferee);
        game.setAssistantReferees(assistantReferees);
        game.setSnitchReferee(snitchReferee);
        game.setSnitch(snitch);
        game.setPitch(pitch);
        return game;
    }
}


text:
#ifndef ELEVATIONANALYSISMAP_H
#define ELEVATIONANALYSISMAP_H

#include "AnalysisMap.h"
#include "ElevationDataMap.h"

class ElevationAnalysisMap : public AnalysisMap
{

Q_OBJECT

protected:
    ElevationDataMap *_elevationMap;

public:
    explicit ElevationAnalysisMap(ElevationDataMap *elevationMap, QSettings *settings, QObject *parent = 0);
    virtual double calculateScoreForPixel(int x, int y);

signals:

public slots:

};

#endif // ELEVATIONANALYSISMAP_H


text:
import { Component } from "react";
import clsx from "clsx";

import PropTypes from "prop-types";

import SimpleButton from "components/Buttons/SimpleButton";
import WizardFooter from "./WizardFooter";
import * as classes from "@app/uiTheme/radium/replacingRadiumPseudoClasses.module.less";

class DefaultWizardFooter extends Component {
  static propTypes = {
    style: PropTypes.object,
    isPreviewAvailable: PropTypes.bool,
    submitting: PropTypes.bool,
    handleSubmit: PropTypes.func,
    onFormSubmit: PropTypes.func.isRequired,
    onCancel: PropTypes.func.isRequired,
  };

  static defaultProps = {
    isPreviewAvailable: true,
  };

  constructor(props) {
    super(props);
    this.state = {
      submitType: null,
    };
  }

  onCancel = (e) => {
    e.preventDefault();
    this.props.onCancel();
  };

  onButtonClick = (submitType, e, ...rest) => {
    if (e && e.preventDefault) {
      e.preventDefault();
    }
    this.setState({ submitType });
    const { handleSubmit, onFormSubmit } = this.props;
    if (onFormSubmit && handleSubmit) {
      return handleSubmit((values) => {
        return onFormSubmit(values, submitType);
      })(e, ...rest);
    }
    return onFormSubmit(submitType);
  };

  render() {
    const { submitting, isPreviewAvailable } = this.props;
    const submitType = submitting && this.state.submitType;

    return (
      <WizardFooter style={{ ...styles.wizardParent, ...this.props.style }}>
        <SimpleButton
          buttonStyle="primary"
          onClick={this.onButtonClick.bind(this, "apply")}
          submitting={submitType === "apply"}
          className={clsx(
            "wizard-apply-button",
            classes["primaryButtonPsuedoClasses"]
          )}
        >
          Apply
        </SimpleButton>
        {isPreviewAvailable && (
          <SimpleButton
            buttonStyle="secondary"
            onClick={this.onButtonClick.bind(this, "preview")}
            disabled={submitting && submitType !== "preview"}
            submitting={submitType === "preview"}
            className={clsx("wizard-preview-button", {
              [classes["secondaryButtonPsuedoClasses"]]:
                !submitting && submitType === "preview",
            })}
          >
            Preview
          </SimpleButton>
        )}
        <SimpleButton
          buttonStyle="secondary"
          className={clsx(classes["secondaryButtonPsuedoClasses"])}
          onClick={this.onCancel}
        >
          Cancel
        </SimpleButton>
      </WizardFooter>
    );
  }
}

const styles = {
  wizardParent: {
    width: "100%",
  },
};
export default DefaultWizardFooter;


text:
using device::BluetoothGattService;

namespace content {

namespace {

blink::mojom::WebBluetoothError TranslateGATTErrorAndRecord(
    BluetoothGattService::GattErrorCode error_code,
    UMAGATTOperation operation) {
  switch (error_code) {
    case BluetoothGattService::GATT_ERROR_UNKNOWN:
      RecordGATTOperationOutcome(operation, UMAGATTOperationOutcome::UNKNOWN);
      return blink::mojom::WebBluetoothError::GATT_UNKNOWN_ERROR;
    case BluetoothGattService::GATT_ERROR_FAILED:
      RecordGATTOperationOutcome(operation, UMAGATTOperationOutcome::FAILED);
      return blink::mojom::WebBluetoothError::GATT_UNKNOWN_FAILURE;
    case BluetoothGattService::GATT_ERROR_IN_PROGRESS:
      RecordGATTOperationOutcome(operation,
                                 UMAGATTOperationOutcome::IN_PROGRESS);
      return blink::mojom::WebBluetoothError::GATT_OPERATION_IN_PROGRESS;
    case BluetoothGattService::GATT_ERROR_INVALID_LENGTH:
      RecordGATTOperationOutcome(operation,
                                 UMAGATTOperationOutcome::INVALID_LENGTH);
      return blink::mojom::WebBluetoothError::GATT_INVALID_ATTRIBUTE_LENGTH;
    case BluetoothGattService::GATT_ERROR_NOT_PERMITTED:
      RecordGATTOperationOutcome(operation,
                                 UMAGATTOperationOutcome::NOT_PERMITTED);
      return blink::mojom::WebBluetoothError::GATT_NOT_PERMITTED;
    case BluetoothGattService::GATT_ERROR_NOT_AUTHORIZED:
      RecordGATTOperationOutcome(operation,
                                 UMAGATTOperationOutcome::NOT_AUTHORIZED);
      return blink::mojom::WebBluetoothError::GATT_NOT_AUTHORIZED;
    case BluetoothGattService::GATT_ERROR_NOT_PAIRED:
      RecordGATTOperationOutcome(operation,
                                 UMAGATTOperationOutcome::NOT_PAIRED);
      return blink::mojom::WebBluetoothError::GATT_NOT_PAIRED;
    case BluetoothGattService::GATT_ERROR_NOT_SUPPORTED:
      RecordGATTOperationOutcome(operation,
                                 UMAGATTOperationOutcome::NOT_SUPPORTED);
      return blink::mojom::WebBluetoothError::GATT_NOT_SUPPORTED;
  }
  NOTREACHED();
  return blink::mojom::WebBluetoothError::GATT_UNTRANSLATED_ERROR_CODE;
}

}  // namespace

using CacheQueryResult = BluetoothDispatcherHost::CacheQueryResult;

WebBluetoothServiceImpl::WebBluetoothServiceImpl(
    RenderFrameHost* render_frame_host,
    blink::mojom::WebBluetoothServiceRequest request)
    : render_frame_host_(render_frame_host),
      binding_(this, std::move(request)),
      weak_ptr_factory_(this) {
  DCHECK_CURRENTLY_ON(BrowserThread::UI);
}

WebBluetoothServiceImpl::~WebBluetoothServiceImpl() {}

void WebBluetoothServiceImpl::RemoteCharacteristicWriteValue(
    const mojo::String& characteristic_instance_id,
    mojo::Array<uint8_t> value,
    const RemoteCharacteristicWriteValueCallback& callback) {
  DCHECK_CURRENTLY_ON(BrowserThread::UI);
  RecordWebBluetoothFunctionCall(
      UMAWebBluetoothFunction::CHARACTERISTIC_WRITE_VALUE);

  // We perform the length check on the renderer side. So if we
  // get a value with length > 512, we can assume it's a hostile
  // renderer and kill it.
  if (value.size() > 512) {
    CrashRendererAndClosePipe(bad_message::BDH_INVALID_WRITE_VALUE_LENGTH);
    return;
  }

  const CacheQueryResult query_result =
      GetBluetoothDispatcherHost()->QueryCacheForCharacteristic(
          GetOrigin(), characteristic_instance_id);

  if (query_result.outcome == CacheQueryOutcome::BAD_RENDERER) {
    binding_.Close();
    return;
  }

  if (query_result.outcome != CacheQueryOutcome::SUCCESS) {
    RecordCharacteristicWriteValueOutcome(query_result.outcome);
    callback.Run(query_result.GetWebError());
    return;
  }

  if (BluetoothBlacklist::Get().IsExcludedFromWrites(
          query_result.characteristic->GetUUID())) {
    RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome::BLACKLISTED);
    callback.Run(blink::mojom::WebBluetoothError::BLACKLISTED_WRITE);
    return;
  }

  query_result.characteristic->WriteRemoteCharacteristic(
      value.To<std::vector<uint8_t>>(),
      base::Bind(&WebBluetoothServiceImpl::OnWriteValueSuccess,
                 weak_ptr_factory_.GetWeakPtr(), callback),
      base::Bind(&WebBluetoothServiceImpl::OnWriteValueFailed,
                 weak_ptr_factory_.GetWeakPtr(), callback));
}

void WebBluetoothServiceImpl::OnWriteValueSuccess(
    const RemoteCharacteristicWriteValueCallback& callback) {
  DCHECK_CURRENTLY_ON(BrowserThread::UI);
  RecordCharacteristicWriteValueOutcome(UMAGATTOperationOutcome::SUCCESS);
  callback.Run(blink::mojom::WebBluetoothError::SUCCESS);
}

void WebBluetoothServiceImpl::OnWriteValueFailed(
    const RemoteCharacteristicWriteValueCallback& callback,
    device::BluetoothGattService::GattErrorCode error_code) {
  DCHECK_CURRENTLY_ON(BrowserThread::UI);
  callback.Run(TranslateGATTErrorAndRecord(
      error_code, UMAGATTOperation::CHARACTERISTIC_WRITE));
}

RenderProcessHost* WebBluetoothServiceImpl::GetRenderProcessHost() {
  return render_frame_host_->GetProcess();
}

BluetoothDispatcherHost* WebBluetoothServiceImpl::GetBluetoothDispatcherHost() {
  RenderProcessHostImpl* render_process_host_impl =
      static_cast<RenderProcessHostImpl*>(GetRenderProcessHost());
  return render_process_host_impl->GetBluetoothDispatcherHost();
}

void WebBluetoothServiceImpl::CrashRendererAndClosePipe(
    bad_message::BadMessageReason reason) {
  bad_message::ReceivedBadMessage(GetRenderProcessHost(), reason);
  binding_.Close();
}

url::Origin WebBluetoothServiceImpl::GetOrigin() {
  return render_frame_host_->GetLastCommittedOrigin();
}

}  // namespace content


text:
#pragma once
#include <aws/lookoutmetrics/LookoutMetrics_EXPORTS.h>
#include <aws/core/utils/memory/stl/AWSString.h>
#include <utility>

namespace Aws
{
template<typename RESULT_TYPE>
class AmazonWebServiceResult;

namespace Utils
{
namespace Json
{
  class JsonValue;
} // namespace Json
} // namespace Utils
namespace LookoutMetrics
{
namespace Model
{
  class AWS_LOOKOUTMETRICS_API UpdateAlertResult
  {
  public:
    UpdateAlertResult();
    UpdateAlertResult(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);
    UpdateAlertResult& operator=(const Aws::AmazonWebServiceResult<Aws::Utils::Json::JsonValue>& result);

    /**
     *
The ARN of the updated alert.

     */
    inline const Aws::String& GetAlertArn() const{ return m_alertArn; }

    /**
     *
The ARN of the updated alert.

     */
    inline void SetAlertArn(const Aws::String& value) { m_alertArn = value; }

    /**
     *
The ARN of the updated alert.

     */
    inline void SetAlertArn(Aws::String&& value) { m_alertArn = std::move(value); }

    /**
     *
The ARN of the updated alert.

     */
    inline void SetAlertArn(const char* value) { m_alertArn.assign(value); }

    /**
     *
The ARN of the updated alert.

     */
    inline UpdateAlertResult& WithAlertArn(const Aws::String& value) { SetAlertArn(value); return *this;}

    /**
     *
The ARN of the updated alert.

     */
    inline UpdateAlertResult& WithAlertArn(Aws::String&& value) { SetAlertArn(std::move(value)); return *this;}

    /**
     *
The ARN of the updated alert.

     */
    inline UpdateAlertResult& WithAlertArn(const char* value) { SetAlertArn(value); return *this;}

  private:

    Aws::String m_alertArn;
  };

} // namespace Model
} // namespace LookoutMetrics
} // namespace Aws


text:
package com.rmn.testrail.parameters;

/**
 * The GetCasesFilter is used to generate filters specifically for the getTestCases methods.
 *
 * @author vliao
 */
public enum GetCasesFilter implements ApiFilter {
    //Request filters for get_cases
    CREATED_AFTER("created_after"),
    CREATED_BEFORE("created_before"),
    CREATED_BY("created_by"),
    MILESTONE_ID("milestone_id"),
    PRIORITY_ID("priority_id"),
    TEMPLATE_ID("template_id"),
    TYPE_ID("type_id"),
    UPDATED_AFTER("updated_after"),
    UPDATED_BEFORE("updated_before"),
    UPDATED_BY("updated_by");

    private String filter;
    GetCasesFilter(String filter) { this.filter = filter; }

    public String getFilter() {
        return filter;
    }
}


text:
<?php

namespace Doctrine\KeyValueStore\Id;

class NullIdConverter implements IdConverterStrategy
{
    public function serialize($class, $data)
    {
        return $data;
    }

    public function unserialize($class, $data)
    {
        return $data;
    }
}


text: bool writePointCloud(PointCloudPoint &pCloud);