text:
<?php

namespace Kenjis\CI4Twig;

class TestCase extends \PHPUnit\Framework\TestCase
{
}

redpajama_set_name: RedPajamaGithub


text:
import { assert } from '@ember/debug';
import removeFromDOM from '../-private/utils/remove-from-dom';
import BaseAdapter from './base';

export default class Piwik extends BaseAdapter {
  toStringExtension() {
    return 'Piwik';
  }

  install() {
    const { piwikUrl, siteId } = this.config;

    assert(
      `[ember-metrics] You must pass a \`piwikUrl\` and a \`siteId\` to the ${this.toString()} adapter`,
      piwikUrl && siteId
    );

    this._injectScript(piwikUrl, siteId);
  }

  // prettier-ignore
  _injectScript(piwikUrl, siteId) {
    window._paq = window._paq || [];
    (function() {
      window._paq.push(['setTrackerUrl', `${piwikUrl}/piwik.php`]);
      window._paq.push(['setSiteId', siteId]);
      var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
      g.type='text/javascript'; g.async=true; g.defer=true; g.src=`${piwikUrl}/piwik.js`; s.parentNode.insertBefore(g,s);
    })();
  }

  identify(options = {}) {
    window._paq.push(['setUserId', options.userId]);
  }

  trackEvent(options = {}) {
    window._paq.push([
      'trackEvent',
      options.category,
      options.action,
      options.name,
      options.value,
    ]);
  }

  trackPage(options = {}) {
    window._paq.push(['setCustomUrl', options.page]);
    window._paq.push(['trackPageView', options.title]);
  }

  uninstall() {
    removeFromDOM('script[src*="piwik"]');

    delete window._paq;
  }
}


text:
<?php defined('SYSPATH') or die('No direct script access.');

return array(
    'Hello World' => 'Terve maailma',
);


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

namespace Demo
{

    [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    public struct ByteParam
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 200)]
        public byte[] aucParam;
    }

    [StructLayoutAttribute(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
    public struct CardDownData
    {
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 2)]
        public byte[] aucRespCode;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 60)]
        public byte[] aucRespInfo;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 12)]
        public byte[] aucAmount;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
        public byte[] aucTransDate;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 6)]
        public byte[] aucTransTime;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
        public byte[] aucOrderNo;
        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)]
        public byte[] aucReserve;
    }

    class Trans
    {
        [DllImport("DLL_BANKCOMM_INTERFACE.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int BANKCOMM_SetParam(int iParamIndex, string data);
        [DllImport("DLL_BANKCOMM_INTERFACE.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int BANKCOMM_Login(ref CardDownData szOut, string deviceID = null);
        [DllImport("DLL_BANKCOMM_INTERFACE.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int BANKCOMM_Purchase(int amount, string scancode, ref ByteParam detail, ref CardDownData szOut, string deviceID = null);
        [DllImport("DLL_BANKCOMM_INTERFACE.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int BANKCOMM_Query(string orderNo, ref CardDownData szOut, string deviceID = null);
        [DllImport("DLL_BANKCOMM_INTERFACE.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int BANKCOMM_Void(int amount, string orderNo, ref CardDownData szOut, string deviceID = null);
        [DllImport("DLL_BANKCOMM_INTERFACE.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int BANKCOMM_Refund(int amount, string orderNo, ref CardDownData szOut, string deviceID = null);
        [DllImport("DLL_BANKCOMM_INTERFACE.dll", CallingConvention = CallingConvention.StdCall)]
        private static extern int BANKCOMM_AutoPurchase(int amount, string scancode, ref ByteParam detail, int timeout, ref CardDownData szOut, string deviceID = null);

        public static void SetParam(int iParamIndex, String data)
        {
            BANKCOMM_SetParam(iParamIndex, data);
        }

        public static CardDownData Login()
        {
            CardDownData cardDownData = new CardDownData();
            BANKCOMM_Login(ref cardDownData);
            return cardDownData;
        }

        public static CardDownData Purchase(int amount, String channel, String detail, String authCode)
        {
            ByteParam byteDetail = new ByteParam();
            byte[] bsDetail = Encoding.UTF8.GetBytes(detail);
            byteDetail.aucParam = new byte[200];
            Array.Copy(bsDetail, byteDetail.aucParam, bsDetail.Length);
            CardDownData cardDownData = new CardDownData();
            BANKCOMM_Purchase(amount, channel+authCode, ref byteDetail, ref cardDownData);
            return cardDownData;
        }

        public static CardDownData Query(String orderNo)
        {
            CardDownData cardDownData = new CardDownData();
            BANKCOMM_Query(orderNo, ref cardDownData);
            return cardDownData;
        }

        public static CardDownData Void(int amount, String orderNo)
        {
            CardDownData cardDownData = new CardDownData();
            BANKCOMM_Void(amount, orderNo, ref cardDownData);
            return cardDownData;
        }

        public static CardDownData Refund(int amount, String orderNo)
        {
            CardDownData cardDownData = new CardDownData();
            BANKCOMM_Refund(amount, orderNo, ref cardDownData);
            return cardDownData;
        }

        public static CardDownData AutoPurchase(int amount, String channel, String detail, int timeout, String authCode, String deviceID)
        {
            ByteParam byteDetail = new ByteParam();
            byte[] bsDetail = Encoding.UTF8.GetBytes(detail);
            byteDetail.aucParam = new byte[200];
            Array.Copy(bsDetail, byteDetail.aucParam, bsDetail.Length);
            CardDownData cardDownData = new CardDownData();
            BANKCOMM_AutoPurchase(amount, channel+authCode, ref byteDetail, timeout, ref cardDownData, deviceID);
            return cardDownData;
        }
    }
}


text:
require 'spec_helper_rspec'

[:shield, :xpack].each do |provider|
  describe Puppet::Type.type(:elasticsearch_role_mapping).provider(provider) do
    describe 'instances' do
      it 'should have an instance method' do
        expect(described_class).to respond_to :instances
      end

      context 'with no roles' do
        it 'should return no resources' do
          expect(described_class.parse("\n")).to eq([])
        end
      end

      context 'with one role' do
        it 'should return one resource' do
          expect(described_class.parse(%q{
            admin:
              - "cn=users,dc=example,dc=com"
          })[0]).to eq({
            :ensure => :present,
            :name => 'admin',
            :mappings => [
              "cn=users,dc=example,dc=com"
            ]
          })
        end
      end

      context 'with multiple roles' do
        it 'should return three resources' do
          expect(described_class.parse(%q{
            admin:
              - "cn=users,dc=example,dc=com"
            user:
              - "cn=users,dc=example,dc=com"
              - "cn=admins,dc=example,dc=com"
              - "cn=John Doe,cn=other users,dc=example,dc=com"
            power_user:
              - "cn=admins,dc=example,dc=com"
          }).length).to eq(3)
        end
      end
    end # of describe instances

    describe 'prefetch' do
      it 'should have a prefetch method' do
        expect(described_class).to respond_to :prefetch
      end
    end
  end # of describe puppet type
end


text:
<?php

require_once 'Tests/TestDriver.php';

$suites = loadSuite();

// Create and run the user interface
$gui = new PHPUnit_GUI_HTML();
$gui->addSuites($suites);
$gui->show();

?>


text:
package org.eclipse.rdf4j.http.server;

import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.rdf4j.common.exception.ValidationException;
import org.eclipse.rdf4j.common.webapp.views.SimpleResponseView;
import org.eclipse.rdf4j.model.Model;
import org.eclipse.rdf4j.rio.RDFFormat;
import org.eclipse.rdf4j.rio.Rio;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

/**
 * Simple resolver for Exceptions: returns the correct response code and message to the client.
 *
 * @author Herko ter Horst
 */
public class ProtocolExceptionResolver implements HandlerExceptionResolver {

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@Override
	public ModelAndView resolveException(HttpServletRequest request, HttpServletResponse response, Object handler,
			Exception exception) {
		logger.debug("ProtocolExceptionResolver.resolveException() called");

		Map<String, Object> model = new HashMap<>();

		int statusCode = HttpServletResponse.SC_INTERNAL_SERVER_ERROR;
		String errMsg = exception.getMessage();

		if (exception instanceof HTTPException) {
			HTTPException httpExc = (HTTPException) exception;
			statusCode = httpExc.getStatusCode();

			if (exception instanceof ClientHTTPException) {
				logger.info("Client sent bad request ( " + statusCode + ")", exception);
			} else {
				logger.error("Error while handling request (" + statusCode + ")", exception);
			}
		} else {
			logger.error("Error while handling request", exception);
		}

		int depth = 10;
		Throwable temp = exception;
		while (!(temp instanceof ValidationException)) {
			if (depth-- == 0) {
				break;
			}
			if (temp == null) {
				break;
			}
			temp = temp.getCause();
		}

		if (temp instanceof ValidationException) {
			// This is currently just a simple fix that causes the validation report to be printed.
			// This should not be the final solution.
			Model validationReportModel = ((ValidationException) temp).validationReportAsModel();

			StringWriter stringWriter = new StringWriter();

			// We choose NQUADS because we want to support streaming in the future, and because there could be a use for
			// different graphs in the future
			Rio.write(validationReportModel, stringWriter, RDFFormat.NQUADS);

			statusCode = HttpServletResponse.SC_CONFLICT;
			errMsg = stringWriter.toString();

			Map<String, String> headers = new HashMap<>();
			headers.put("Content-Type", "application/shacl-validation-report+n-quads");
			model.put(SimpleResponseView.CUSTOM_HEADERS_KEY, headers);
		}

		model.put(SimpleResponseView.SC_KEY, statusCode);
		model.put(SimpleResponseView.CONTENT_KEY, errMsg);

		return new ModelAndView(SimpleResponseView.getInstance(), model);
	}
}


text:
namespace content {

class ServiceWorkerVersion;

// A helper class to dispatch fetch event to a service worker.
class CONTENT_EXPORT ServiceWorkerFetchDispatcher {
 public:
  typedef base::Callback<void(ServiceWorkerStatusCode,
                              ServiceWorkerFetchEventResult,
                              const ServiceWorkerResponse&,
                              const scoped_refptr<ServiceWorkerVersion>&)>
      FetchCallback;

  ServiceWorkerFetchDispatcher(
      std::unique_ptr<ServiceWorkerFetchRequest> request,
      ServiceWorkerVersion* version,
      ResourceType resource_type,
      const base::Closure& prepare_callback,
      const FetchCallback& fetch_callback);
  ~ServiceWorkerFetchDispatcher();

  // Dispatches a fetch event to the |version| given in ctor, and fires
  // |callback| (also given in ctor) when finishes.
  void Run();

 private:
  void DidWaitActivation();
  void DidFailActivation();
  void DispatchFetchEvent();
  void DidPrepare();
  void DidFail(ServiceWorkerStatusCode status);
  void DidFinish(int request_id,
                 ServiceWorkerFetchEventResult fetch_result,
                 const ServiceWorkerResponse& response);

  ServiceWorkerMetrics::EventType GetEventType() const;

  scoped_refptr<ServiceWorkerVersion> version_;
  base::Closure prepare_callback_;
  FetchCallback fetch_callback_;
  std::unique_ptr<ServiceWorkerFetchRequest> request_;
  ResourceType resource_type_;
  base::WeakPtrFactory<ServiceWorkerFetchDispatcher> weak_factory_;

  DISALLOW_COPY_AND_ASSIGN(ServiceWorkerFetchDispatcher);
};

}  // namespace content

#endif  // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_FETCH_DISPATCHER_H_


text:
@interface CMSelButton : UIButton
/// 选中计数
@property (nonatomic) NSInteger count;
@end


text:
import distutils.cmd
import os
import subprocess

from setuptools import find_packages, setup

class BaseCommand(distutils.cmd.Command):
    user_options = []

    def initialize_options(self):
        pass

    def finalize_options(self):
        pass

def create_command(text, commands):
    """Creates a custom setup.py command."""

    class CustomCommand(BaseCommand):
        description = text

        def run(self):
            for cmd in commands:
                subprocess.check_call(cmd)

    return CustomCommand

with open(
    os.path.join(os.path.dirname(__file__), "README.md"), encoding="utf-8"
) as readme:
    README = readme.read()

setup(
    name="django-localized-fields",
    version="6.6",
    packages=find_packages(exclude=["tests"]),
    include_package_data=True,
    license="MIT License",
    description="Implementation of localized model fields using PostgreSQL HStore fields.",
    long_description=README,
    long_description_content_type="text/markdown",
    url="https://github.com/SectorLabs/django-localized-fields",
    author="Sector Labs",
    author_email="open-source@sectorlabs.ro",
    keywords=[
        "django",
        "localized",
        "language",
        "models",
        "fields",
        "postgres",
        "hstore",
        "i18n",
    ],
    classifiers=[
        "Environment :: Web Environment",
        "Framework :: Django",
        "Intended Audience :: Developers",
        "License :: OSI Approved :: MIT License",
        "Operating System :: OS Independent",
        "Programming Language :: Python",
        "Programming Language :: Python :: 3.6",
        "Programming Language :: Python :: 3.7",
        "Programming Language :: Python :: 3.8",
        "Programming Language :: Python :: 3.9",
        "Topic :: Internet :: WWW/HTTP",
        "Topic :: Internet :: WWW/HTTP :: Dynamic Content",
    ],
    python_requires=">=3.6",
    install_requires=[
        "Django>=2.0",
        "django-postgres-extra>=2.0,<3.0",
        "deprecation==2.0.7",
    ],
    extras_require={
        ':python_version <= "3.6"': ["dataclasses"],
        "docs": ["Sphinx==2.2.0", "sphinx-rtd-theme==0.4.3"],
        "test": [
            "tox==3.14.3",
            "pytest==5.3.2",
            "pytest-django==3.7.0",
            "pytest-cov==2.8.1",
            "dj-database-url==0.5.0",
            "django-autoslug==1.9.6",
            "django-bleach==0.6.1",
            "psycopg2==2.8.4",
        ],
        "analysis": [
            "black==19.3b0",
            "flake8==3.7.7",
            "autoflake==1.3",
            "autopep8==1.4.4",
            "isort==4.3.20",
            "sl-docformatter==1.4",
        ],
    },
    cmdclass={
        "lint": create_command(
            "Lints the code",
            [["flake8", "setup.py", "localized_fields", "tests"]],
        ),
        "lint_fix": create_command(
            "Lints the code",
            [
                [
                    "autoflake",
                    "--remove-all-unused-imports",
                    "-i",
                    "-r",
                    "setup.py",
                    "localized_fields",
                    "tests",
                ],
                [
                    "autopep8",
                    "-i",
                    "-r",
                    "setup.py",
                    "localized_fields",
                    "tests",
                ],
            ],
        ),
        "format": create_command(
            "Formats the code",
            [["black", "setup.py", "localized_fields", "tests"]],
        ),
        "format_verify": create_command(
            "Checks if the code is auto-formatted",
            [["black", "--check", "setup.py", "localized_fields", "tests"]],
        ),
        "format_docstrings": create_command(
            "Auto-formats doc strings", [["docformatter", "-r", "-i", "."]]
        ),
        "format_docstrings_verify": create_command(
            "Verifies that doc strings are properly formatted",
            [["docformatter", "-r", "-c", "."]],
        ),
        "sort_imports": create_command(
            "Automatically sorts imports",
            [
                ["isort", "setup.py"],
                ["isort", "-rc", "localized_fields"],
                ["isort", "-rc", "tests"],
            ],
        ),
        "sort_imports_verify": create_command(
            "Verifies all imports are properly sorted.",
            [
                ["isort", "-c", "setup.py"],
                ["isort", "-c", "-rc", "localized_fields"],
                ["isort", "-c", "-rc", "tests"],
            ],
        ),
        "fix": create_command(
            "Automatically format code and fix linting errors",
            [
                ["python", "setup.py", "format"],
                ["python", "setup.py", "format_docstrings"],
                ["python", "setup.py", "sort_imports"],
                ["python", "setup.py", "lint_fix"],
            ],
        ),
        "verify": create_command(
            "Verifies whether the code is auto-formatted and has no linting errors",
            [
                ["python", "setup.py", "format_verify"],
                ["python", "setup.py", "format_docstrings_verify"],
                ["python", "setup.py", "sort_imports_verify"],
                ["python", "setup.py", "lint"],
            ],
        ),
        "test": create_command(
            "Runs all the tests",
            [
                [
                    "pytest",
                    "--cov=localized_fields",
                    "--cov-report=term",
                    "--cov-report=xml:reports/xml",
                    "--cov-report=html:reports/html",
                    "--junitxml=reports/junit/tests.xml",
                    "--reuse-db",
                ]
            ],
        ),
    },
)


text:
How to run GermaNER:

###  From Commandline

* Download the jar file from [here](https://github.com/tudarmstadt-lt/GermaNER/releases/download/germaNER0.9.1/GermaNER-09-09-2015.jar) or if you don't have enough memory, use GermaNER without freebase features from [here] (https://github.com/tudarmstadt-lt/GermaNER/releases/download/germaNER0.9.1/GermaNER-nofb-09-09-2015.jar) -> the corresponding configuration file is found [here](https://github.com/tudarmstadt-lt/GermaNER/releases/download/germaNER0.9.1/config-nofreebase.properties)
* Download the configuration file from [here](https://github.com/tudarmstadt-lt/GermaNER/releases/download/germaNER0.9.1/config.properties)
* Download a test file [here](https://github.com/tudarmstadt-lt/GermaNER/releases/download/germaNER0.9.1/test_de.tsv)
* Download a training file [here](https://github.com/tudarmstadt-lt/GermaNER/releases/download/germaNER0.9.1/full_train.tsv)
* To test a file that was trained on our model, run as follows:
   * `java -jar GermaNER-09-09-2015.jar -t TESTFILE -o OUTPUTFILE`

 where `-t TESTFILE` is the document to be tagged and  `-o OUTFILE`  is name of the tagged output file,
However, if you want to test one of your own models, add the `-c CONFIGFILE` and `-d OUTPUTFOLDER` which are the configuration file used for training and the directory of the saved GermaNER model directory name respectively.
* To train (and optionally test) a model, run it as follows
   * `java -jar GermaNER-09-09-2015.jar -f TRAINFILE -t TESTFILE -o OUTPUTFILE -c CONFIGFILE -d OUTPUTFOLDER`

 Where `-t TESTFILE`, `-o OUTPUTFILE`, and `-c CONFIGFILE` are optional parameters.  `-t TESTFILE` is the document to be tagged,` -f TRAINFILE ` is the training data, as explained [here] (https://github.com/tudarmstadt-lt/GermaNER/wiki/File-Format), `-o OUTPUTFILE` is the tagged output file, and `-c CONFIGFILE` is the configuration file as explained [here](https://github.com/tudarmstadt-lt/GermaNER/wiki/Configuration-File) and `-d OUTPUTFOLDER` is the directory where the model will be saved (if`-d `is not provided, a folder called `output` will be created and the model will be stored therein.)
* To tag your document, the document format should be as it is explained here, run it as follows
###  Inside an application

  TODO

###  From source
* Get the source code of [GermaNER](https://github.com/tudarmstadt-lt/GermaNER) using git

    `git clone https://github.com/tudarmstadt-lt/GermaNER.git`

* Compile GermaNER using the following command

   `mvn clean install -Dmaven.test.skip=true`

The generated jar will be available under the **target** folder


text:
<?php

namespace Oro\Bundle\EntityBundle\Helper;

use Doctrine\ORM\Mapping\ClassMetadata;

use Rhumsaa\Uuid\Console\Exception;

use Symfony\Component\PropertyAccess\PropertyAccess;

class DictionaryHelper
{
    /** @var \Symfony\Component\PropertyAccess\PropertyAccessor */
    protected $accessor;

    public function __construct()
    {
        $this->accessor = PropertyAccess::createPropertyAccessor();
    }

    /**
     * @param ClassMetadata $metadata
     * @return mixed
     */
    public function getNamePrimaryKeyField(ClassMetadata $metadata)
    {
        $idNames = $metadata->getIdentifierFieldNames();
        if (count($idNames) !== 1) {
            throw new Exception('Primary key for this entity is absent or contains few fields');
        }
        return $idNames[0];
    }

    /**
     * @param ClassMetadata $meteData
     * @return string
     */
    public function getNameLabelField(ClassMetadata $meteData)
    {
        $fieldNames = $meteData->getFieldNames();
        if (in_array('label', $fieldNames)) {
            return 'label';
        }

        return 'name';
    }
}


text:
/*****************************************************************************/
/**
*
* @file xil_io.c
*
* Contains I/O functions for memory-mapped architectures.  These functions
* encapsulate generic CPU I/O requirements.
*
* <pre>
* MODIFICATION HISTORY:
*
* Ver   Who  Date	 Changes
* ----- ---- -------- -------------------------------------------------------
* 3.00a hbm  07/28/09 Initial release
* 3.00a hbm  07/21/10 Added Xil_EndianSwap32/16, Xil_Htonl/s, Xil_Ntohl/s
* 5.4   sk   01/14/16 Changed xil_io() and xil_out() functions to static inline
*                     functions.
*
* </pre>
*
* @note
*
* This file may contain architecture-dependent code.
*
******************************************************************************/

/***************************** Include Files *********************************/

#include "xil_io.h"
#include "xil_types.h"

/************************** Constant Definitions *****************************/

/**************************** Type Definitions *******************************/

/***************** Macros (Inline Functions) Definitions *********************/

/************************** Function Prototypes ******************************/

/***************** Macros (Inline Functions) and Functions Definitions *******/

/*****************************************************************************/
/**
*
* Perform a 16-bit endian converion.
*
* @param	Data contains the value to be converted.
*
* @return	converted value.
*
* @note		None.
*
******************************************************************************/
u16 Xil_EndianSwap16(u16 Data)
{
	return (u16) (((Data & 0xFF00U) >> 8U) | ((Data & 0x00FFU) << 8U));
}

/*****************************************************************************/
/**
*
* Perform a 32-bit endian converion.
*
* @param	Data contains the value to be converted.
*
* @return	converted value.
*
* @note		None.
*
******************************************************************************/
u32 Xil_EndianSwap32(u32 Data)
{
	u16 LoWord;
	u16 HiWord;

	/* get each of the half words from the 32 bit word */

	LoWord = (u16) (Data & 0x0000FFFFU);
	HiWord = (u16) ((Data & 0xFFFF0000U) >> 16U);

	/* byte swap each of the 16 bit half words */

	LoWord = (((LoWord & 0xFF00U) >> 8U) | ((LoWord & 0x00FFU) << 8U));
	HiWord = (((HiWord & 0xFF00U) >> 8U) | ((HiWord & 0x00FFU) << 8U));

	/* swap the half words before returning the value */

	return ((((u32)LoWord) << (u32)16U) | (u32)HiWord);
}

/*****************************************************************************/
/**
*
* Perform a little-endian input operation for a 16-bit memory location
* by reading from the specified address and returning the byte-swapped value
* read from that address.
*
* @param	Addr contains the address to perform the input operation at.
*
* @return	The value read from the specified input address with the
*		proper endianness. The return value has the same endianness
*		as that of the processor, i.e. if the processor is big-engian,
*		the return value is the byte-swapped value read from the
*		address.
*
*
* @note		None.
*
******************************************************************************/
#ifndef __LITTLE_ENDIAN__
u16 Xil_In16LE(UINTPTR Addr)
#else
u16 Xil_In16BE(UINTPTR Addr)
#endif
{
	u16 Value;

	/* get the data then swap it */
	Value = Xil_In16(Addr);

	return Xil_EndianSwap16(Value);
}

/*****************************************************************************/
/**
*
* Perform a little-endian input operation for a 32-bit memory location
* by reading from the specified address and returning the byte-swapped value
* read from that address.
*
* @param	Addr contains the address to perform the input operation at.
*
* @return	The value read from the specified input address with the
*		proper endianness. The return value has the same endianness
*		as that of the processor, i.e. if the processor is big-engian,
*		the return value is the byte-swapped value read from the
*		address.
*
* @note		None.
*
******************************************************************************/
#ifndef __LITTLE_ENDIAN__
u32 Xil_In32LE(UINTPTR Addr)
#else
u32 Xil_In32BE(UINTPTR Addr)
#endif
{
	u32 InValue;

	/* get the data then swap it */
	InValue = Xil_In32(Addr);
	return Xil_EndianSwap32(InValue);
}

/*****************************************************************************/
/**
*
* Perform a little-endian output operation for a 16-bit memory location by
* writing the specified value to the the specified address. The value is
* byte-swapped before being written.
*
* @param	Addr contains the address to perform the output operation at.
* @param	Value contains the value to be output at the specified address.
*		The value has the same endianness as that of the processor.
*		If the processor is big-endian, the byte-swapped value is
*		written to the address.
*
* @return	None.
*
* @note		None.
*
******************************************************************************/
#ifndef __LITTLE_ENDIAN__
void Xil_Out16LE(UINTPTR Addr, u16 Value)
#else
void Xil_Out16BE(UINTPTR Addr, u16 Value)
#endif
{
	u16 OutValue;

	/* swap the data then output it */
	OutValue = Xil_EndianSwap16(Value);

	Xil_Out16(Addr, OutValue);
}

/*****************************************************************************/
/**
*
* Perform a little-endian output operation for a 32-bit memory location
* by writing the specified value to the the specified address. The value is
* byte-swapped before being written.
*
* @param	Addr contains the address at which the output operation at.
* @param	Value contains the value to be output at the specified address.
*		The value has the same endianness as that of the processor.
*		If the processor is big-endian, the byte-swapped value is
*		written to the address.
*
* @return	None.
*
* @note		None.
*
******************************************************************************/
#ifndef __LITTLE_ENDIAN__
void Xil_Out32LE(UINTPTR Addr, u32 Value)
#else
void Xil_Out32BE(UINTPTR Addr, u32 Value)
#endif
{
	u32 OutValue;

	/* swap the data then output it */
	OutValue = Xil_EndianSwap32(Value);
	Xil_Out32(Addr, OutValue);
}


text:
Please take a moment to review this document in order to make the contribution
process easy and effective for everyone involved.

Following these guidelines helps to communicate that you respect the time of
the developers managing and developing this open source project. In return,
they should reciprocate that respect in addressing your issue, assessing
changes, and helping you finalize your pull requests.

As for everything else in the project, the contributions are governed by our
[Code of Conduct](Code_of_Conduct.md).

## Using the issue tracker

First things first: **Do NOT report security vulnerabilities in public issues!**
Please disclose responsibly by letting
[us](mailto:public@asciidisco.com?subject=TelekomPluginSecurity) know upfront.
We will assess the issue as soon as possible on a best-effort basis and will
give you an estimate for when we have a fix and release available for an
eventual public disclosure.

The issue tracker is the preferred channel for [bug reports](#bugs),
[features requests](#features) and [submitting pull
requests](#pull-requests), but please respect the following restrictions:

* Please **do not** use the issue tracker for personal support requests.

* Please **do not** derail or troll issues. Keep the discussion on topic and
  respect the opinions of others.

## Bug reports

A bug is a _demonstrable problem_ that is caused by the code in the repository.
Good bug reports are extremely helpful - thank you!

Guidelines for bug reports:

* **Use the GitHub issue search** — check if the issue has already been reported.
* **Check if the issue has been fixed** — try to reproduce it using `master`.
* **Isolate the problem** — ideally create a reduced test case.

A good bug report shouldn't leave others needing to chase you up for more
information. Please try to be as detailed as possible in your report. What is
your environment? What steps will reproduce the issue? What OS experiences the
problem? What would you expect to be the outcome? All these details will help
people to fix any potential bugs.

Example:

> Short and descriptive example bug report title
>
> A summary of the issue and the Kodi & the OS/Processor Arch
> environment in which it occurs. If
> suitable, include the steps required to reproduce the bug.
>
> `This is the first step`
> `This is the second step`
> `Further steps, etc.`
>
> `<log>` - a link to the Kodi debug log
>
> Any other information you want to share that is relevant to the issue being
> reported. This might include the lines of code that you have identified as
> causing the bug, and potential solutions (and your opinions on their
> merits).

## Feature requests

Feature requests are welcome. But take a moment to find out whether your idea
fits with the scope and aims of the project. It's up to *you* to make a strong
case to convince the project's developers of the merits of this feature. Please
provide as much detail and context as possible.

## Pull requests

Good pull requests - patches, improvements, new features - are a fantastic
help. They should remain focused in scope and avoid containing unrelated
commits.

**Please ask first** before embarking on any significant pull request (e.g.
implementing features, refactoring code), otherwise you risk spending a lot of
time working on something that the project's developers might not want to merge
into the project.

### For new Contributors

If you never created a pull request before, welcome :tada: :smile:
[Here is a great tutorial](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github)
on how to send one :)

* [Fork](http://help.github.com/fork-a-repo/), clone, and configure the remotes:

```bash
# Clone your fork of the repo into the current directory
git clone https://github.com/<your-username>/<repo-name>
# Navigate to the newly cloned directory
cd <repo-name>
# Assign the original repo to a remote called "upstream"
git remote add upstream https://github.com/asciidisco/plugin.video.telekom-sport
```

* If you cloned a while ago, get the latest changes from upstream:

   ```bash
   git checkout master
   git pull upstream master
   ```

* Create a new topic branch (off the main project development branch) to
   contain your feature, change, or fix:

   ```bash
   git checkout -b <topic-branch-name>
   ```

* Make sure to update, or add to the tests when appropriate. Patches and
   features will not be accepted without tests. Run `make test` to check that
   all tests pass after you've made changes.Run `make lint` to ensure
   that your code meets our guildelines (PEP-8)

* If you added or changed a feature, make sure to document it accordingly in
   the `README.md` file.

* Push your topic branch up to your fork:

   ```bash
   git push origin <topic-branch-name>
   ```

* Note: We follow Angular style commit guildelines

  Best to install NodeJS & use commitizen for that, all you need to do is

   ```bash
   npm install
   ```

   initially in the root directiory & then use

   ```bash
   make commit
   ```

   to commit changes.

* [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
    with a clear title and description.

### Addendum

Optionally, you can help us with these things. But don't worry if they are too
complicated, we can help you out and teach you as we go :)

* Update your branch to the latest changes in the upstream master branch. You
   can do that locally with

   ```bash
   git pull --rebase upstream master
   ```

   Afterwards force push your changes to your remote feature branch.

* Once a pull request is good to go, you can tidy up your commit messages using
   Git's [interactive rebase](https://help.github.com/articles/interactive-rebase).
   Please follow our commit message conventions shown below, as they are used by
   [semantic-release](https://github.com/semantic-release/semantic-release) to
   automatically determine the new version and release to npm. In a nutshell:

#### Commit Message Conventions

* Commit test files with `test: ...` or `test(scope): ...` prefix
* Commit bug fixes with `fix: ...` or `fix(scope): ...` prefix
* Commit breaking changes by adding `BREAKING CHANGE:` in the commit body
    (not the subject line)
* Commit changes to `package.json`, `.gitignore` and other meta files with
    `chore(filenamewithoutext): ...`
* Commit changes to README files or comments with `docs: ...`
* Cody style changes with `style: standard`

**IMPORTANT**: By submitting a patch, you agree to license your work under the
same license as that used by the project.

## Maintainers

If you have commit access, please follow this process for
merging patches and cutting new releases.

### Reviewing changes

* Check that a change is within the scope and philosophy of the component.
* Check that a change has any necessary tests.
* Check that a change has any necessary documentation.
* If there is anything you don't like, leave a comment below the respective
   lines and submit a "Request changes" review. Repeat until everything has
   been addressed.
* If you are not sure about something, mention `@asciidisco` or specific
   people for help in a comment.
* If there is only a tiny change left before you can merge it and you think
   it's best to fix it yourself, you can directly commit to the author's fork.
   Leave a comment about it so the author and others will know.
* Once everything looks good, add an "Approve" review. Don't forget to say
   something nice 👏🐶💖✨
* If the commit messages follow [our conventions](@commit-message-conventions)

* If there is a breaking change, make sure that `BREAKING CHANGE:` with
    _exactly_ that spelling (incl. the ":") is in body of the according
    commit message. This is _very important_, better look twice :)
* Make sure there are `fix: ...` or `feat: ...` commits depending on whether
    a bug was fixed or a feature was added. **Gotcha:** look for spaces before
    the prefixes of `fix:` and `feat:`, these get ignored by semantic-release.
* Use the "Rebase and merge" button to merge the pull request.
* Done! You are awesome! Thanks so much for your help 🤗

* If the commit messages _do not_ follow our conventions

* Use the "squash and merge" button to clean up the commits and merge at
    the same time: ✨🎩
* Is there a breaking change? Describe it in the commit body. Start with
    _exactly_ `BREAKING CHANGE:` followed by an empty line. For the commit
    subject:
* Was a new feature added? Use `feat: ...` prefix in the commit subject
* Was a bug fixed? Use `fix: ...` in the commit subject

Sometimes there might be a good reason to merge changes locally. The process
looks like this:

### Reviewing and merging changes locally

```bash
git checkout master # or the main branch configured on github
git pull # get latest changes
git checkout feature-branch # replace name with your branch
git rebase master
git checkout master
git merge feature-branch # replace name with your branch
git push
```

When merging PRs from forked repositories, we recommend you install the
[hub](https://github.com/github/hub) command line tools.

This allows you to do:

```bash
hub checkout link-to-pull-request
```

meaning that you will automatically check out the branch for the pull request,
without needing any other steps like setting git upstreams! :sparkles:


text:
<?xml version="1.0" encoding="UTF-8"?>
<resourceInfo xmlns="http://www.ilsp.gr/META-XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.ilsp.gr/META-XMLSchema http://metashare.ilsp.gr/META-XMLSchema/v3.0/META-SHARE-Resource.xsd">
      <identificationInfo>
        <resourceName lang="en">Database of Bulgarian sentences</resourceName>
        <description lang="en">A set of Bulgarian sentences from news web portals, grammatically checked and corrected.</description>
        <metaShareId>NOT_DEFINED_FOR_V2</metaShareId>
      </identificationInfo>
      <distributionInfo>
        <availability>available-restrictedUse</availability>
          <licenceInfo>
            <licence>proprietary</licence>
            <downloadLocation>http://lrt.ilsp.gr:8081/data/BulgarianCorpusSentencesDatabase.rar</downloadLocation>
          </licenceInfo>
      </distributionInfo>
      <contactPerson>
        <surname lang="en">Raptis</surname>
        <givenName lang="en">Spyros</givenName>
        <sex>male</sex>
          <communicationInfo>
            <email>spy@ilsp.athena-innovation.gr</email>
            <url>http://www.ilsp.gr/index.php?option=com_jresearch&view=member&task=show&id=53&Itemid=156</url>
            <telephoneNumber>+302106875407</telephoneNumber>
            <faxNumber>+302106854270</faxNumber>
          </communicationInfo>
        <position>Principal Researcher</position>
          <affiliation>
            <organizationName lang="en">Institute for Language and Speech Processing / Athena R.C.</organizationName>
            <organizationShortName lang="en">ILSP / Athena R.C.</organizationShortName>
              <communicationInfo>
                <email>www@ilsp.athena-innovation.gr</email>
                <url>http://www.ilsp.gr/</url>
                <address>Artemidos 6 & Epidavrou</address>
                <zipCode>GR-15125</zipCode>
                <city>Maroussi</city>
                <country>GR</country>
                <telephoneNumber>+302106875300</telephoneNumber>
                <faxNumber>+302106854270</faxNumber>
                <faxNumber>+302106856794</faxNumber>
              </communicationInfo>
          </affiliation>
      </contactPerson>
      <contactPerson>
        <surname lang="en">Chalamandaris</surname>
        <givenName lang="en">Aimilios</givenName>
        <sex>male</sex>
          <communicationInfo>
            <email>achalam@ilsp.athena-innovation.gr</email>
            <url>http://www.ilsp.gr/index.php?option=com_jresearch&view=member&task=show&id=69&Itemid=156</url>
            <telephoneNumber>+302106875406</telephoneNumber>
            <faxNumber>+302106854270</faxNumber>
          </communicationInfo>
        <position>Scientific Associate</position>
          <affiliation>
            <organizationName lang="en">Institute for Language and Speech Processing / Athena R.C.</organizationName>
            <organizationShortName lang="en">ILSP / Athena R.C.</organizationShortName>
              <communicationInfo>
                <email>www@ilsp.athena-innovation.gr</email>
                <url>http://www.ilsp.gr/</url>
                <address>Artemidos 6 & Epidavrou</address>
                <zipCode>GR-15125</zipCode>
                <city>Maroussi</city>
                <country>GR</country>
                <telephoneNumber>+302106875300</telephoneNumber>
                <faxNumber>+302106854270</faxNumber>
                <faxNumber>+302106856794</faxNumber>
              </communicationInfo>
          </affiliation>
      </contactPerson>
      <metadataInfo>
        <metadataCreationDate>2012-02-02</metadataCreationDate>
          <metadataCreator>
            <surname lang="en">Desipri</surname>
            <givenName lang="en">Elina</givenName>
            <sex>female</sex>
              <communicationInfo>
                <email>elina@ilsp.athena-innovation.gr</email>
                <url>http://www.ilsp.gr/index.php?option=com_jresearch&view=member&task=show&id=23&Itemid=156</url>
                <telephoneNumber>+302106875442</telephoneNumber>
                <faxNumber>+302106854270</faxNumber>
                <faxNumber>+302106856794</faxNumber>
              </communicationInfo>
            <position>Scientific Associate</position>
              <affiliation>
                <organizationName lang="en">Institute for Language and Speech Processing / Athena R.C.</organizationName>
                <organizationShortName lang="en">ILSP / Athena R.C.</organizationShortName>
                  <communicationInfo>
                    <email>www@ilsp.athena-innovation.gr</email>
                    <url>http://www.ilsp.gr/</url>
                    <address>Artemidos 6 & Epidavrou</address>
                    <zipCode>GR-15125</zipCode>
                    <city>Maroussi</city>
                    <country>GR</country>
                    <telephoneNumber>+302106875300</telephoneNumber>
                    <faxNumber>+302106854270</faxNumber>
                    <faxNumber>+302106856794</faxNumber>
                  </communicationInfo>
              </affiliation>
          </metadataCreator>
        <source>META-SHARE/ILSP</source>
        <metadataLastDateUpdated>2012-05-14</metadataLastDateUpdated>
      </metadataInfo>
      <versionInfo>
        <version>1</version>
      </versionInfo>
      <validationInfo>
        <validated>true</validated>
        <validationType>content</validationType>
        <validationMode>mixed</validationMode>
        <validationExtent>full</validationExtent>
          <validator>
              <organizationInfo>
                <organizationName lang="en">Institute for Language and Speech Processing / Athena R.C.</organizationName>
                <organizationShortName lang="en">ILSP / Athena R.C.</organizationShortName>
                  <communicationInfo>
                    <email>www@ilsp.athena-innovation.gr</email>
                    <url>http://www.ilsp.gr/</url>
                    <address>Artemidos 6 & Epidavrou</address>
                    <zipCode>GR-15125</zipCode>
                    <city>Maroussi</city>
                    <country>GR</country>
                    <telephoneNumber>+302106875300</telephoneNumber>
                    <faxNumber>+302106854270</faxNumber>
                    <faxNumber>+302106856794</faxNumber>
                  </communicationInfo>
              </organizationInfo>
          </validator>
      </validationInfo>
      <usageInfo>
          <foreseenUseInfo>
            <foreseenUse>nlpApplications</foreseenUse>
            <useNLPSpecific>speechSynthesis</useNLPSpecific>
          </foreseenUseInfo>
          <actualUseInfo>
            <actualUse>nlpApplications</actualUse>
            <useNLPSpecific>speechSynthesis</useNLPSpecific>
          </actualUseInfo>
      </usageInfo>
      <resourceDocumentationInfo>
          <documentation>
              <documentInfo>
                <documentType>inProceedings</documentType>
                <title lang="und">Design of an Efficient Corpus for High-Quality Unit Selection TTS for Bulgarian</title>
                <author>Χαλαμανδάρης, Α., Τσιάκουλης, Π., Ράπτης, Σ. & Καραμπέτσος, Σ.</author>
                <year>2009</year>
                <bookTitle>Proc. 4th Language & Technology Conference: Human Language Technologies as a Challenge for Computer Science and Linguistics</bookTitle>
                <conference>TSD 2009</conference>
              </documentInfo>
          </documentation>
      </resourceDocumentationInfo>
      <resourceCreationInfo>
          <fundingProject>
            <projectName lang="und">Transfer and Adaptation of Text-to-Speech Technology to the Bulgarian Language and its Application in Cultural Tools with Emphasis on Accessibility</projectName>
            <fundingType>euFunds</fundingType>
            <funder>	INTERREG IIIA / PHARE CBC GREECE – BULGARIA </funder>
            <fundingCountry>Greece</fundingCountry>
            <projectStartDate>2005-10-01</projectStartDate>
            <projectEndDate>2007-09-30</projectEndDate>
          </fundingProject>
      </resourceCreationInfo>
      <resourceComponentType>
          <corpusInfo>
            <resourceType>corpus</resourceType>
              <corpusMediaType>
                  <corpusTextInfo>
                    <mediaType>text</mediaType>
                      <lingualityInfo>
                        <lingualityType>monolingual</lingualityType>
                      </lingualityInfo>
                      <languageInfo>
                        <languageId>bg</languageId>
                        <languageName>Bulgarian</languageName>
                      </languageInfo>
                      <modalityInfo>
                        <modalityType>writtenLanguage</modalityType>
                      </modalityInfo>
                      <sizeInfo>
                        <size>2577</size>
                        <sizeUnit>entries</sizeUnit>
                      </sizeInfo>
                      <textFormatInfo>
                        <mimeType>txt/plain</mimeType>
                      </textFormatInfo>
                      <characterEncodingInfo>
                        <characterEncoding>UTF-8</characterEncoding>
                      </characterEncodingInfo>
                      <domainInfo>
                        <domain>general</domain>
                      </domainInfo>
                      <textClassificationInfo>
                        <subject_topic>news</subject_topic>
                      </textClassificationInfo>
                      <creationInfo>
                          <originalSource>
                            <targetResourceNameURI>web news</targetResourceNameURI>
                          </originalSource>
                        <creationMode>mixed</creationMode>
                      </creationInfo>
                  </corpusTextInfo>
              </corpusMediaType>
          </corpusInfo>
      </resourceComponentType>
  </resourceInfo>


text:
<?xml version="1.0" encoding="UTF-8"?>
<test-set xmlns="http://www.w3.org/2010/09/qt-fots-catalog"
          name="op-multiply-yearMonthDuration">
   <description>Tests for the multiply-yearMonthDuration() function</description>
   <link type="spec" document="http://www.w3.org/TR/xpath-functions-30/"
         idref="func-multiply-yearMonthDuration"/>
   <test-case name="op-multiply-yearMonthDuration2args-1">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration2args-1
Written By: Carmelo Montanez
Date: Tue Apr 12 16:29:08 GMT-05:00 2005
Purpose: Evaluates The "op:multiply-yearMonthDuration" operator
 with the arguments set as follows:
$arg1 = xs:yearMonthDuration(lower bound)
$arg2 = xs:double(lower bound)
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2004-12-13"/>
      <test>xs:yearMonthDuration("P0Y0M") * xs:double("-1.7976931348623157E308")</test>
      <result>
         <assert-string-value>P0M</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration2args-2">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration2args-2
Written By: Carmelo Montanez
Date: Tue Apr 12 16:29:08 GMT-05:00 2005
Purpose: Evaluates The "op:multiply-yearMonthDuration" operator
 with the arguments set as follows:
$arg1 = xs:yearMonthDuration(mid range)
$arg2 = xs:double(lower bound)
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2004-12-13"/>
      <test>xs:yearMonthDuration("P1000Y6M") * xs:double("-0")</test>
      <result>
         <assert-string-value>P0M</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration2args-3">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration2args-3
Written By: Carmelo Montanez
Date: Tue Apr 12 16:29:08 GMT-05:00 2005
Purpose: Evaluates The "op:multiply-yearMonthDuration" operator
 with the arguments set as follows:
$arg1 = xs:yearMonthDuration(upper bound)
$arg2 = xs:double(lower bound)
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2004-12-13"/>
      <test>xs:yearMonthDuration("P2030Y12M") * xs:double("-0")</test>
      <result>
         <assert-string-value>P0M</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration2args-4">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration2args-4
Written By: Carmelo Montanez
Date: Tue Apr 12 16:29:08 GMT-05:00 2005
Purpose: Evaluates The "op:multiply-yearMonthDuration" operator
 with the arguments set as follows:
$arg1 = xs:yearMonthDuration(lower bound)
$arg2 = xs:double(mid range)
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2004-12-13"/>
      <test>xs:yearMonthDuration("P0Y0M") * xs:double("0")</test>
      <result>
         <assert-string-value>P0M</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration2args-5">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration2args-5
Written By: Carmelo Montanez
Date: Tue Apr 12 16:29:08 GMT-05:00 2005
Purpose: Evaluates The "op:multiply-yearMonthDuration" operator
 with the arguments set as follows:
$arg1 = xs:yearMonthDuration(lower bound)
$arg2 = xs:double(upper bound)
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2004-12-13"/>
      <test>xs:yearMonthDuration("P0Y0M") * xs:double("1.7976931348623157E308")</test>
      <result>
         <assert-string-value>P0M</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-1">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-1
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function
As per example 1 (for this function)of the F&O specs.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>xs:yearMonthDuration("P2Y11M") * 2.3</test>
      <result>
         <assert-string-value>P6Y9M</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-2">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-2
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function
used as part of a boolean expression (and operator) and the "fn:false" function.
 Apply "fn:string" function to account for new EBV.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>fn:string((xs:yearMonthDuration("P10Y11M")) * 2.0) and fn:false()</test>
      <result>
         <assert-false/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-3">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-3
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function as
part of a boolean expression (or operator) and the "fn:boolean" function.
 Apply "fn:string" function to account for new EBV.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>fn:string((xs:yearMonthDuration("P20Y10M") * 2.0)) or fn:false()</test>
      <result>
         <assert-true/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-4">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-4
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function that
return true and used together with fn:not.
 Apply "fn:string" function to account for new EBV.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>fn:not(fn:string(xs:yearMonthDuration("P11Y04M") * 2.0))</test>
      <result>
         <assert-false/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-5">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-5
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function that
is used as an argument to the fn:boolean function.
 Apply "fn:string" function to account for new EBV.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>fn:boolean(fn:string(xs:yearMonthDuration("P05Y08M") * 2.0))</test>
      <result>
         <assert-true/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-6">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-6
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" operator that
is used as an argument to the fn:number function.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>fn:number(xs:yearMonthDuration("P02Y09M") * 2.0)</test>
      <result>
         <assert-string-value>NaN</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-7">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-7
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function used
as an argument to the "fn:string" function).
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>fn:string(xs:yearMonthDuration("P03Y08M") * 2.0)</test>
      <result>
         <assert-string-value>P7Y4M</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-8">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-8
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function that
returns a negative value.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>(xs:yearMonthDuration("P10Y01M") * -2.0)</test>
      <result>
         <assert-string-value>-P20Y2M</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-9">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-9
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function used
together with and "and" expression.
 Apply "fn:string" function to account for new EBV.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>fn:string((xs:yearMonthDuration("P01Y01M") * 2.0)) and fn:string((xs:yearMonthDuration("P02Y03M") * 2.0))</test>
      <result>
         <assert-true/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-10">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-10
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function used
together with an "or" expression.
 Apply "fn:string" function to account for new EBV.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>fn:string((xs:yearMonthDuration("P05Y02M") * 2.0)) or fn:string((xs:yearMonthDuration("P05Y03M") * 2.0))</test>
      <result>
         <assert-true/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-11">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-11
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function used
together with a "div" expression.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>(xs:yearMonthDuration("P20Y11M") * 2.0) div (xs:yearMonthDuration("P20Y11M") * 2.0)</test>
      <result>
         <assert-string-value>1</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-12">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-12
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" operators used
with a boolean expression and the "fn:true" function.
 Apply "fn:string" function to account for new EBV.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>fn:string((xs:yearMonthDuration("P10Y11M") * 2.0)) and (fn:true())</test>
      <result>
         <assert-true/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-13">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-13
Written By: Carmelo Montanez
Date: June 29, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function used
together with the numeric-equal- operator "eq".
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>(xs:yearMonthDuration("P23Y11M") * 2.0) eq xs:yearMonthDuration("P23Y11M")</test>
      <result>
         <assert-false/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-14">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-14
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function used
together with the numeric-equal operator "ne".
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>(xs:yearMonthDuration("P21Y12M") * 2.0) ne xs:yearMonthDuration("P08Y05M")</test>
      <result>
         <assert-true/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-15">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-15
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" function used
together with the numeric-equal operator "le".
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>(xs:yearMonthDuration("P10Y01M") * 2.0) le xs:yearMonthDuration("P17Y02M")</test>
      <result>
         <assert-false/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-16">
      <description>
*******************************************************
Test: op-subtract-yearMonthDurations-16
Written By: Carmelo Montanez
Date: June 29, 2005
Purpose: Evaluates The "subtract-yearMonthDurations" function used
together with the numeric-equal operator "ge".
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>(xs:yearMonthDuration("P13Y09M") - xs:yearMonthDuration("P18Y02M")) ge xs:yearMonthDuration("P18Y02M")</test>
      <result>
         <assert-false/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-17">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-16
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" operator
multiplied by +0.  Use of fn:count to avoid empty file.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>fn:count((xs:yearMonthDuration("P13Y09M") *+0))</test>
      <result>
         <assert-string-value>1</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-18">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-18
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" operator
multiplied by -0.  Use of fn:count to avoid empty file.
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>fn:count((xs:yearMonthDuration("P13Y09M") *-0))</test>
      <result>
         <assert-string-value>1</assert-string-value>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-19">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-19
Written By: Carmelo Montanez
Date: June 30, 2005
Purpose: Evaluates The "multiply-yearMonthDuration" operator
with arg2 set to NaN.  Should raise an error
*******************************************************
</description>
      <created by="Carmelo Montanez" on="2005-06-29"/>
      <test>xs:yearMonthDuration("P13Y09M") * fn:number(())</test>
      <result>
         <error code="FOCA0005"/>
      </result>
   </test-case>
   <test-case name="op-multiply-yearMonthDuration-20">
      <description>
*******************************************************
Test: op-multiply-yearMonthDuration-20
Written By: Michael Kay
Date: 5 Feb 2009
Purpose: Test rounding behaviour, FO.E12.
*******************************************************
</description>
      <created by="Michael Kay, Saxonica" on="2009-03-05"/>
      <test>for $i in (-3.9, -3.5, -3.1, -0.9, -0.5, -0.1, +0.1, +0.5, +0.9, +3.1, +3.5, +3.9) return xs:yearMonthDuration("P1M") * $i</test>
      <result>
         <assert-string-value>-P4M -P3M -P3M -P1M P0M P0M P0M P1M P1M P3M P4M P4M</assert-string-value>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-1">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-1
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: Simple test of multiplying a xs:yearMonthDuration with 3.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>xs:yearMonthDuration("P3Y36M") * 3 eq xs:yearMonthDuration("P18Y")</test>
      <result>
         <assert-true/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-2">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-2
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: Simple test of multiplying 3 with xs:yearMonthDuration.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>3 * xs:yearMonthDuration("P3Y36M") eq xs:yearMonthDuration("P18Y")</test>
      <result>
         <assert-true/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-3">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-3
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: Simple test of multiplying 0 with xs:yearMonthDuration.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>0 * xs:yearMonthDuration("P3Y36M") eq xs:yearMonthDuration("P0M")</test>
      <result>
         <assert-true/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-4">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-4
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: Simple test of multiplying a xs:yearMonthDuration with 0.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>xs:yearMonthDuration("P3Y36M") * 0 eq xs:yearMonthDuration("P0M")</test>
      <result>
         <assert-true/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-5">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-5
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: Simple test of multiplying a xs:yearMonthDuration with INF.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>xs:yearMonthDuration("P3Y3M") * xs:double("INF")</test>
      <result>
         <error code="FODT0002"/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-6">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-6
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: Simple test of multiplying a xs:yearMonthDuration with -INF.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>xs:yearMonthDuration("P3Y3M") * xs:double("-INF")</test>
      <result>
         <error code="FODT0002"/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-7">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-7
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: Simple test of multiplying a xs:yearMonthDuration with NaN.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>xs:yearMonthDuration("P3Y3M") * xs:double("NaN")</test>
      <result>
         <error code="FOCA0005"/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-8">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-8
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: The multiplication operator is not available between xs:duration and xs:integer.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>xs:duration("P1Y3M") * 3</test>
      <result>
         <error code="XPTY0004"/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-9">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-9
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: The multiplication operator is not available between xs:integer and xs:duration.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>3 * xs:duration("P1Y3M")</test>
      <result>
         <error code="XPTY0004"/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-10">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-10
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: The multiplication operator is not available between xs:dayTimeDuration and xs:yearMonthDuration.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>xs:dayTimeDuration("P3D") * xs:yearMonthDuration("P3Y3M")</test>
      <result>
         <error code="XPTY0004"/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-11">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-11
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: The multiplication operator is not available between xs:yearMonthDuration and xs:dayTimeDuration.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>xs:yearMonthDuration("P3Y3M") * xs:dayTimeDuration("P3D")</test>
      <result>
         <error code="XPTY0004"/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-12">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-12
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: The multiplication operator is not available between xs:yearMonthDuration and xs:yearMonthDuration.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>xs:yearMonthDuration("P3Y3M") * xs:yearMonthDuration("P3Y3M")</test>
      <result>
         <error code="XPTY0004"/>
      </result>
   </test-case>
   <test-case name="K-YearMonthDurationMultiply-13">
      <description>
*******************************************************
 Test: K-YearMonthDurationMultiply-13
 Written by: Frans Englich
 Date: 2007-11-22T11:31:21+01:00
 Purpose: The multiplication operator is not available between xs:dayTimeDuration and xs:dayTimeDuration.
*******************************************************
</description>
      <created by="Frans Englich" on="2007-11-26+01:00"/>
      <test>xs:dayTimeDuration("P3D") * xs:dayTimeDuration("P3D")</test>
      <result>
         <error code="XPTY0004"/>
      </result>
   </test-case>

   <test-case name="cbcl-multiply-yearMonthDuration-001">
      <description> test multiplication of xs:yearMonthDuration by 0 </description>
      <created by="Tim Mills" on="2008-05-14"/>
      <dependency type="spec" value="XQ10+"/>
      <test>
        declare function local:yearMonthDuration($years as xs:integer) as xs:yearMonthDuration { xs:yearMonthDuration(concat("P", $years, "Y")) };
        local:yearMonthDuration(2) * 0</test>
      <result>
         <assert-string-value>P0M</assert-string-value>
      </result>
   </test-case>

   <test-case name="cbcl-multiply-yearMonthDuration-002">
      <description> test multiplication of xs:yearMonthDuration by 1 </description>
      <created by="Tim Mills" on="2008-05-14"/>
      <dependency type="spec" value="XQ10+"/>
      <test>
        declare function local:yearMonthDuration($years as xs:integer) as xs:yearMonthDuration { xs:yearMonthDuration(concat("P", $years, "Y")) };
        local:yearMonthDuration(2) * 1</test>
      <result>
         <assert-string-value>P2Y</assert-string-value>
      </result>
   </test-case>

   <test-case name="cbcl-multiply-yearMonthDuration-003">
      <description> test multiplication of xs:yearMonthDuration by NaN </description>
      <created by="Tim Mills" on="2008-05-14"/>
      <test>xs:yearMonthDuration("P2Y") * xs:double('NaN')</test>
      <result>
         <error code="FOCA0005"/>
      </result>
   </test-case>

   <test-case name="cbcl-multiply-yearMonthDuration-004">
      <description> test multiplication of xs:yearMonthDuration by 0 </description>
      <created by="Tim Mills" on="2008-05-14"/>
      <dependency type="spec" value="XQ10+"/>
      <test>
        declare function local:yearMonthDuration($years as xs:integer) as xs:yearMonthDuration { xs:yearMonthDuration(concat("P", $years, "Y")) };
        0 * local:yearMonthDuration(2)</test>
      <result>
         <assert-string-value>P0M</assert-string-value>
      </result>
   </test-case>

   <test-case name="cbcl-multiply-yearMonthDuration-005">
      <description> test multiplication of xs:yearMonthDuration by 1 </description>
      <created by="Tim Mills" on="2008-05-14"/>
      <dependency type="spec" value="XQ10+"/>
      <test>
        declare function local:yearMonthDuration($years as xs:integer) as xs:yearMonthDuration { xs:yearMonthDuration(concat("P", $years, "Y")) };
        1 * local:yearMonthDuration(2)</test>
      <result>
         <assert-string-value>P2Y</assert-string-value>
      </result>
   </test-case>

   <test-case name="cbcl-multiply-yearMonthDuration-006">
      <description> test multiplication of xs:yearMonthDuration by NaN </description>
      <created by="Tim Mills" on="2008-05-14"/>
      <test>xs:double('NaN') * xs:yearMonthDuration("P2Y")</test>
      <result>
         <error code="FOCA0005"/>
      </result>
   </test-case>
</test-set>


text:
package nextmethod.web.razor.parser;

import nextmethod.base.Delegates;
import nextmethod.base.OutParam;
import nextmethod.threading.SendOrPostCallback;
import nextmethod.threading.SynchronizationContext;
import nextmethod.web.razor.parser.syntaxtree.BlockBuilder;
import nextmethod.web.razor.parser.syntaxtree.BlockType;
import nextmethod.web.razor.parser.syntaxtree.FunctionsBlock;
import nextmethod.web.razor.parser.syntaxtree.RazorError;
import nextmethod.web.razor.parser.syntaxtree.Span;
import nextmethod.web.razor.parser.syntaxtree.SpanBuilder;
import nextmethod.web.razor.text.SourceLocation;
import org.junit.Test;

import static nextmethod.base.TypeHelpers.typeAs;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;

/**
 *
 */
public class CallbackParserListenerTest {

    @Test
    public void listenerConstructedWithSpanCallbackCallsCallbackOnEndSpan() {
        runOnEndSpanTest(
                            callback -> {
                                assert callback != null;
                                return new CallbackVisitor(callback);
                            }
                        );
    }

    @Test
    public void listenerConstructedWithSpanCallbackDoesNotThrowOnStartBlockEndBlockOrError() {
        final Delegates.IAction1<Span> spanCallback = createNopAction();

        final CallbackVisitor listener = new CallbackVisitor(spanCallback);

        listener.visitStartBlock(new FunctionsBlock());
        listener.visitError(new RazorError("Error", SourceLocation.Zero));
        listener.visitEndBlock(new FunctionsBlock());
    }

    @Test
    public void listenerConstructedWithSpanAndErrorCallbackCallsCallbackOnEndSpan() {
        runOnEndSpanTest(
                            input1 -> {
                                assert input1 != null;
                                return new CallbackVisitor(
                                                              input1,
                                                              createNopAction(RazorError.class)
                                );
                            }
                        );
    }

    @Test
    public void listenerConstructedWithSpanAndErrorCallbackCallsCallbackOnError() {
        runOnErrorTest(
                          input1 -> {
                              assert input1 != null;
                              return new CallbackVisitor(
                                                            createNopAction(Span.class),
                                                            input1
                              );
                          }
                      );
    }

    @Test
    public void listenerConstructedWithAllCallbacksCallsCallbackOnEndSpan() {
        runOnEndSpanTest(
                            input1 -> {
                                assert input1 != null;
                                return new CallbackVisitor(
                                                              input1,
                                                              createNopAction(RazorError.class),
                                                              createNopAction(BlockType.class),
                                                              createNopAction(BlockType.class)
                                );
                            }
                        );
    }

    @Test
    public void listenerConstructedWithAllCallbacksCallsCallbackOnError() {
        runOnErrorTest(
                          input1 -> {
                              assert input1 != null;
                              return new CallbackVisitor(
                                                            createNopAction(Span.class),
                                                            input1,
                                                            createNopAction(BlockType.class),
                                                            createNopAction(BlockType.class)
                              );
                          }
                      );
    }

    @Test
    public void listenerConstructedWithAllCallbacksCallsCallbackOnStartBlock() {
        runOnStartBlockTest(
                               input1 -> {
                                   assert input1 != null;
                                   return new CallbackVisitor(
                                                                 createNopAction(Span.class),
                                                                 createNopAction(RazorError.class),
                                                                 input1,
                                                                 createNopAction(BlockType.class)
                                   );
                               }
                           );
    }

    @Test
    public void listenerConstructedWithAllCallbacksCallsCallbackOnEndBlock() {
        runOnEndBlockTest(
                             input1 -> {
                                 assert input1 != null;
                                 return new CallbackVisitor(
                                                               createNopAction(Span.class),
                                                               createNopAction(RazorError.class),
                                                               createNopAction(BlockType.class),
                                                               input1
                                 );
                             }
                         );
    }

    @Test
    public void listenerCallsOnEndSpanCallbackUsingSynchronizationContextIfSpecified() {
        runSyncContextTest(
                              new SpanBuilder().build(),
                              new SpanBuilder().build(),
                              spanCallback -> {
                                  assert spanCallback != null;
                                  return new CallbackVisitor(
                                                                spanCallback,
                                                                createNopAction(RazorError.class),
                                                                createNopAction(BlockType.class),
                                                                createNopAction(BlockType.class)
                                  );
                              },
                              (listener, expected) -> {
                                  assert listener != null;
                                  assert expected != null;
                                  listener.visitSpan(expected);
                              }
                          );
    }

    @Test
    public void listenerCallsOnStartBlockCallbackUsingSynchronizationContextIfSpecified() {
        runSyncContextTest(
                              BlockType.values()[0],
                              BlockType.Template,
                              startBlockCall -> {
                                  assert startBlockCall != null;
                                  return new CallbackVisitor(
                                                                createNopAction(Span.class),
                                                                createNopAction(RazorError.class),
                                                                startBlockCall,
                                                                createNopAction(BlockType.class)
                                  );
                              },
                              (listener, expected) -> {
                                  assert listener != null;
                                  listener.visitStartBlock(new BlockBuilder().setType(expected).build());
                              }
                          );
    }

    @Test
    public void listenerCallsOnEndBlockCallbackUsingSynchronizationContextIfSpecified() {
        runSyncContextTest(
                              BlockType.values()[0],
                              BlockType.Template,
                              endBlockCallback -> {
                                  assert endBlockCallback != null;
                                  return new CallbackVisitor(
                                                                createNopAction(Span.class),
                                                                createNopAction(RazorError.class),
                                                                createNopAction(BlockType.class),
                                                                endBlockCallback
                                  );
                              },
                              (listener, expected) -> {
                                  assert listener != null;
                                  listener.visitEndBlock(new BlockBuilder().setType(expected).build());
                              }
                          );
    }

    @Test
    public void listenerCallsOnErrorCallbackUsingSynchronizationContextIfSpecified() {
        runSyncContextTest(
                              new RazorError("Foo", SourceLocation.Zero),
                              new RazorError("Bar", 42, 42, 42),
                              errorCallback -> {
                                  assert errorCallback != null;
                                  return new CallbackVisitor(
                                                                createNopAction(Span.class),
                                                                errorCallback,
                                                                createNopAction(BlockType.class),
                                                                createNopAction(BlockType.class)
                                  );
                              },
                              (listener, expected) -> {
                                  assert listener != null;
                                  assert expected != null;
                                  listener.visitError(expected);
                              }
                          );
    }

    @SuppressWarnings("unchecked")
    private static <T> void runSyncContextTest(final T defaultValue, final T expected,
                                               final Delegates.IFunc1<Delegates.IAction1<T>, CallbackVisitor> ctor,
                                               final Delegates.IAction2<CallbackVisitor, T> call
                                              ) {
        final SynchronizationContext mockContext = mock(SynchronizationContext.class);
        doAnswer(
                    invocation -> {
                        final Object[] arguments = invocation.getArguments();
                        assert arguments.length == 2;
                        final SendOrPostCallback sendOrPostCallback = typeAs(arguments[0], SendOrPostCallback.class);
                        sendOrPostCallback.invoke(expected);

                        return null;
                    }
                ).when(mockContext).post(any(SendOrPostCallback.class), anyObject());

        runCallbackTest(
                           defaultValue,
                           callback -> {
                               final CallbackVisitor listener = ctor.invoke(callback);
                               assert listener != null;
                               listener.setSynchronizationContext(mockContext);
                               return listener;
                           },
                           call,
                           (original, actual) -> {
                               assertNotSame(original, actual);
                               assertSame(expected, actual);
                           }
                       );
    }

    private static void runOnStartBlockTest(final Delegates.IFunc1<Delegates.IAction1<BlockType>, CallbackVisitor> ctor) {
        runOnStartBlockTest(ctor, null);
    }

    private static void runOnStartBlockTest(final Delegates.IFunc1<Delegates.IAction1<BlockType>, CallbackVisitor> ctor,
                                            final Delegates.IAction2<BlockType, BlockType> verifyResults
                                           ) {
        runCallbackTest(
                           BlockType.Markup,
                           ctor,
                           (listener, expected) -> {
                               assert listener != null;
                               assert expected != null;
                               listener.visitStartBlock(new BlockBuilder().setType(expected).build());
                           },
                           verifyResults
                       );
    }

    private static void runOnEndBlockTest(final Delegates.IFunc1<Delegates.IAction1<BlockType>, CallbackVisitor> ctor) {
        runOnEndBlockTest(ctor, null);
    }

    private static void runOnEndBlockTest(final Delegates.IFunc1<Delegates.IAction1<BlockType>, CallbackVisitor> ctor,
                                          final Delegates.IAction2<BlockType, BlockType> verifyResults
                                         ) {
        runCallbackTest(
                           BlockType.Markup,
                           ctor,
                           (listener, expected) -> {
                               assert listener != null;
                               assert expected != null;
                               listener.visitEndBlock(new BlockBuilder().setType(expected).build());
                           },
                           verifyResults
                       );
    }

    private static void runOnErrorTest(final Delegates.IFunc1<Delegates.IAction1<RazorError>, CallbackVisitor> ctor) {
        runOnErrorTest(ctor, null);
    }

    private static void runOnErrorTest(final Delegates.IFunc1<Delegates.IAction1<RazorError>, CallbackVisitor> ctor,
                                       final Delegates.IAction2<RazorError, RazorError> verifyResults
                                      ) {
        runCallbackTest(
                           new RazorError("Foo", SourceLocation.Zero),
                           ctor,
                           (listener, expected) -> {
                               assert listener != null;
                               assert expected != null;
                               listener.visitError(expected);
                           },
                           verifyResults
                       );
    }

    private static void runOnEndSpanTest(final Delegates.IFunc1<Delegates.IAction1<Span>, CallbackVisitor> ctor) {
        runOnEndSpanTest(ctor, null);
    }

    private static void runOnEndSpanTest(final Delegates.IFunc1<Delegates.IAction1<Span>, CallbackVisitor> ctor,
                                         final Delegates.IAction2<Span, Span> verifyResults
                                        ) {
        runCallbackTest(
                           new SpanBuilder().build(),
                           ctor,
                           (listener, expected) -> {
                               assert listener != null;
                               assert expected != null;
                               listener.visitSpan(expected);
                           },
                           verifyResults
                       );
    }

    private static <T> void runCallbackTest(final T expected,
                                            final Delegates.IFunc1<Delegates.IAction1<T>, CallbackVisitor> ctor,
                                            final Delegates.IAction2<CallbackVisitor, T> call
                                           ) {
        runCallbackTest(expected, ctor, call, null);
    }

    private static <T> void runCallbackTest(final T expected,
                                            final Delegates.IFunc1<Delegates.IAction1<T>, CallbackVisitor> ctor,
                                            final Delegates.IAction2<CallbackVisitor, T> call,
                                            final Delegates.IAction2<T, T> verifyResults
                                           ) {
        final OutParam<T> actual = OutParam.of();
        final Delegates.IAction1<T> callback = actual::set;

        final CallbackVisitor listener = ctor.invoke(callback);

        call.invoke(listener, expected);

        if (verifyResults == null) {
            assertSame(expected, actual.value());
        }
        else {
            verifyResults.invoke(expected, actual.value());
        }
    }

    private static <T> Delegates.IAction1<T> createNopAction() {
        return input -> {
        };
    }

    private static <T> Delegates.IAction1<T> createNopAction(final Class<T> ignored) {
        return input -> {
        };
    }
}


text:
import React from "react";
import PropTypes from "prop-types";
import LightComponent from "ui-lib/light_component";
import { CardText, CardTitle } from "react-toolbox/lib/card";
import { HiddenText } from "ui-components/hidden_text";
import { DateTime } from "ui-components/datetime";
import { Tags } from "ui-components/tags";
import DataCard from "./DataCard";
import { UserAvatar } from "ui-components/user_avatar";
import stateVar from "ui-lib/state_var";
import { LogLines } from "ui-components/log_viewer";

class LogCard extends LightComponent {
    constructor(props) {
        super(props);

        this.state = {
            expanded: stateVar(this, "expanded", this.props.expanded)
        };
    }

    render() {
        const myItemPath = `/logrepo/log/${this.props.item._id}/download`;

        return (
            <DataCard
                theme={this.props.theme}
                expanded={this.state.expanded}
                expandable={this.props.expandable}
                path={myItemPath}
                openInNew={true}
            >
                <CardTitle
                    avatar={(
                        <UserAvatar
                            className={this.props.theme.avatar}
                            defaultUrl="/Cheser/48x48/mimetypes/text-x-generic.png"
                        />
                    )}
                    title={this.props.item.name}
                    subtitle={(
                        <DateTime
                            value={this.props.item.saved}
                            niceDate={true}
                        />
                    )}
                />
                <If condition={this.state.expanded.value}>
                    <CardText>
                        <LogLines id={this.props.item._id} />
                    </CardText>

                                State

                                    {this.props.item.state}

                                Name

                                    {this.props.item.name}
                                    <HiddenText
                                        className={this.props.theme.hiddenText}
                                        label="SHOW ID"
                                        text={this.props.item._id}
                                    />

                                Repository
                                {this.props.item.repository}

                                Size
                                {this.props.item.fileMeta.size}

                                Mimetype
                                {this.props.item.fileMeta.mimeType}

                                Created at

                                    <DateTime
                                        value={this.props.item.created}
                                        niceDate={true}
                                    />

                                Tags

                                    <Tags list={this.props.item.tags} />

                </If>
            </DataCard>
        );
    }
}

LogCard.defaultProps = {
    expanded: false,
    expandable: true
};

LogCard.propTypes = {
    theme: PropTypes.object,
    item: PropTypes.object.isRequired,
    expanded: PropTypes.bool,
    expandable: PropTypes.bool
};

export default LogCard;


text:
from __future__ import absolute_import
from ..errs import ValidationError

class File(object):
    """ for type File
    """
    def apply_with(self, _, val, ctx):
        """ constructor

        example val:
        {
            # header values used in multipart/form-data according to RFC2388
            'header': {
                'Content-Type': 'text/plain',

                # according to RFC2388, available values are '7bit', '8bit', 'binary'
                'Content-Transfer-Encoding': 'binary'
            },
            filename: 'a.txt',
            data: None (or any file-like object)
        }

        :param val: dict containing file info.
        """
        self.header = val.get('header', {})
        self.data = val.get('data', None)
        self.filename = val.get('filename', '')
        if self.data == None and self.filename == '':
            raise ValidationError('should have file name or file object, not: {0}, {1}'.format(
                self.data, self.filename
            ))


text:
<?php

class Dm_Image_Filter_Chain extends Dm_Image_Filter_Abstract
{
	private $filters;

	/**
	 * Create new filter chain
	 *
	 * @return Dm_Image_Filter_Chain
	 */
	public static function create()
	{
		return new Dm_Image_Filter_Chain();
	}

	/**
	 * Filter chain constructor
	 *
	 * @param array $filters Dm_Image_Filter_Abstract
	 * @return Dm_Image_Filter_Chain
	 */
	public function __construct(array $filters = [])
	{
		$this->filters = is_array($filters) ? $filters : [];
	}

	/**
	 * Crop image
	 *
	 * @param int $width
	 * @param int $height
	 * @param boolean $bounding
	 * @return $this
	 */
	public function crop($width, $height)
	{
		$this->filters[] = new Dm_Image_Filter_Crop($width, $height);
		return $this;
	}

	/**
	 * Fit image
	 *
	 * @param int $width
	 * @param int $height
	 * @param boolean $bounding
	 * @return $this
	 */
	public function fit($width, $height, $bounding = false)
	{
		$this->filters[] = new Dm_Image_Filter_Fit($width, $height, $bounding);
		return $this;
	}

	/**
	 * Apply filters
	 *
	 * @param DmImage
	 * @return bool
	 */
	public function execute(Dm_Image $image)
	{
		foreach ($this->filters as $filter) {
			$image->applyFilter($filter);
		}
		return $image->getImageResource();
	}
}