text:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"

	android:orientation="vertical" android:layout_width="fill_parent"
	android:layout_height="fill_parent">
	<com.google.ads.AdView android:id="@+id/adView"
		android:layout_width="wrap_content" android:layout_height="wrap_content"
		ads:adUnitId="a14df8d1385d745" ads:adSize="BANNER" ads:loadAdOnCreate="false" />

	<TableRow android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:id="@+id/firstrow">
		<Button android:id="@+id/onebutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="1"
			android:layout_weight="1" />
		<Button android:id="@+id/twobutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="2"
			android:layout_weight="1" />
		<Button android:id="@+id/threebutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="3"
			android:layout_weight="1" />
	</TableRow>

		<TableRow android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:id="@+id/secondrow">
		<Button android:id="@+id/fourbutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="4"
			android:layout_weight="1" />
		<Button android:id="@+id/fivebutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="5"
			android:layout_weight="1" />
		<Button android:id="@+id/sixbutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="6"
			android:layout_weight="1" />
	</TableRow>

		<TableRow android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:id="@+id/thirdrow">
		<Button android:id="@+id/sevenbutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="7"
			android:layout_weight="1" />
		<Button android:id="@+id/eightbutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="8"
			android:layout_weight="1" />
		<Button android:id="@+id/ninebutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="9"
			android:layout_weight="1" />
	</TableRow>

		<TableRow android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:id="@+id/fourthrow">
		<Button android:id="@+id/starbutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="*"
			android:layout_weight="1" />
		<Button android:id="@+id/zerobutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="0"
			android:layout_weight="1" />
		<Button android:id="@+id/poundbutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="#"
			android:layout_weight="1" />
	</TableRow>

	<TableRow android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:id="@+id/frequencytable">
		<Button android:id="@+id/freqbutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="Play Frequency Hz"
			 />
		<EditText android:layout_width="fill_parent" android:id="@+id/freq"
			android:text="1200" android:numeric="decimal" android:layout_height="wrap_content"
			></EditText>
	</TableRow>

	<TableRow android:layout_width="fill_parent"
		android:layout_height="wrap_content" android:id="@+id/dialtable">
		<Button android:id="@+id/dialbutton" android:layout_height="wrap_content"
			android:layout_width="wrap_content" android:text="Dial Sequence"
			 />
		<EditText android:layout_width="fill_parent" android:id="@+id/dialnums"
			android:text="5552234433" android:phoneNumber="true" android:layout_height="wrap_content"
			></EditText>
	</TableRow>

</LinearLayout>


text:
package org.apache.jackrabbit.oak.plugins.document.secondary;

import com.google.common.collect.EvictingQueue;
import org.apache.jackrabbit.oak.plugins.document.AbstractDocumentNodeState;
import org.apache.jackrabbit.oak.plugins.document.DocumentNodeStateCache;
import org.apache.jackrabbit.oak.plugins.document.NodeStateDiffer;
import org.apache.jackrabbit.oak.plugins.document.Path;
import org.apache.jackrabbit.oak.plugins.document.RevisionVector;
import org.apache.jackrabbit.oak.spi.filter.PathFilter;
import org.apache.jackrabbit.oak.spi.state.NodeState;
import org.apache.jackrabbit.oak.spi.state.NodeStateUtils;
import org.apache.jackrabbit.oak.spi.state.NodeStore;
import org.apache.jackrabbit.oak.stats.MeterStats;
import org.apache.jackrabbit.oak.stats.StatisticsProvider;
import org.apache.jackrabbit.oak.stats.StatsOptions;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class SecondaryStoreCache implements DocumentNodeStateCache, SecondaryStoreRootObserver {
    private final Logger log = LoggerFactory.getLogger(getClass());
    private static final AbstractDocumentNodeState[] EMPTY = new AbstractDocumentNodeState[0];
    private final NodeStore store;
    private final PathFilter pathFilter;
    private final NodeStateDiffer differ;
    private final MeterStats unknownPaths;
    private final MeterStats knownMissed;
    private final MeterStats knownMissedOld;
    private final MeterStats knownMissedNew;
    private final MeterStats knownMissedInRange;
    private final MeterStats headRevMatched;
    private final MeterStats prevRevMatched;
    private final int maxSize = 10000;
    private final EvictingQueue<AbstractDocumentNodeState> queue;
    private volatile AbstractDocumentNodeState[] previousRoots = EMPTY;

    public SecondaryStoreCache(NodeStore nodeStore, NodeStateDiffer differ, PathFilter pathFilter,
                               StatisticsProvider statisticsProvider) {
        this.differ = differ;
        this.store = nodeStore;
        this.pathFilter = pathFilter;
        this.unknownPaths = statisticsProvider.getMeter("DOCUMENT_CACHE_SEC_UNKNOWN", StatsOptions.DEFAULT);
        this.knownMissed = statisticsProvider.getMeter("DOCUMENT_CACHE_SEC_KNOWN_MISSED", StatsOptions.DEFAULT);
        this.knownMissedOld = statisticsProvider.getMeter("DOCUMENT_CACHE_SEC_KNOWN_MISSED_OLD", StatsOptions.DEFAULT);
        this.knownMissedNew = statisticsProvider.getMeter("DOCUMENT_CACHE_SEC_KNOWN_MISSED_NEW", StatsOptions.DEFAULT);
        this.knownMissedInRange = statisticsProvider.getMeter("DOCUMENT_CACHE_SEC_KNOWN_MISSED_IN_RANGE", StatsOptions
                .DEFAULT);
        this.headRevMatched = statisticsProvider.getMeter("DOCUMENT_CACHE_SEC_HEAD", StatsOptions.DEFAULT);
        this.prevRevMatched = statisticsProvider.getMeter("DOCUMENT_CACHE_SEC_OLD", StatsOptions.DEFAULT);
        this.queue = EvictingQueue.create(maxSize);
    }

    @Nullable
    @Override
    public AbstractDocumentNodeState getDocumentNodeState(Path path, RevisionVector rootRevision,
                                                          RevisionVector lastRev) {
        //TODO We might need skip the calls if they occur due to SecondaryStoreObserver
        //doing the diff or in the startup when we try to sync the state
        String p = path.toString();
        PathFilter.Result result = pathFilter.filter(p);
        if (result != PathFilter.Result.INCLUDE) {
            unknownPaths.mark();
            return null;
        }

        if (!DelegatingDocumentNodeState.hasMetaProps(store.getRoot())){
            return null;
        }

        AbstractDocumentNodeState currentRoot = DelegatingDocumentNodeState.wrap(store.getRoot(), differ);

        //If the root rev is < lastRev then secondary store is lagging and would
        //not have the matching result
        if (lastRev.compareTo(currentRoot.getLastRevision()) > 0){
            return null;
        }

        AbstractDocumentNodeState nodeState = findByMatchingLastRev(currentRoot, path, lastRev);
        if (nodeState != null){
            headRevMatched.mark();
            return nodeState;
        }

        AbstractDocumentNodeState matchingRoot = findMatchingRoot(rootRevision);
        if (matchingRoot != null){
            NodeState state = NodeStateUtils.getNode(matchingRoot, p);
            if (state.exists()){
                AbstractDocumentNodeState docState = asDocState(state);
                prevRevMatched.mark();
                return docState;
            }
        }

        knownMissed.mark();
        return null;
    }

    @Override
    public boolean isCached(Path path) {
        return pathFilter.filter(path.toString()) == PathFilter.Result.INCLUDE;
    }

    @Nullable
    private AbstractDocumentNodeState findByMatchingLastRev(AbstractDocumentNodeState root, Path path,
                                                      RevisionVector lastRev){
        NodeState state = root;

        for (String name : path.elements()) {
            state = state.getChildNode(name);

            if (!state.exists()){
                return null;
            }

            //requested lastRev is > current node lastRev then no need to check further
            if (lastRev.compareTo(asDocState(state).getLastRevision()) > 0){
                return null;
            }
        }

        AbstractDocumentNodeState docState = asDocState(state);
        if (lastRev.equals(docState.getLastRevision())) {
            headRevMatched.mark();
            return docState;
        }

        return null;
    }

    @Nullable
    private AbstractDocumentNodeState findMatchingRoot(RevisionVector rr) {
        if (isEmpty()){
            return null;
        }

        //Use a local variable as the array can get changed in process
        AbstractDocumentNodeState[] roots = previousRoots;
        AbstractDocumentNodeState latest = roots[roots.length - 1];
        AbstractDocumentNodeState oldest = roots[0];

        if (rr.compareTo(latest.getRootRevision()) > 0){
            knownMissedNew.mark();
            return null;
        }

        if (rr.compareTo(oldest.getRootRevision()) < 0){
            knownMissedOld.mark();
            return null;
        }

        AbstractDocumentNodeState result = findMatchingRoot(roots, rr);
        if (result != null){
            return result;
        }
        knownMissedInRange.mark();
        return null;
    }

    @Override
    public void contentChanged(@NotNull AbstractDocumentNodeState root) {
        synchronized (queue){
            //TODO Possibly can be improved
            queue.add(root);
            previousRoots = queue.toArray(EMPTY);
        }
    }

    private boolean isEmpty() {
        return previousRoots.length == 0;
    }

    static AbstractDocumentNodeState findMatchingRoot(AbstractDocumentNodeState[] roots, RevisionVector key) {
        int low = 0;
        int high = roots.length - 1;

        //Perform a binary search as the array is sorted in ascending order
        while (low <= high) {
            int mid = (low + high) >>> 1;
            AbstractDocumentNodeState midVal = roots[mid];
            int cmp = midVal.getRootRevision().compareTo(key);

            if (cmp < 0) {
                low = mid + 1;
            } else if (cmp > 0) {
                high = mid - 1;
            } else {
                return midVal; // key found
            }
        }
        return null;  // key not found.
    }

    private static AbstractDocumentNodeState asDocState(NodeState state) {
        return (AbstractDocumentNodeState)state;
    }

}

redpajama_set_name: RedPajamaGithub


text:
using System.Text.Json;
using Azure.Communication.MediaComposition;
using Azure.Core;

namespace Azure.Communication.MediaComposition.Models
{
    public partial class MediaInput : IUtf8JsonSerializable
    {
        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
        {
            writer.WriteStartObject();
            writer.WritePropertyName("kind");
            writer.WriteStringValue(Kind.ToString());
            if (Optional.IsDefined(PlaceholderImageUri))
            {
                writer.WritePropertyName("placeholderImageUri");
                writer.WriteStringValue(PlaceholderImageUri);
            }
            writer.WriteEndObject();
        }

        internal static MediaInput DeserializeMediaInput(JsonElement element)
        {
            if (element.TryGetProperty("kind", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                    case "activePresenter": return ActivePresenter.DeserializeActivePresenter(element);
                    case "dominantSpeaker": return DominantSpeaker.DeserializeDominantSpeaker(element);
                    case "groupCall": return GroupCallInput.DeserializeGroupCallInput(element);
                    case "image": return ImageInput.DeserializeImageInput(element);
                    case "participant": return ParticipantInput.DeserializeParticipantInput(element);
                    case "room": return RoomInput.DeserializeRoomInput(element);
                    case "rtmp": return RtmpInput.DeserializeRtmpInput(element);
                    case "screenShare": return ScreenShare.DeserializeScreenShare(element);
                    case "srt": return SrtInput.DeserializeSrtInput(element);
                    case "teamsMeeting": return TeamsMeetingInput.DeserializeTeamsMeetingInput(element);
                }
            }
            return UnknownMediaInput.DeserializeUnknownMediaInput(element);
        }
    }
}


text:
  <form class="weui_search_outer">

      <input type="search" class="weui_search_input" id="search_input" placeholder="搜索" required/>

      搜索

  </form>
  取消


text:
<!DOCTYPE html>

  <meta charset="UTF-8">
  <title>Code Coverage for /home/toby/PhpStormProjects/alcys-orm/src/Core/Types/TypesInterface.php</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="../css/bootstrap.min.css" rel="stylesheet">
  <link href="../css/style.css" rel="stylesheet">

/home/toby/PhpStormProjects/alcys-orm/src/Core

Types

TypesInterface.php

Code Coverage

Classes and Traits

Functions and Methods

Lines

      Total

      CRAP

1
	<?php

2

3

24

25
	namespace Alcys\Core\Types;

26

27
	/**

28
	 * Interface TypesInterface

29
	 * @package Alcys\Core\Types

30
	 */

31
	interface TypesInterface

32
	{

33
	    /**

34
	     * Each object with a TypesInterface is a simple

35
	     * value object that represent specific types, so

36
	     * we can use TypeHints for ParameterInjections.

37
	     *

38
	     * @param mixed $arg

39
	     */

40
	    public function __construct($arg);

41

42

43
	    /**

44
	     * This magic method is used to return the value,

45
	     * that is passed as argument while the instantiation,

46
	     * immediate as a string.

47
	     *

48
	     * @return string

49
	     */

50
	    public function __toString();

51
	}

Legend

     Executed
     Not Executed
     Dead Code

     Generated by PHP_CodeCoverage 2.0.15 using PHP 5.5.12-2ubuntu4.6 and PHPUnit 4.5.0 at Sat Jul 25 22:06:57 CEST 2015.


text:
Syntax.layouts.fixed = function(options, code, container) {
	var fixed = jQuery('
'), line = 1, space = /^\s*$/;
	var toolbar = jQuery('
');

	var rawCode = container.clone();
	rawCode.addClass("raw syntax highlighted");

	var codeTable = document.createElement('table');

	var codeTableBody = document.createElement('tbody');
	codeTable.appendChild(codeTableBody);

	var numbersColumn = jQuery('
');
	var codeColumn = jQuery('
');

	// Source code
	code.children().each(function() {
		var lineNumber = document.createElement('div');
		lineNumber.className = "line ln" + line
		lineNumber.innerHTML = line;
		numbersColumn.append(lineNumber);

		var lineCode = document.createElement('td');
		lineCode.className = "source "  + this.className;

		if (line % 2) {
			lineCode.className += " alt";
		}

		if (lineCode == 1) {
			lineNumber.className += " first"
		}

		// Thanks to Michael for suggesting the obvious :)
		lineCode.appendChild(this);

		var tr = document.createElement('tr');
		tr.appendChild(lineCode);
		codeTableBody.appendChild(tr);

		line = line + 1;
	});

	codeColumn.append(codeTable);

	fixed.append(numbersColumn);
	fixed.append(codeColumn);

	a = jQuery('View Raw Code');
	a.click(function (event) {
		event.preventDefault();

		if (jQuery(fixed).is(':visible')) {
			rawCode.height(jQuery(fixed).height());
			jQuery(fixed).replaceWith(rawCode);
		} else {
			jQuery(rawCode).replaceWith(fixed);
		}
	});

	toolbar.append(a);
	toolbar.append('?');

	return jQuery('
').append(toolbar).append(fixed);
};


text:
package org.apache.omid;

import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
import org.apache.hadoop.hbase.regionserver.HRegion;
import org.apache.hadoop.hbase.regionserver.HRegionServer;
import org.apache.hadoop.hbase.regionserver.Region;

import java.io.IOException;

public class HBaseShims {

    static public void setKeyValueSequenceId(KeyValue kv, int sequenceId) {

        kv.setMvccVersion(sequenceId);

    }

    static public Region getRegionCoprocessorRegion(RegionCoprocessorEnvironment env) {

        return new Region(env.getRegion());

    }

    static public void flushAllOnlineRegions(HRegionServer regionServer, TableName tableName) throws IOException {

        for (HRegion r : regionServer.getOnlineRegions(tableName)) {
            r.flushcache();
        }

    }

    static public void addFamilyToHTableDescriptor(HTableDescriptor tableDesc, HColumnDescriptor columnDesc) {

        tableDesc.addFamily(columnDesc);

    }

}


text:
require 'test_helper'

class Flo2cashTest < Test::Unit::TestCase
  include CommStub

  def setup
    Base.mode = :test

    @gateway = Flo2cashGateway.new(
      :username => 'username',
      :password => 'password',
      :account_id => 'account_id'
    )

    @credit_card = credit_card
    @amount = 100
  end

  def test_successful_purchase
    response = stub_comms do
      @gateway.purchase(@amount, @credit_card, order_id: "boom")
    end.respond_with(successful_purchase_response)

    assert_success response

    assert_equal "P1610W0005138048", response.authorization
    assert response.test?
  end

  def test_failed_purchase
    response = stub_comms do
      @gateway.purchase(@amount, @credit_card)
    end.respond_with(failed_purchase_response)

    assert_failure response
    assert_equal "Transaction Declined - Bank Error", response.message
    assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
    assert response.test?
  end

  def test_successful_authorize_and_capture
    response = stub_comms do
      @gateway.authorize(@amount, @credit_card)
    end.respond_with(successful_authorize_response)

    assert_success response
    assert_equal "P150100005006789", response.authorization

    capture = stub_comms do
      @gateway.capture(@amount, response.authorization)
    end.check_request do |endpoint, data, headers|
      assert_match(/P150100005006789/, data)
    end.respond_with(successful_capture_response)

    assert_success capture
  end

  def test_failed_authorize
    response = stub_comms do
      @gateway.authorize(@amount, @credit_card)
    end.respond_with(failed_authorize_response)

    assert_failure response
    assert_equal "Transaction Declined - Bank Error", response.message
    assert_equal Gateway::STANDARD_ERROR_CODE[:processing_error], response.error_code
    assert response.test?
  end

  def test_successful_refund
    response = stub_comms do
      @gateway.purchase(@amount, @credit_card)
    end.respond_with(successful_purchase_response)

    assert_success response
    assert_equal "P1610W0005138048", response.authorization

    refund = stub_comms do
      @gateway.refund(@amount, response.authorization)
    end.check_request do |endpoint, data, headers|
      assert_match(/P1610W0005138048/, data)
    end.respond_with(successful_refund_response)

    assert_success refund
  end

  def test_empty_response_fails
    response = stub_comms do
      @gateway.purchase(@amount, @credit_card)
    end.respond_with(empty_purchase_response)

    assert_failure response
    assert_equal "Unable to read error message", response.message
  end

  def test_transcript_scrubbing
    transcript =  @gateway.scrub(successful_authorize_response)

    assert_scrubbed(@credit_card.number, transcript)
    assert_scrubbed(@credit_card.verification_value, transcript)
    assert_scrubbed(@gateway.options[:password], transcript)
  end

  def test_successful_store
    response = stub_comms do
      @gateway.store(@credit_card)
    end.respond_with(successful_store_response)

    assert_success response
    assert_equal '25223239884', response.authorization
  end

  def test_failed_store
    response = stub_comms do
      @gateway.store(@credit_card)
    end.respond_with(failed_store_response)

    assert_failure response
    assert_equal 'Card number must be a valid credit card number', response.message
  end

  def test_successful_unstore
    response = stub_comms do
      @gateway.store(@credit_card)
    end.respond_with(successful_store_response)

    assert_success response
    assert_equal '25223239884', response.authorization

    unstore = stub_comms do
      @gateway.unstore(response.authorization)
    end.respond_with(successful_unstore_response)

    assert_success unstore
  end

  def test_failed_unstore
    response = stub_comms do
      @gateway.unstore('12345')
    end.respond_with(failed_unstore_response)

    assert_failure response
    assert_equal 'Card token not found', response.message
  end

  def test_successful_purchase_with_token
    response = stub_comms do
      @gateway.store(@credit_card)
    end.respond_with(successful_store_response)

    assert_success response
    assert_equal '25223239884', response.authorization

    purchase = stub_comms do
      @gateway.purchase(@amount, response.authorization)
    end.respond_with(successful_purchase_with_token_response)

    assert_success purchase
    assert_equal 'P1610W0005138055', purchase.authorization
  end

  def test_failed_purchase_with_token
    purchase = stub_comms do
      @gateway.purchase(@amount, '12345')
    end.respond_with(failed_purchased_with_token_response)

    assert_failure purchase
    assert_equal 'Card token not found', purchase.message
  end

  private

  def successful_authorize_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><ProcessAuthoriseResponse xmlns=\"http://www.flo2cash.co.nz/webservices/paymentwebservice\"><transactionresult><TransactionId>P150100005006789</TransactionId><OriginalTransactionId /><Type>AUTHORISATION</Type><AccountId>621409</AccountId><Status>SUCCESSFUL</Status><ReceiptNumber>25001371</ReceiptNumber><AuthCode>017265</AuthCode><Amount>100</Amount><Reference /><Particular>Store Purchase</Particular><Message>Transaction Successful</Message><BlockedReason /><CardStored>false</CardStored><CardToken /></transactionresult></ProcessAuthoriseResponse></soap:Body></soap:Envelope>
    )
  end

  def failed_authorize_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><ProcessAuthoriseResponse xmlns=\"http://www.flo2cash.co.nz/webservices/paymentwebservice\"><transactionresult><TransactionId>P150100005006794</TransactionId><OriginalTransactionId /><Type>AUTHORISATION</Type><AccountId>621409</AccountId><Status>FAILED</Status><ReceiptNumber>0</ReceiptNumber><AuthCode /><Amount>100</Amount><Reference /><Particular>Store Purchase</Particular><Message>Transaction Declined - Bank Error</Message><BlockedReason /><CardStored>false</CardStored><CardToken /></transactionresult></ProcessAuthoriseResponse></soap:Body></soap:Envelope>
    )
  end

  def successful_capture_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><ProcessCaptureResponse xmlns=\"http://www.flo2cash.co.nz/webservices/paymentwebservice\"><transactionresult><TransactionId>P150100005006790</TransactionId><OriginalTransactionId>P150100005006789</OriginalTransactionId><Type>CAPTURE</Type><AccountId>621409</AccountId><Status>SUCCESSFUL</Status><ReceiptNumber>25001372</ReceiptNumber><AuthCode>007524</AuthCode><Amount>100</Amount><Reference /><Particular /><Message>Transaction Successful</Message><BlockedReason /><CardStored>false</CardStored><CardToken /></transactionresult></ProcessCaptureResponse></soap:Body></soap:Envelope>
    )
  end

  def successful_refund_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><ProcessRefundResponse xmlns=\"http://www.flo2cash.co.nz/webservices/paymentwebservice\"><transactionresult><TransactionId>P1610W0005138053</TransactionId><OriginalTransactionId>P1610W0005138052</OriginalTransactionId><Type>REFUND</Type><AccountId>621462</AccountId><Status>SUCCESSFUL</Status><ReceiptNumber>25162085</ReceiptNumber><AuthCode>425730</AuthCode><Amount>1.00</Amount><Reference /><Particular /><Message>Transaction Successful</Message><BlockedReason /><CardStored>false</CardStored><CardToken /></transactionresult></ProcessRefundResponse></soap:Body></soap:Envelope>
    )
  end

  def empty_purchase_response
    %(
    )
  end

  def successful_purchase_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><ProcessPurchaseResponse xmlns=\"http://www.flo2cash.co.nz/webservices/paymentwebservice\"><transactionresult><TransactionId>P1610W0005138048</TransactionId><OriginalTransactionId /><Type>PURCHASE</Type><AccountId>621462</AccountId><Status>SUCCESSFUL</Status><ReceiptNumber>25162080</ReceiptNumber><AuthCode>915933</AuthCode><Amount>1.00</Amount><Reference>4dad48e7ca579b597963bab9635761c0</Reference><Particular>Store Purchase</Particular><Message>Transaction Successful</Message><BlockedReason /><CardStored>false</CardStored><CardToken /></transactionresult></ProcessPurchaseResponse></soap:Body></soap:Envelope>
    )
  end

  def failed_purchase_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><ProcessPurchaseResponse xmlns=\"http://www.flo2cash.co.nz/webservices/paymentwebservice\"><transactionresult><TransactionId>P1610W0005138051</TransactionId><OriginalTransactionId /><Type>PURCHASE</Type><AccountId>621462</AccountId><Status>FAILED</Status><ReceiptNumber>0</ReceiptNumber><AuthCode /><Amount>1.10</Amount><Reference>591f9a1e8fbe4fb8ff82ea628e7ae3ea</Reference><Particular>Store Purchase</Particular><Message>Transaction Declined - Bank Error</Message><BlockedReason /><CardStored>false</CardStored><CardToken /></transactionresult></ProcessPurchaseResponse></soap:Body></soap:Envelope>
    )
  end

  def successful_store_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><AddCardResponse xmlns=\"http://www.flo2cash.co.nz/webservices/creditcardwebservice\"><AddCardResult>25223239884</AddCardResult></AddCardResponse></soap:Body></soap:Envelope>
    )
  end

  def failed_store_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Sender</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang=\"en\">Card number must be a valid credit card number</soap:Text></soap:Reason><soap:Node>AddCard</soap:Node><detail><error><errortype>Parameter</errortype><errornumber>1002</errornumber><errormessage>Card number must be a valid credit card number</errormessage></error></detail></soap:Fault></soap:Body></soap:Envelope>
    )
  end

  def successful_unstore_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><RemoveCardResponse xmlns=\"http://www.flo2cash.co.nz/webservices/creditcardwebservice\"><RemoveCardResult>true</RemoveCardResult></RemoveCardResponse></soap:Body></soap:Envelope>
    )
  end

  def failed_unstore_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Sender</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang=\"en\">Card token not found</soap:Text></soap:Reason><soap:Node>RemoveCard</soap:Node><detail><error><errortype>Parameter</errortype><errornumber>2000</errornumber><errormessage>Card token not found</errormessage></error></detail></soap:Fault></soap:Body></soap:Envelope>
    )
  end

  def successful_purchase_with_token_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><ProcessPurchaseByTokenResponse xmlns=\"http://www.flo2cash.co.nz/webservices/paymentwebservice\"><transactionresult><TransactionId>P1610W0005138055</TransactionId><OriginalTransactionId /><Type>PURCHASE</Type><AccountId>621462</AccountId><Status>SUCCESSFUL</Status><ReceiptNumber>25162087</ReceiptNumber><AuthCode>943672</AuthCode><Amount>1.00</Amount><Reference>4a669b0e31206b57b7088e4f9433025a</Reference><Particular>Store Purchase</Particular><Message>Transaction Successful</Message><BlockedReason /><CardStored>false</CardStored><CardToken /></transactionresult></ProcessPurchaseByTokenResponse></soap:Body></soap:Envelope>
    )
  end

  def failed_purchased_with_token_response
    %(
      <?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><soap:Body><soap:Fault><soap:Code><soap:Value>soap:Sender</soap:Value></soap:Code><soap:Reason><soap:Text xml:lang=\"en\">Card token not found</soap:Text></soap:Reason><soap:Node>ProcessTokenPayment</soap:Node><detail><error><errortype>Parameter</errortype><errornumber>2000</errornumber><errormessage>Card token not found</errormessage></error></detail></soap:Fault></soap:Body></soap:Envelope>
    )
  end
end


text:
package com.quollwriter.data;

import com.quollwriter.ui.*;
import com.quollwriter.ui.userobjects.*;

/**
 * Models a text user configurable object field.
 */
public class ObjectDescriptionUserConfigurableObjectTypeField extends MultiTextUserConfigurableObjectTypeField
{

    public ObjectDescriptionUserConfigurableObjectTypeField ()
    {

        super (Type.objectdesc);

        this.setDefinitionValue ("isObjectDesc", true);

    }

    @Override
    public boolean canDelete ()
    {

        return true;

    }

    @Override
    public UserConfigurableObjectTypeFieldConfigHandler getConfigHandler ()
    {

        return new ObjectDescriptionUserConfigurableObjectTypeFieldConfigHandler (this);

    }

    @Override
    public UserConfigurableObjectFieldViewEditHandler getViewEditHandler (UserConfigurableObject      obj,
                                                                          UserConfigurableObjectField field,
                                                                          AbstractProjectViewer       viewer)
    {

        return new ObjectDescriptionUserConfigurableObjectFieldViewEditHandler (this,
                                                                                obj,
                                                                                field,
                                                                                viewer);

    }

    @Override
    public boolean isSearchable ()
    {

        return true;

    }

    @Override
    public void setNameField (boolean v)
    {

    }

    @Override
    public boolean isNameField ()
    {

        return false;

    }

}


text:
#ifndef DATE_TIME_TIME_RESOLUTION_TRAITS_HPP
#define DATE_TIME_TIME_RESOLUTION_TRAITS_HPP

#include <ctime>
#include <boost/cstdint.hpp>
#include <boost/date_time/time_defs.hpp>
#include <boost/date_time/int_adapter.hpp>
#include <boost/date_time/compiler_config.hpp>

namespace boost {
namespace date_time {

  //! Simple function to calculate absolute value of a numeric type
  template <typename T>
  // JDG [7/6/02 made a template],
  // moved here from time_duration.hpp 2003-Sept-4.
  inline T absolute_value(T x)
  {
    return x < 0 ? -x : x;
  }

  //! traits struct for time_resolution_traits implementation type
  struct time_resolution_traits_bi32_impl {
    typedef boost::int32_t int_type;
    typedef boost::int32_t impl_type;
    static int_type as_number(impl_type i){ return i;}
    //! Used to determine if implemented type is int_adapter or int
    static bool is_adapted() { return false;}
  };
  //! traits struct for time_resolution_traits implementation type
  struct time_resolution_traits_adapted32_impl {
    typedef boost::int32_t int_type;
    typedef boost::date_time::int_adapter<boost::int32_t> impl_type;
    static int_type as_number(impl_type i){ return i.as_number();}
    //! Used to determine if implemented type is int_adapter or int
    static bool is_adapted() { return true;}
  };
  //! traits struct for time_resolution_traits implementation type
  struct time_resolution_traits_bi64_impl {
    typedef boost::int64_t int_type;
    typedef boost::int64_t impl_type;
    static int_type as_number(impl_type i){ return i;}
    //! Used to determine if implemented type is int_adapter or int
    static bool is_adapted() { return false;}
  };
  //! traits struct for time_resolution_traits implementation type
  struct time_resolution_traits_adapted64_impl {
    typedef boost::int64_t int_type;
    typedef boost::date_time::int_adapter<boost::int64_t> impl_type;
    static int_type as_number(impl_type i){ return i.as_number();}
    //! Used to determine if implemented type is int_adapter or int
    static bool is_adapted() { return true;}
  };

  //
  // Note about var_type, which is used to define the variable that
  // stores hours, minutes, and seconds values:
  //
  // In Boost 1.65.1 and earlier var_type was boost::int32_t which suffers
  // the year 2038 problem.  Binary serialization of posix_time uses
  // 32-bit values, and uses serialization version 0.
  //
  // In Boost 1.66.0 the var_type changed to std::time_t, however
  // binary serialization was not properly versioned, so on platforms
  // where std::time_t is 32-bits, it remains compatible, however on
  // platforms where std::time_t is 64-bits, binary serialization ingest
  // will be incompatible with previous versions.  Furthermore, binary
  // serialized output from 1.66.0 will not be compatible with future
  // versions.  Yes, it's a mess.  Static assertions were not present
  // in the serialization code to protect against this possibility.
  //
  // In Boost 1.67.0 the var_type was changed to boost::int64_t,
  // ensuring the output size is 64 bits, and the serialization version
  // was bumped.  Static assertions were added as well, protecting
  // future changes in this area.
  //

  template<typename frac_sec_type,
           time_resolutions res,
#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
           boost::int64_t resolution_adjust,
#else
           typename frac_sec_type::int_type resolution_adjust,
#endif
           unsigned short frac_digits,
           typename var_type = boost::int64_t >     // see note above
  class time_resolution_traits {
  public:
    typedef typename frac_sec_type::int_type fractional_seconds_type;
    typedef typename frac_sec_type::int_type tick_type;
    typedef typename frac_sec_type::impl_type impl_type;
    typedef var_type  day_type;
    typedef var_type  hour_type;
    typedef var_type  min_type;
    typedef var_type  sec_type;

    // bring in function from frac_sec_type traits structs
    static fractional_seconds_type as_number(impl_type i)
    {
      return frac_sec_type::as_number(i);
    }
    static bool is_adapted()
    {
      return frac_sec_type::is_adapted();
    }

    //Would like this to be frac_sec_type, but some compilers complain
#if (defined(BOOST_MSVC) && (_MSC_VER < 1300))
    BOOST_STATIC_CONSTANT(boost::int64_t, ticks_per_second = resolution_adjust);
#else
    BOOST_STATIC_CONSTANT(fractional_seconds_type, ticks_per_second = resolution_adjust);
#endif

    static time_resolutions resolution()
    {
      return res;
    }
    static unsigned short num_fractional_digits()
    {
      return frac_digits;
    }
    static fractional_seconds_type res_adjust()
    {
      return resolution_adjust;
    }
    //! Any negative argument results in a negative tick_count
    static tick_type to_tick_count(hour_type hours,
                                   min_type  minutes,
                                   sec_type  seconds,
                                   fractional_seconds_type  fs)
    {
      if(hours < 0 || minutes < 0 || seconds < 0 || fs < 0)
      {
        hours = absolute_value(hours);
        minutes = absolute_value(minutes);
        seconds = absolute_value(seconds);
        fs = absolute_value(fs);
        return static_cast<tick_type>(((((fractional_seconds_type(hours)*3600)
                                       + (fractional_seconds_type(minutes)*60)
                                       + seconds)*res_adjust()) + fs) * -1);
      }

      return static_cast<tick_type>((((fractional_seconds_type(hours)*3600)
                                    + (fractional_seconds_type(minutes)*60)
                                    + seconds)*res_adjust()) + fs);
    }

  };

  typedef time_resolution_traits<time_resolution_traits_adapted32_impl, milli, 1000, 3 > milli_res;
  typedef time_resolution_traits<time_resolution_traits_adapted64_impl, micro, 1000000, 6 > micro_res;
  typedef time_resolution_traits<time_resolution_traits_adapted64_impl, nano,  1000000000, 9 > nano_res;

} } //namespace date_time

#endif


text:
namespace ui {

ScopedDisableClientSideDecorationsForTest::
    ScopedDisableClientSideDecorationsForTest() {
#if defined(USE_OZONE)
  if (auto* platform_utils = OzonePlatform::GetInstance()->GetPlatformUtils()) {
    disabled_csd_ = platform_utils->DisableClientSideDecorationsForTest();
  }
#endif
}

ScopedDisableClientSideDecorationsForTest::
    ~ScopedDisableClientSideDecorationsForTest() = default;

}  // namespace ui


text:
package sk.henrichg.phoneprofilesplus;

import android.content.Context;
import android.content.res.TypedArray;
import android.preference.DialogPreference;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.NumberPicker;

/*
 * @author Danesh
 * @author nebkat
 */

public class NumberPickerPreference extends DialogPreference {
    private int mMin, mMax;

    private String mMaxExternalKey, mMinExternalKey;

    private NumberPicker mNumberPicker;

    public NumberPickerPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedArray numberPickerType = context.obtainStyledAttributes(attrs,
                R.styleable.NumberPickerPreference, 0, 0);

        mMaxExternalKey = numberPickerType.getString(R.styleable.NumberPickerPreference_maxExternal);
        mMinExternalKey = numberPickerType.getString(R.styleable.NumberPickerPreference_minExternal);

        mMax = numberPickerType.getInt(R.styleable.NumberPickerPreference_max, 5);
        mMin = numberPickerType.getInt(R.styleable.NumberPickerPreference_min, 0);

        numberPickerType.recycle();
    }

    @Override
    protected View onCreateDialogView() {
        int max = mMax;
        int min = mMin;

        // External values
        if (mMaxExternalKey != null) {
            max = getSharedPreferences().getInt(mMaxExternalKey, mMax);
        }
        if (mMinExternalKey != null) {
            min = getSharedPreferences().getInt(mMinExternalKey, mMin);
        }

        LayoutInflater inflater =
                (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = inflater.inflate(R.layout.activity_number_pref_dialog, null);

        mNumberPicker = (NumberPicker) view.findViewById(R.id.number_picker);

        // Initialize state
        mNumberPicker.setMaxValue(max);
        mNumberPicker.setMinValue(min);
        //mNumberPicker.setValue(getPersistedInt(min));
        mNumberPicker.setValue(Integer.valueOf(getPersistedString(String.valueOf(min))));
        mNumberPicker.setWrapSelectorWheel(false);

        /*
        mNumberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
            @Override
            public void onValueChange(NumberPicker numberPicker, int valueOld, int valueNew) {

                //Toast.makeText(this, "Value was: " + Integer.toString(valueOld) + " is now: " + Integer.toString(valueNew), Toast.LENGTH_SHORT).show();
                //persistString(String.valueOf(valueNew));

        		callChangeListener(String.valueOf(valueNew));

            }
        });
        */

        return view;
    }

    @Override
    protected void onDialogClosed(boolean positiveResult) {
        if (positiveResult) {
        	mNumberPicker.clearFocus();

        	String value = String.valueOf(mNumberPicker.getValue());

    		if (callChangeListener(value))
    		{
	    		//persistInt(mNumberPicker.getValue());
	            persistString(value);
    		}
        }
    }

}


text:
#pragma once

#include <SDL.h>
#include <iostream>
#include <unordered_map>
#include "Shader.h"
#include "UIObject.h"
#include "UI.h"

/**
@brief A class for the 2D CreditsUI that inherits UI.
@author Jamie Slowgrove
*/
class CreditsUI : public UI
{
private:
	/**The credits image*/
	UIObject * credits;

public:
	/**
	Constructs the CreditsUI object.
	@param vertexShaderFileName The name of the vertex shader file.
	@param fragmentShaderFileName The name of the fragment shader file.
	@param shaders A reference to the loaded Shader files
	*/
	CreditsUI(std::string vertexShaderFileName, std::string fragmentShaderFileName,
		std::unordered_map<std::string, Shader*> &shaders);

	/**
	Constructs the CreditsUI object.
	@param shaders A reference to the loaded Shader files
	*/
	CreditsUI(std::unordered_map<std::string, Shader*> &shaders);

	/**
	Destructs the CreditsUI object.
	*/
	~CreditsUI();

	/**
	A function to update the CreditsUI.
	@param dt The delta time.
	*/
	void update(float dt);

	/**
	A function to draw to the screen.
	*/
	void draw();
};


text:
[![Version](https://img.shields.io/cocoapods/v/TestPods.svg?style=flat)](http://cocoapods.org/pods/TestPods)
[![License](https://img.shields.io/cocoapods/l/TestPods.svg?style=flat)](http://cocoapods.org/pods/TestPods)
[![Platform](https://img.shields.io/cocoapods/p/TestPods.svg?style=flat)](http://cocoapods.org/pods/TestPods)

## Example

To run the example project, clone the repo, and run `pod install` from the Example directory first.

## Requirements

## Installation

TestPods is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

```ruby
pod "TestPods"
```

## Author

Lazar Djordjevic, lazar89nis@gmail.com

## License

TestPods is available under the MIT license. See the LICENSE file for more info.


text:
module Ruboty
  module Handlers
    class Cron < Base
      NAMESPACE = "cron"

      on(/add job "(?<schedule>.+?)" (?<body>.+)/m, name: "add", description: "Add a new cron job")

      on(/delete job (?<id>\d+)/, name: "delete", description: "Delete a cron job")

      on(/list jobs\z/, name: "list", description: "List all cron jobs")

      attr_writer :jobs

      def initialize(*args)
        super
        remember
      end

      def add(message)
        job = create(message)
        message.reply("Job #{job.id} created")
      end

      def delete(message)
        id = message[:id].to_i
        if jobs.has_key?(id)
          jobs.delete(id)
          running_jobs[id].stop
          running_jobs.delete(id)
          message.reply("Job #{id} deleted")
        else
          message.reply("Job #{id} does not exist")
        end
      end

      def list(message)
        message.reply(summary, code: true)
      end

      private

      def remember
        jobs.each do |id, attributes|
          job = Ruboty::Cron::Job.new(attributes)
          running_jobs[id] = job
          job.start(robot)
        end
      end

      def jobs
        robot.brain.data[NAMESPACE] ||= {}
      end

      def create(message)
        job = Ruboty::Cron::Job.new(
          message.original.except(:robot).merge(
            body: message[:body],
            id: generate_id,
            schedule: message[:schedule],
          ),
        )
        jobs[job.id] = job.to_hash
        job.start(robot)
        running_jobs[job.id] = job
        job
      end

      def summary
        if jobs.empty?
          empty_message
        else
          job_descriptions
        end
      end

      def empty_message
        "Job not found"
      end

      def job_descriptions
        jobs.values.map do |attributes|
          Ruboty::Cron::Job.new(attributes).description
        end.join("\n")
      end

      def generate_id
        loop do
          id = rand(10000)
          break id unless jobs.has_key?(id)
        end
      end

      def running_jobs
        @running_jobs ||= {}
      end
    end
  end
end


text:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AirportEntities
{
    public class Class1
    {
    }
}


text:
package me.tatarka.simplefragment.test;

import org.junit.runners.model.InitializationError;
import org.robolectric.AndroidManifest;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.SdkConfig;
import org.robolectric.annotation.Config;

import java.io.File;
import java.util.Properties;

public class CustomRobolectricRunner extends RobolectricTestRunner {
    public CustomRobolectricRunner(Class<?> testClass)
            throws InitializationError {
        super(testClass);
    }

    @Override
    protected AndroidManifest getAppManifest(Config config) {
        String path = "src/main/AndroidManifest.xml";

        // android studio has a different execution root for tests than pure gradle
        // so we avoid here manual effort to get them running inside android studio
        if (!new File(path).exists()) {
            path = "app/" + path;
        }

        config = overwriteConfig(config, "manifest", path);
        return super.getAppManifest(config);
    }

    protected Config.Implementation overwriteConfig(
            Config config, String key, String value) {
        Properties properties = new Properties();
        properties.setProperty(key, value);
        return new Config.Implementation(config,
                Config.Implementation.fromProperties(properties));
    }

    @Override
    protected SdkConfig pickSdkVersion(
            AndroidManifest appManifest, Config config) {
        // current Robolectric supports not the latest android SDK version
        // so we must downgrade to simulate the latest supported version.
        config = overwriteConfig(config, "emulateSdk", "18");
        return super.pickSdkVersion(appManifest, config);
    }
}


text:
<?php
var_export(clone []);
var_export(clone (new stdClass()));
var_export(clone 'str');
var_export(clone null);
/** @param mixed $x */
function test($x) {
    return clone($x);
}


text:
"""

Copyright (c) 2014-2018 Alex Forencich

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

"""

from myhdl import *
import os

import eth_ep
import ip_ep
import udp_ep

module = 'udp_ip_tx_64'
testbench = 'test_%s' % module

srcs = []

srcs.append("../rtl/%s.v" % module)
srcs.append("%s.v" % testbench)

src = ' '.join(srcs)

build_cmd = "iverilog -o %s.vvp %s" % (testbench, src)

def bench():

    # Inputs
    clk = Signal(bool(0))
    rst = Signal(bool(0))
    current_test = Signal(intbv(0)[8:])

    s_udp_hdr_valid = Signal(bool(0))
    s_eth_dest_mac = Signal(intbv(0)[48:])
    s_eth_src_mac = Signal(intbv(0)[48:])
    s_eth_type = Signal(intbv(0)[16:])
    s_ip_version = Signal(intbv(0)[4:])
    s_ip_ihl = Signal(intbv(0)[4:])
    s_ip_dscp = Signal(intbv(0)[6:])
    s_ip_ecn = Signal(intbv(0)[2:])
    s_ip_identification = Signal(intbv(0)[16:])
    s_ip_flags = Signal(intbv(0)[3:])
    s_ip_fragment_offset = Signal(intbv(0)[13:])
    s_ip_ttl = Signal(intbv(0)[8:])
    s_ip_protocol = Signal(intbv(0)[8:])
    s_ip_header_checksum = Signal(intbv(0)[16:])
    s_ip_source_ip = Signal(intbv(0)[32:])
    s_ip_dest_ip = Signal(intbv(0)[32:])
    s_udp_source_port = Signal(intbv(0)[16:])
    s_udp_dest_port = Signal(intbv(0)[16:])
    s_udp_length = Signal(intbv(0)[16:])
    s_udp_checksum = Signal(intbv(0)[16:])
    s_udp_payload_axis_tdata = Signal(intbv(0)[64:])
    s_udp_payload_axis_tkeep = Signal(intbv(0)[8:])
    s_udp_payload_axis_tvalid = Signal(bool(0))
    s_udp_payload_axis_tlast = Signal(bool(0))
    s_udp_payload_axis_tuser = Signal(bool(0))
    m_ip_payload_axis_tready = Signal(bool(0))
    m_ip_hdr_ready = Signal(bool(0))

    # Outputs
    s_udp_hdr_ready = Signal(bool(0))
    s_udp_payload_axis_tready = Signal(bool(0))
    m_ip_hdr_valid = Signal(bool(0))
    m_eth_dest_mac = Signal(intbv(0)[48:])
    m_eth_src_mac = Signal(intbv(0)[48:])
    m_eth_type = Signal(intbv(0)[16:])
    m_ip_version = Signal(intbv(0)[4:])
    m_ip_ihl = Signal(intbv(0)[4:])
    m_ip_dscp = Signal(intbv(0)[6:])
    m_ip_ecn = Signal(intbv(0)[2:])
    m_ip_length = Signal(intbv(0)[16:])
    m_ip_identification = Signal(intbv(0)[16:])
    m_ip_flags = Signal(intbv(0)[3:])
    m_ip_fragment_offset = Signal(intbv(0)[13:])
    m_ip_ttl = Signal(intbv(0)[8:])
    m_ip_protocol = Signal(intbv(0)[8:])
    m_ip_header_checksum = Signal(intbv(0)[16:])
    m_ip_source_ip = Signal(intbv(0)[32:])
    m_ip_dest_ip = Signal(intbv(0)[32:])
    m_ip_payload_axis_tdata = Signal(intbv(0)[64:])
    m_ip_payload_axis_tkeep = Signal(intbv(0)[8:])
    m_ip_payload_axis_tvalid = Signal(bool(0))
    m_ip_payload_axis_tlast = Signal(bool(0))
    m_ip_payload_axis_tuser = Signal(bool(0))
    busy = Signal(bool(0))
    error_payload_early_termination = Signal(bool(0))

    # sources and sinks
    source_pause = Signal(bool(0))
    sink_pause = Signal(bool(0))

    source = udp_ep.UDPFrameSource()

    source_logic = source.create_logic(
        clk,
        rst,
        udp_hdr_ready=s_udp_hdr_ready,
        udp_hdr_valid=s_udp_hdr_valid,
        eth_dest_mac=s_eth_dest_mac,
        eth_src_mac=s_eth_src_mac,
        eth_type=s_eth_type,
        ip_version=s_ip_version,
        ip_ihl=s_ip_ihl,
        ip_dscp=s_ip_dscp,
        ip_ecn=s_ip_ecn,
        ip_identification=s_ip_identification,
        ip_flags=s_ip_flags,
        ip_fragment_offset=s_ip_fragment_offset,
        ip_ttl=s_ip_ttl,
        ip_protocol=s_ip_protocol,
        ip_header_checksum=s_ip_header_checksum,
        ip_source_ip=s_ip_source_ip,
        ip_dest_ip=s_ip_dest_ip,
        udp_source_port=s_udp_source_port,
        udp_dest_port=s_udp_dest_port,
        udp_length=s_udp_length,
        udp_checksum=s_udp_checksum,
        udp_payload_tdata=s_udp_payload_axis_tdata,
        udp_payload_tkeep=s_udp_payload_axis_tkeep,
        udp_payload_tvalid=s_udp_payload_axis_tvalid,
        udp_payload_tready=s_udp_payload_axis_tready,
        udp_payload_tlast=s_udp_payload_axis_tlast,
        udp_payload_tuser=s_udp_payload_axis_tuser,
        pause=source_pause,
        name='source'
    )

    sink = ip_ep.IPFrameSink()

    sink_logic = sink.create_logic(
        clk,
        rst,
        ip_hdr_ready=m_ip_hdr_ready,
        ip_hdr_valid=m_ip_hdr_valid,
        eth_dest_mac=m_eth_dest_mac,
        eth_src_mac=m_eth_src_mac,
        eth_type=m_eth_type,
        ip_version=m_ip_version,
        ip_ihl=m_ip_ihl,
        ip_dscp=m_ip_dscp,
        ip_ecn=m_ip_ecn,
        ip_length=m_ip_length,
        ip_identification=m_ip_identification,
        ip_flags=m_ip_flags,
        ip_fragment_offset=m_ip_fragment_offset,
        ip_ttl=m_ip_ttl,
        ip_protocol=m_ip_protocol,
        ip_header_checksum=m_ip_header_checksum,
        ip_source_ip=m_ip_source_ip,
        ip_dest_ip=m_ip_dest_ip,
        ip_payload_tdata=m_ip_payload_axis_tdata,
        ip_payload_tkeep=m_ip_payload_axis_tkeep,
        ip_payload_tvalid=m_ip_payload_axis_tvalid,
        ip_payload_tready=m_ip_payload_axis_tready,
        ip_payload_tlast=m_ip_payload_axis_tlast,
        ip_payload_tuser=m_ip_payload_axis_tuser,
        pause=sink_pause,
        name='sink'
    )

    # DUT
    if os.system(build_cmd):
        raise Exception("Error running build command")

    dut = Cosimulation(
        "vvp -m myhdl %s.vvp -lxt2" % testbench,
        clk=clk,
        rst=rst,
        current_test=current_test,

        s_udp_hdr_valid=s_udp_hdr_valid,
        s_udp_hdr_ready=s_udp_hdr_ready,
        s_eth_dest_mac=s_eth_dest_mac,
        s_eth_src_mac=s_eth_src_mac,
        s_eth_type=s_eth_type,
        s_ip_version=s_ip_version,
        s_ip_ihl=s_ip_ihl,
        s_ip_dscp=s_ip_dscp,
        s_ip_ecn=s_ip_ecn,
        s_ip_identification=s_ip_identification,
        s_ip_flags=s_ip_flags,
        s_ip_fragment_offset=s_ip_fragment_offset,
        s_ip_ttl=s_ip_ttl,
        s_ip_protocol=s_ip_protocol,
        s_ip_header_checksum=s_ip_header_checksum,
        s_ip_source_ip=s_ip_source_ip,
        s_ip_dest_ip=s_ip_dest_ip,
        s_udp_source_port=s_udp_source_port,
        s_udp_dest_port=s_udp_dest_port,
        s_udp_length=s_udp_length,
        s_udp_checksum=s_udp_checksum,
        s_udp_payload_axis_tdata=s_udp_payload_axis_tdata,
        s_udp_payload_axis_tkeep=s_udp_payload_axis_tkeep,
        s_udp_payload_axis_tvalid=s_udp_payload_axis_tvalid,
        s_udp_payload_axis_tready=s_udp_payload_axis_tready,
        s_udp_payload_axis_tlast=s_udp_payload_axis_tlast,
        s_udp_payload_axis_tuser=s_udp_payload_axis_tuser,

        m_ip_hdr_valid=m_ip_hdr_valid,
        m_ip_hdr_ready=m_ip_hdr_ready,
        m_eth_dest_mac=m_eth_dest_mac,
        m_eth_src_mac=m_eth_src_mac,
        m_eth_type=m_eth_type,
        m_ip_version=m_ip_version,
        m_ip_ihl=m_ip_ihl,
        m_ip_dscp=m_ip_dscp,
        m_ip_ecn=m_ip_ecn,
        m_ip_length=m_ip_length,
        m_ip_identification=m_ip_identification,
        m_ip_flags=m_ip_flags,
        m_ip_fragment_offset=m_ip_fragment_offset,
        m_ip_ttl=m_ip_ttl,
        m_ip_protocol=m_ip_protocol,
        m_ip_header_checksum=m_ip_header_checksum,
        m_ip_source_ip=m_ip_source_ip,
        m_ip_dest_ip=m_ip_dest_ip,
        m_ip_payload_axis_tdata=m_ip_payload_axis_tdata,
        m_ip_payload_axis_tkeep=m_ip_payload_axis_tkeep,
        m_ip_payload_axis_tvalid=m_ip_payload_axis_tvalid,
        m_ip_payload_axis_tready=m_ip_payload_axis_tready,
        m_ip_payload_axis_tlast=m_ip_payload_axis_tlast,
        m_ip_payload_axis_tuser=m_ip_payload_axis_tuser,

        busy=busy,
        error_payload_early_termination=error_payload_early_termination
    )

    @always(delay(4))
    def clkgen():
        clk.next = not clk

    error_payload_early_termination_asserted = Signal(bool(0))

    @always(clk.posedge)
    def monitor():
        if (error_payload_early_termination):
            error_payload_early_termination_asserted.next = 1

    def wait_normal():
        while s_udp_payload_axis_tvalid or m_ip_payload_axis_tvalid or s_udp_hdr_valid:
            yield clk.posedge

    def wait_pause_source():
        while s_udp_payload_axis_tvalid or m_ip_payload_axis_tvalid or s_udp_hdr_valid:
            yield clk.posedge
            yield clk.posedge
            source_pause.next = False
            yield clk.posedge
            source_pause.next = True
            yield clk.posedge

        source_pause.next = False

    def wait_pause_sink():
        while s_udp_payload_axis_tvalid or m_ip_payload_axis_tvalid or s_udp_hdr_valid:
            sink_pause.next = True
            yield clk.posedge
            yield clk.posedge
            yield clk.posedge
            sink_pause.next = False
            yield clk.posedge

    @instance
    def check():
        yield delay(100)
        yield clk.posedge
        rst.next = 1
        yield clk.posedge
        rst.next = 0
        yield clk.posedge
        yield delay(100)
        yield clk.posedge

        for payload_len in range(1,18):
            yield clk.posedge
            print("test 1: test packet, length %d" % payload_len)
            current_test.next = 1

            test_frame = udp_ep.UDPFrame()
            test_frame.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame.eth_src_mac = 0x5A5152535455
            test_frame.eth_type = 0x0800
            test_frame.ip_version = 4
            test_frame.ip_ihl = 5
            test_frame.ip_length = None
            test_frame.ip_identification = 0
            test_frame.ip_flags = 2
            test_frame.ip_fragment_offset = 0
            test_frame.ip_ttl = 64
            test_frame.ip_protocol = 0x11
            test_frame.ip_header_checksum = None
            test_frame.ip_source_ip = 0xc0a80164
            test_frame.ip_dest_ip = 0xc0a80165
            test_frame.udp_source_port = 1
            test_frame.udp_dest_port = 2
            test_frame.udp_length = None
            test_frame.udp_checksum = None
            test_frame.payload = bytearray(range(payload_len))
            test_frame.build()

            for wait in wait_normal, wait_pause_source, wait_pause_sink:
                source.send(test_frame)
                yield clk.posedge
                yield clk.posedge

                yield wait()

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame

                assert sink.empty()

                yield delay(100)

            yield clk.posedge
            print("test 2: back-to-back packets, length %d" % payload_len)
            current_test.next = 2

            test_frame1 = udp_ep.UDPFrame()
            test_frame1.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame1.eth_src_mac = 0x5A5152535455
            test_frame1.eth_type = 0x0800
            test_frame1.ip_version = 4
            test_frame1.ip_ihl = 5
            test_frame1.ip_length = None
            test_frame1.ip_identification = 0
            test_frame1.ip_flags = 2
            test_frame1.ip_fragment_offset = 0
            test_frame1.ip_ttl = 64
            test_frame1.ip_protocol = 0x11
            test_frame1.ip_header_checksum = None
            test_frame1.ip_source_ip = 0xc0a80164
            test_frame1.ip_dest_ip = 0xc0a80165
            test_frame1.udp_source_port = 1
            test_frame1.udp_dest_port = 2
            test_frame1.udp_length = None
            test_frame1.udp_checksum = None
            test_frame1.payload = bytearray(range(payload_len))
            test_frame1.build()
            test_frame2 = udp_ep.UDPFrame()
            test_frame2.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame2.eth_src_mac = 0x5A5152535455
            test_frame2.eth_type = 0x0800
            test_frame2.ip_version = 4
            test_frame2.ip_ihl = 5
            test_frame2.ip_length = None
            test_frame2.ip_identification = 0
            test_frame2.ip_flags = 2
            test_frame2.ip_fragment_offset = 0
            test_frame2.ip_ttl = 64
            test_frame2.ip_protocol = 0x11
            test_frame2.ip_header_checksum = None
            test_frame2.ip_source_ip = 0xc0a80164
            test_frame2.ip_dest_ip = 0xc0a80166
            test_frame2.udp_source_port = 1
            test_frame2.udp_dest_port = 2
            test_frame2.udp_length = None
            test_frame2.udp_checksum = None
            test_frame2.payload = bytearray(range(payload_len))
            test_frame2.build()

            for wait in wait_normal, wait_pause_source, wait_pause_sink:
                source.send(test_frame1)
                source.send(test_frame2)
                yield clk.posedge
                yield clk.posedge

                yield wait()

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame1

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame2

                assert sink.empty()

                yield delay(100)

            yield clk.posedge
            print("test 3: tuser assert, length %d" % payload_len)
            current_test.next = 3

            test_frame1 = udp_ep.UDPFrame()
            test_frame1.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame1.eth_src_mac = 0x5A5152535455
            test_frame1.eth_type = 0x0800
            test_frame1.ip_version = 4
            test_frame1.ip_ihl = 5
            test_frame1.ip_length = None
            test_frame1.ip_identification = 0
            test_frame1.ip_flags = 2
            test_frame1.ip_fragment_offset = 0
            test_frame1.ip_ttl = 64
            test_frame1.ip_protocol = 0x11
            test_frame1.ip_header_checksum = None
            test_frame1.ip_source_ip = 0xc0a80164
            test_frame1.ip_dest_ip = 0xc0a80165
            test_frame1.udp_source_port = 1
            test_frame1.udp_dest_port = 2
            test_frame1.udp_length = None
            test_frame1.udp_checksum = None
            test_frame1.payload = bytearray(range(payload_len))
            test_frame1.build()
            test_frame2 = udp_ep.UDPFrame()
            test_frame2.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame2.eth_src_mac = 0x5A5152535455
            test_frame2.eth_type = 0x0800
            test_frame2.ip_version = 4
            test_frame2.ip_ihl = 5
            test_frame2.ip_length = None
            test_frame2.ip_identification = 0
            test_frame2.ip_flags = 2
            test_frame2.ip_fragment_offset = 0
            test_frame2.ip_ttl = 64
            test_frame2.ip_protocol = 0x11
            test_frame2.ip_header_checksum = None
            test_frame2.ip_source_ip = 0xc0a80164
            test_frame2.ip_dest_ip = 0xc0a80166
            test_frame2.udp_source_port = 1
            test_frame2.udp_dest_port = 2
            test_frame2.udp_length = None
            test_frame2.udp_checksum = None
            test_frame2.payload = bytearray(range(payload_len))
            test_frame2.build()

            test_frame1.payload.user = 1

            for wait in wait_normal, wait_pause_source, wait_pause_sink:
                source.send(test_frame1)
                source.send(test_frame2)
                yield clk.posedge
                yield clk.posedge

                yield wait()

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame1
                assert rx_frame.payload.user[-1]

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame2

                assert sink.empty()

                yield delay(100)

            yield clk.posedge
            print("test 4: trailing bytes (1), length %d" % payload_len)
            current_test.next = 4

            test_frame1 = udp_ep.UDPFrame()
            test_frame1.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame1.eth_src_mac = 0x5A5152535455
            test_frame1.eth_type = 0x0800
            test_frame1.ip_version = 4
            test_frame1.ip_ihl = 5
            test_frame1.ip_length = None
            test_frame1.ip_identification = 0
            test_frame1.ip_flags = 2
            test_frame1.ip_fragment_offset = 0
            test_frame1.ip_ttl = 64
            test_frame1.ip_protocol = 0x11
            test_frame1.ip_header_checksum = None
            test_frame1.ip_source_ip = 0xc0a80164
            test_frame1.ip_dest_ip = 0xc0a80165
            test_frame1.udp_source_port = 1
            test_frame1.udp_dest_port = 2
            test_frame1.udp_length = None
            test_frame1.udp_checksum = None
            test_frame1.payload = bytearray(range(payload_len))
            test_frame1.build()
            test_frame2 = udp_ep.UDPFrame()
            test_frame2.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame2.eth_src_mac = 0x5A5152535455
            test_frame2.eth_type = 0x0800
            test_frame2.ip_version = 4
            test_frame2.ip_ihl = 5
            test_frame2.ip_length = None
            test_frame2.ip_identification = 0
            test_frame2.ip_flags = 2
            test_frame2.ip_fragment_offset = 0
            test_frame2.ip_ttl = 64
            test_frame2.ip_protocol = 0x11
            test_frame2.ip_header_checksum = None
            test_frame2.ip_source_ip = 0xc0a80164
            test_frame2.ip_dest_ip = 0xc0a80166
            test_frame2.udp_source_port = 1
            test_frame2.udp_dest_port = 2
            test_frame2.udp_length = None
            test_frame2.udp_checksum = None
            test_frame2.payload = bytearray(range(payload_len))
            test_frame2.build()

            test_frame1a = udp_ep.UDPFrame(test_frame1)
            test_frame1a.payload.data += bytearray(b'\x00')

            for wait in wait_normal, wait_pause_source, wait_pause_sink:
                source.send(test_frame1a)
                source.send(test_frame2)
                yield clk.posedge
                yield clk.posedge

                yield wait()

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame1

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame2

                assert sink.empty()

                yield delay(100)

            yield clk.posedge
            print("test 5: trailing bytes (10), length %d" % payload_len)
            current_test.next = 5

            test_frame1 = udp_ep.UDPFrame()
            test_frame1.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame1.eth_src_mac = 0x5A5152535455
            test_frame1.eth_type = 0x0800
            test_frame1.ip_version = 4
            test_frame1.ip_ihl = 5
            test_frame1.ip_length = None
            test_frame1.ip_identification = 0
            test_frame1.ip_flags = 2
            test_frame1.ip_fragment_offset = 0
            test_frame1.ip_ttl = 64
            test_frame1.ip_protocol = 0x11
            test_frame1.ip_header_checksum = None
            test_frame1.ip_source_ip = 0xc0a80164
            test_frame1.ip_dest_ip = 0xc0a80165
            test_frame1.udp_source_port = 1
            test_frame1.udp_dest_port = 2
            test_frame1.udp_length = None
            test_frame1.udp_checksum = None
            test_frame1.payload = bytearray(range(payload_len))
            test_frame1.build()
            test_frame2 = udp_ep.UDPFrame()
            test_frame2.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame2.eth_src_mac = 0x5A5152535455
            test_frame2.eth_type = 0x0800
            test_frame2.ip_version = 4
            test_frame2.ip_ihl = 5
            test_frame2.ip_length = None
            test_frame2.ip_identification = 0
            test_frame2.ip_flags = 2
            test_frame2.ip_fragment_offset = 0
            test_frame2.ip_ttl = 64
            test_frame2.ip_protocol = 0x11
            test_frame2.ip_header_checksum = None
            test_frame2.ip_source_ip = 0xc0a80164
            test_frame2.ip_dest_ip = 0xc0a80166
            test_frame2.udp_source_port = 1
            test_frame2.udp_dest_port = 2
            test_frame2.udp_length = None
            test_frame2.udp_checksum = None
            test_frame2.payload = bytearray(range(payload_len))
            test_frame2.build()

            test_frame1a = udp_ep.UDPFrame(test_frame1)
            test_frame1a.payload.data += bytearray(b'\x00'*10)

            for wait in wait_normal, wait_pause_source, wait_pause_sink:
                source.send(test_frame1a)
                source.send(test_frame2)
                yield clk.posedge
                yield clk.posedge

                yield wait()

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame1

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame2

                assert sink.empty()

                yield delay(100)

            yield clk.posedge
            print("test 6: trailing bytes with tuser assert (1), length %d" % payload_len)
            current_test.next = 6

            test_frame1 = udp_ep.UDPFrame()
            test_frame1.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame1.eth_src_mac = 0x5A5152535455
            test_frame1.eth_type = 0x0800
            test_frame1.ip_version = 4
            test_frame1.ip_ihl = 5
            test_frame1.ip_length = None
            test_frame1.ip_identification = 0
            test_frame1.ip_flags = 2
            test_frame1.ip_fragment_offset = 0
            test_frame1.ip_ttl = 64
            test_frame1.ip_protocol = 0x11
            test_frame1.ip_header_checksum = None
            test_frame1.ip_source_ip = 0xc0a80164
            test_frame1.ip_dest_ip = 0xc0a80165
            test_frame1.udp_source_port = 1
            test_frame1.udp_dest_port = 2
            test_frame1.udp_length = None
            test_frame1.udp_checksum = None
            test_frame1.payload = bytearray(range(payload_len))
            test_frame1.build()
            test_frame2 = udp_ep.UDPFrame()
            test_frame2.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame2.eth_src_mac = 0x5A5152535455
            test_frame2.eth_type = 0x0800
            test_frame2.ip_version = 4
            test_frame2.ip_ihl = 5
            test_frame2.ip_length = None
            test_frame2.ip_identification = 0
            test_frame2.ip_flags = 2
            test_frame2.ip_fragment_offset = 0
            test_frame2.ip_ttl = 64
            test_frame2.ip_protocol = 0x11
            test_frame2.ip_header_checksum = None
            test_frame2.ip_source_ip = 0xc0a80164
            test_frame2.ip_dest_ip = 0xc0a80166
            test_frame2.udp_source_port = 1
            test_frame2.udp_dest_port = 2
            test_frame2.udp_length = None
            test_frame2.udp_checksum = None
            test_frame2.payload = bytearray(range(payload_len))
            test_frame2.build()

            test_frame1a = udp_ep.UDPFrame(test_frame1)
            test_frame1a.payload.data += bytearray(b'\x00')
            test_frame1a.payload.user = 1

            for wait in wait_normal, wait_pause_source, wait_pause_sink:
                source.send(test_frame1a)
                source.send(test_frame2)
                yield clk.posedge
                yield clk.posedge

                yield wait()

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame1
                assert rx_frame.payload.user[-1]

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame2

                assert sink.empty()

                yield delay(100)

            yield clk.posedge
            print("test 7: trailing bytes with tuser assert (10), length %d" % payload_len)
            current_test.next = 7

            test_frame1 = udp_ep.UDPFrame()
            test_frame1.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame1.eth_src_mac = 0x5A5152535455
            test_frame1.eth_type = 0x0800
            test_frame1.ip_version = 4
            test_frame1.ip_ihl = 5
            test_frame1.ip_length = None
            test_frame1.ip_identification = 0
            test_frame1.ip_flags = 2
            test_frame1.ip_fragment_offset = 0
            test_frame1.ip_ttl = 64
            test_frame1.ip_protocol = 0x11
            test_frame1.ip_header_checksum = None
            test_frame1.ip_source_ip = 0xc0a80164
            test_frame1.ip_dest_ip = 0xc0a80165
            test_frame1.udp_source_port = 1
            test_frame1.udp_dest_port = 2
            test_frame1.udp_length = None
            test_frame1.udp_checksum = None
            test_frame1.payload = bytearray(range(payload_len))
            test_frame1.build()
            test_frame2 = udp_ep.UDPFrame()
            test_frame2.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame2.eth_src_mac = 0x5A5152535455
            test_frame2.eth_type = 0x0800
            test_frame2.ip_version = 4
            test_frame2.ip_ihl = 5
            test_frame2.ip_length = None
            test_frame2.ip_identification = 0
            test_frame2.ip_flags = 2
            test_frame2.ip_fragment_offset = 0
            test_frame2.ip_ttl = 64
            test_frame2.ip_protocol = 0x11
            test_frame2.ip_header_checksum = None
            test_frame2.ip_source_ip = 0xc0a80164
            test_frame2.ip_dest_ip = 0xc0a80166
            test_frame2.udp_source_port = 1
            test_frame2.udp_dest_port = 2
            test_frame2.udp_length = None
            test_frame2.udp_checksum = None
            test_frame2.payload = bytearray(range(payload_len))
            test_frame2.build()

            test_frame1a = udp_ep.UDPFrame(test_frame1)
            test_frame1a.payload.data += bytearray(b'\x00'*10)
            test_frame1a.payload.user = 1

            for wait in wait_normal, wait_pause_source, wait_pause_sink:
                source.send(test_frame1a)
                source.send(test_frame2)
                yield clk.posedge
                yield clk.posedge

                yield wait()

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame1
                assert rx_frame.payload.user[-1]

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame2

                assert sink.empty()

                yield delay(100)

            yield clk.posedge
            print("test 8: truncated payload (1), length %d" % payload_len)
            current_test.next = 8

            test_frame1 = udp_ep.UDPFrame()
            test_frame1.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame1.eth_src_mac = 0x5A5152535455
            test_frame1.eth_type = 0x0800
            test_frame1.ip_version = 4
            test_frame1.ip_ihl = 5
            test_frame1.ip_length = None
            test_frame1.ip_identification = 0
            test_frame1.ip_flags = 2
            test_frame1.ip_fragment_offset = 0
            test_frame1.ip_ttl = 64
            test_frame1.ip_protocol = 0x11
            test_frame1.ip_header_checksum = None
            test_frame1.ip_source_ip = 0xc0a80164
            test_frame1.ip_dest_ip = 0xc0a80165
            test_frame1.udp_source_port = 1
            test_frame1.udp_dest_port = 2
            test_frame1.udp_length = None
            test_frame1.udp_checksum = None
            test_frame1.payload = bytearray(range(payload_len+1))
            test_frame1.build()
            test_frame2 = udp_ep.UDPFrame()
            test_frame2.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame2.eth_src_mac = 0x5A5152535455
            test_frame2.eth_type = 0x0800
            test_frame2.ip_version = 4
            test_frame2.ip_ihl = 5
            test_frame2.ip_length = None
            test_frame2.ip_identification = 0
            test_frame2.ip_flags = 2
            test_frame2.ip_fragment_offset = 0
            test_frame2.ip_ttl = 64
            test_frame2.ip_protocol = 0x11
            test_frame2.ip_header_checksum = None
            test_frame2.ip_source_ip = 0xc0a80164
            test_frame2.ip_dest_ip = 0xc0a80166
            test_frame2.udp_source_port = 1
            test_frame2.udp_dest_port = 2
            test_frame2.udp_length = None
            test_frame2.udp_checksum = None
            test_frame2.payload = bytearray(range(payload_len))
            test_frame2.build()

            test_frame1a = udp_ep.UDPFrame(test_frame1)
            test_frame1a.payload.data = test_frame1a.payload.data[:-1]

            for wait in wait_normal, wait_pause_source, wait_pause_sink:
                error_payload_early_termination_asserted.next = 0

                source.send(test_frame1a)
                source.send(test_frame2)
                yield clk.posedge
                yield clk.posedge

                yield wait()

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert rx_frame.payload.user[-1]
                assert error_payload_early_termination_asserted

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame2

                assert sink.empty()

                yield delay(100)

            yield clk.posedge
            print("test 9: truncated payload (10), length %d" % payload_len)
            current_test.next = 9

            test_frame1 = udp_ep.UDPFrame()
            test_frame1.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame1.eth_src_mac = 0x5A5152535455
            test_frame1.eth_type = 0x0800
            test_frame1.ip_version = 4
            test_frame1.ip_ihl = 5
            test_frame1.ip_length = None
            test_frame1.ip_identification = 0
            test_frame1.ip_flags = 2
            test_frame1.ip_fragment_offset = 0
            test_frame1.ip_ttl = 64
            test_frame1.ip_protocol = 0x11
            test_frame1.ip_header_checksum = None
            test_frame1.ip_source_ip = 0xc0a80164
            test_frame1.ip_dest_ip = 0xc0a80165
            test_frame1.udp_source_port = 1
            test_frame1.udp_dest_port = 2
            test_frame1.udp_length = None
            test_frame1.udp_checksum = None
            test_frame1.payload = bytearray(range(payload_len+10))
            test_frame1.build()
            test_frame2 = udp_ep.UDPFrame()
            test_frame2.eth_dest_mac = 0xDAD1D2D3D4D5
            test_frame2.eth_src_mac = 0x5A5152535455
            test_frame2.eth_type = 0x0800
            test_frame2.ip_version = 4
            test_frame2.ip_ihl = 5
            test_frame2.ip_length = None
            test_frame2.ip_identification = 0
            test_frame2.ip_flags = 2
            test_frame2.ip_fragment_offset = 0
            test_frame2.ip_ttl = 64
            test_frame2.ip_protocol = 0x11
            test_frame2.ip_header_checksum = None
            test_frame2.ip_source_ip = 0xc0a80164
            test_frame2.ip_dest_ip = 0xc0a80166
            test_frame2.udp_source_port = 1
            test_frame2.udp_dest_port = 2
            test_frame2.udp_length = None
            test_frame2.udp_checksum = None
            test_frame2.payload = bytearray(range(payload_len))
            test_frame2.build()

            test_frame1a = udp_ep.UDPFrame(test_frame1)
            test_frame1a.payload.data = test_frame1.payload.data[:-10]

            for wait in wait_normal, wait_pause_source, wait_pause_sink:
                error_payload_early_termination_asserted.next = 0

                source.send(test_frame1a)
                source.send(test_frame2)
                yield clk.posedge
                yield clk.posedge

                yield wait()

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert rx_frame.payload.user[-1]
                assert error_payload_early_termination_asserted

                yield sink.wait()
                rx_frame = sink.recv()

                check_frame = udp_ep.UDPFrame()
                check_frame.parse_ip(rx_frame)

                assert check_frame == test_frame2

                assert sink.empty()

                yield delay(100)

        raise StopSimulation

    return instances()

def test_bench():
    sim = Simulation(bench())
    sim.run()

if __name__ == '__main__':
    print("Running test...")
    test_bench()


text:
/*************************************************************************/
/*  thread_posix.cpp                                                     */
/*************************************************************************/
/*                       This file is part of:                           */
/*                           GODOT ENGINE                                */
/*                    http://www.godotengine.org                         */
/*************************************************************************/
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.                 */
/*                                                                       */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the       */
/* "Software"), to deal in the Software without restriction, including   */
/* without limitation the rights to use, copy, modify, merge, publish,   */
/* distribute, sublicense, and/or sell copies of the Software, and to    */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions:                                             */
/*                                                                       */
/* The above copyright notice and this permission notice shall be        */
/* included in all copies or substantial portions of the Software.       */
/*                                                                       */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,       */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF    */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY  */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,  */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE     */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.                */
/*************************************************************************/
#include "thread_posix.h"

#if defined(UNIX_ENABLED) || defined(PTHREAD_ENABLED)

#include "os/memory.h"

Thread::ID ThreadPosix::get_ID() const {

	return id;
}

Thread* ThreadPosix::create_thread_posix() {

	return memnew( ThreadPosix );
}

void *ThreadPosix::thread_callback(void *userdata) {

	ThreadPosix *t=reinterpret_cast<ThreadPosix*>(userdata);
	t->callback(t->user);
	t->id=(ID)pthread_self();
	return NULL;
}

Thread* ThreadPosix::create_func_posix(ThreadCreateCallback p_callback,void *p_user,const Settings&) {

	ThreadPosix *tr= memnew(ThreadPosix);
	tr->callback=p_callback;
	tr->user=p_user;
	pthread_attr_init(&tr->pthread_attr);
	pthread_attr_setdetachstate(&tr->pthread_attr, PTHREAD_CREATE_JOINABLE);
	pthread_attr_setstacksize(&tr->pthread_attr, 256 * 1024);

	pthread_create(&tr->pthread, &tr->pthread_attr, thread_callback, tr);

	return tr;
}
Thread::ID ThreadPosix::get_thread_ID_func_posix() {

	return (ID)pthread_self();
}
void ThreadPosix::wait_to_finish_func_posix(Thread* p_thread) {

	ThreadPosix *tp=static_cast<ThreadPosix*>(p_thread);
	ERR_FAIL_COND(!tp);
	ERR_FAIL_COND(tp->pthread==0);

	pthread_join(tp->pthread,NULL);
	tp->pthread=0;
}

void ThreadPosix::make_default() {

	create_func=create_func_posix;
	get_thread_ID_func=get_thread_ID_func_posix;
	wait_to_finish_func=wait_to_finish_func_posix;

}

ThreadPosix::ThreadPosix() {

	pthread=0;
}

ThreadPosix::~ThreadPosix() {

}

#endif


text:
SPEC_ROOT = File.dirname(__FILE__)
$LOAD_PATH.unshift(SPEC_ROOT)
$LOAD_PATH.unshift(File.join(SPEC_ROOT, '..', 'lib'))
require 'pdfkit'
require 'rspec'
require 'rspec/autorun'
require 'mocha'
require 'rack'
require 'rack/test'
require 'active_support'
require 'custom_wkhtmltopdf_path' if File.exists?(File.join(SPEC_ROOT, 'custom_wkhtmltopdf_path.rb'))

RSpec.configure do |config|
  include Rack::Test::Methods
end


text:
      <appengine-stage-allocation-label allocation-description="$ctrl.allocationDescription">
      </appengine-stage-allocation-label>

        <input
          type="number"
          ng-model="$ctrl.allocationDescription.allocation"
          required
          class="form-control input-sm"
          min="0"
          ng-change="$ctrl.onAllocationChange()"
          max="100"
        />
        %

Locator

          <form>

                <input
                  type="radio"
                  ng-change="$ctrl.onLocatorTypeChange()"
                  ng-model="$ctrl.allocationDescription.locatorType"
                  value="fromExisting"
                />
                Existing server group

                <input
                  type="radio"
                  ng-change="$ctrl.onLocatorTypeChange()"
                  ng-model="$ctrl.allocationDescription.locatorType"
                  value="targetCoordinate"
                />
                Coordinates

                <input
                  type="radio"
                  ng-change="$ctrl.onLocatorTypeChange()"
                  ng-model="$ctrl.allocationDescription.locatorType"
                  value="text"
                />
                Text input

          </form>

Server group

            <ui-select
              ng-model="$ctrl.allocationDescription.serverGroupName"
              on-select="$ctrl.onAllocationChange()"
              class="form-control input-sm"
            >
              <ui-select-match placeholder="Select...">
                {{ $select.selected }}
              </ui-select-match>
              <ui-select-choices
                repeat="serverGroup as serverGroup in $ctrl.getServerGroupOptions() | filter: $select.search"
              >

              </ui-select-choices>
            </ui-select>

Cluster

            <cluster-selector
              class="small"
              clusters="$ctrl.clusterList"
              model="$ctrl.allocationDescription.cluster"
            ></cluster-selector>

Target

            <target-select model="$ctrl.allocationDescription" options="$ctrl.targets"></target-select>

            Text
            <help-field key="appengine.loadBalancer.textLocator"></help-field>

            <input class="form-control input-sm" type="text" ng-model="$ctrl.allocationDescription.serverGroupName" />


text:
FROM    centos:centos6

RUN     rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
RUN     yum install -y npm

# Register gusto source
COPY src /src
COPY package.json .
COPY gusto.js .

EXPOSE  8999

RUN     npm install -y

CMD ["node", "/gusto.js"]


text:
function checkPasswordMatch() {
    var password = $("#pass-field").val();
    var confirmPassword = $("#confirm-password").val();

    if (password != confirmPassword)
        $("#divCheckPasswordMatch").html("Passwords do not match!");
    else
        $("#divCheckPasswordMatch").html("");
}

function checkPasswordRequirements() {
  var password = $('#pass-field').val();
  if(password.length < 8) {
    $("#divCheckPasswordMatch").html("Password must be at least 8 characters!");
    return false;
  } else {
    $("#divCheckPasswordMatch").html("");
    return true;
  }
}

$(document).ready(function() {
  $('#confirm-password').keypress(function(e) {
      if ((e.keyCode || e.which) == 13) {
          $('#button-create').trigger('click');
      }
  });

  $("#confirm-password").keyup(checkPasswordMatch);
  $("#pass-field").keyup(checkPasswordRequirements);

  $('#button-create').on('click', function(e) {
    e.preventDefault();
    if(checkPasswordRequirements()){
      document.getElementById('login-form').submit();
    }
  });
});


text:
<?php

namespace AppBundle\DataFixtures\PHPCR;

use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ODM\PHPCR\DocumentManager;

use Symfony\Component\DependencyInjection\ContainerAware;

use PHPCR\Util\NodeHelper;
use AppBundle\Document\DemoNewsContent;

class LoadNewsData extends ContainerAware implements FixtureInterface, OrderedFixtureInterface
{
    public function getOrder()
    {
        return 50;
    }

    public function load(ObjectManager $manager)
    {
        if (!$manager instanceof DocumentManager) {
            $class = get_class($manager);
            throw new \RuntimeException("Fixture requires a PHPCR ODM DocumentManager instance, instance of '$class' given.");
        }

        $basePath = $this->container->getParameter('cmf_content.persistence.phpcr.content_basepath');
        $newsPath = $basePath . '/news';
        NodeHelper::createPath($manager->getPhpcrSession(), $newsPath);
        $newsRoot = $manager->find(null, $newsPath);

        $news = new DemoNewsContent();
        $news->setParentDocument($newsRoot);
        $news->setTitle('RoutingAutoBundle generates routes!');
        $news->setBody(<<<EOT
'This is a news item which demonstrates the routing auto bundle. The routing
auto bundle automatically creates routes for documents which are persisted.

See the routing auto configuration file to see how this works.
EOT
    );

        $manager->persist($news);
        $manager->flush();
    }
}