text:
<?php

namespace ZfcUserTest\Authentication\Storage;

use ZfcUser\Authentication\Storage\Db;

class DbTest extends \PHPUnit_Framework_TestCase
{
    /**
     * The object to be tested.
     *
     * @var Db
     */
    protected $db;

    /**
     * Mock of Storage.
     *
     * @var storage
     */
    protected $storage;

    /**
     * Mock of Mapper.
     *
     * @var mapper
     */
    protected $mapper;

    public function setUp()
    {
        $db = new Db;
        $this->db = $db;

        $this->storage = $this->getMock('Zend\Authentication\Storage\Session');
        $this->mapper = $this->getMock('ZfcUser\Mapper\User');
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::isEmpty
     */
    public function testIsEmpty()
    {
        $this->storage->expects($this->once())
                      ->method('isEmpty')
                      ->will($this->returnValue(true));

        $this->db->setStorage($this->storage);

        $this->assertTrue($this->db->isEmpty());
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::read
     */
    public function testReadWithResolvedEntitySet()
    {
        $reflectionClass = new \ReflectionClass('ZfcUser\Authentication\Storage\Db');
        $reflectionProperty = $reflectionClass->getProperty('resolvedIdentity');
        $reflectionProperty->setAccessible(true);
        $reflectionProperty->setValue($this->db, 'zfcUser');

        $this->assertSame('zfcUser', $this->db->read());
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::read
     */
    public function testReadWithoutResolvedEntitySetIdentityIntUserFound()
    {
        $this->storage->expects($this->once())
                      ->method('read')
                      ->will($this->returnValue(1));

        $this->db->setStorage($this->storage);

        $user = $this->getMock('ZfcUser\Entity\User');
        $user->setUsername('zfcUser');

        $this->mapper->expects($this->once())
                     ->method('findById')
                     ->with(1)
                     ->will($this->returnValue($user));

        $this->db->setMapper($this->mapper);

        $result = $this->db->read();

        $this->assertSame($user, $result);
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::read
     */
    public function testReadWithoutResolvedEntitySetIdentityIntUserNotFound()
    {
        $this->storage->expects($this->once())
                      ->method('read')
                      ->will($this->returnValue(1));

        $this->db->setStorage($this->storage);

        $this->mapper->expects($this->once())
                     ->method('findById')
                     ->with(1)
                     ->will($this->returnValue(false));

        $this->db->setMapper($this->mapper);

        $result = $this->db->read();

        $this->assertNull($result);
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::read
     */
    public function testReadWithoutResolvedEntitySetIdentityObject()
    {
        $user = $this->getMock('ZfcUser\Entity\User');
        $user->setUsername('zfcUser');

        $this->storage->expects($this->once())
                      ->method('read')
                      ->will($this->returnValue($user));

        $this->db->setStorage($this->storage);

        $result = $this->db->read();

        $this->assertSame($user, $result);
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::write
     */
    public function testWrite()
    {
        $reflectionClass = new \ReflectionClass('ZfcUser\Authentication\Storage\Db');
        $reflectionProperty = $reflectionClass->getProperty('resolvedIdentity');
        $reflectionProperty->setAccessible(true);

        $this->storage->expects($this->once())
                      ->method('write')
                      ->with('zfcUser');

        $this->db->setStorage($this->storage);

        $this->db->write('zfcUser');

        $this->assertNull($reflectionProperty->getValue($this->db));
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::clear
     */
    public function testClear()
    {
        $reflectionClass = new \ReflectionClass('ZfcUser\Authentication\Storage\Db');
        $reflectionProperty = $reflectionClass->getProperty('resolvedIdentity');
        $reflectionProperty->setAccessible(true);

        $this->storage->expects($this->once())
            ->method('clear');

        $this->db->setStorage($this->storage);

        $this->db->clear();

        $this->assertNull($reflectionProperty->getValue($this->db));
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::getMapper
     */
    public function testGetMapperWithNoMapperSet()
    {
        $sm = $this->getMock('Zend\ServiceManager\ServiceManager');
        $sm->expects($this->once())
           ->method('get')
           ->with('zfcuser_user_mapper')
           ->will($this->returnValue($this->mapper));

        $this->db->setServiceManager($sm);

        $this->assertInstanceOf('ZfcUser\Mapper\UserInterface', $this->db->getMapper());
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::setMapper
     * @covers ZfcUser\Authentication\Storage\Db::getMapper
     */
    public function testSetGetMapper()
    {
        $mapper = new \ZfcUser\Mapper\User;
        $mapper->setTableName('zfcUser');

        $this->db->setMapper($mapper);

        $this->assertInstanceOf('ZfcUser\Mapper\User', $this->db->getMapper());
        $this->assertSame('zfcUser', $this->db->getMapper()->getTableName());
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::setServiceManager
     * @covers ZfcUser\Authentication\Storage\Db::getServiceManager
     */
    public function testSetGetServicemanager()
    {
        $sm = $this->getMock('Zend\ServiceManager\ServiceManager');

        $this->db->setServiceManager($sm);

        $this->assertInstanceOf('Zend\ServiceManager\ServiceLocatorInterface', $this->db->getServiceManager());
        $this->assertSame($sm, $this->db->getServiceManager());
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::getStorage
     * @covers ZfcUser\Authentication\Storage\Db::setStorage
     */
    public function testGetStorageWithoutStorageSet()
    {
        $this->assertInstanceOf('Zend\Authentication\Storage\Session', $this->db->getStorage());
    }

    /**
     * @covers ZfcUser\Authentication\Storage\Db::getStorage
     * @covers ZfcUser\Authentication\Storage\Db::setStorage
     */
    public function testSetGetStorage()
    {
        $storage = new \Zend\Authentication\Storage\Session('ZfcUserStorage');
        $this->db->setStorage($storage);

        $this->assertInstanceOf('Zend\Authentication\Storage\Session', $this->db->getStorage());
    }
}


text:
% STARSINE Generates phase congruent star shaped sine wave grating
%
% Usage:    im = starsine(sze, nCycles, nScales, ampExponent, offset)
%
% Arguments:
%      sze         - The size of the square image to be produced.
%      nCycles     - The number of sine wave cycles around centre point.
%                    Typically an integer, but any value can be used.
%      nScales     - No of fourier components used to construct the
%                    signal. This is typically 1, if you want a simple sine
%                    wave, or >50 if you want to build a phase congruent
%                    waveform.
%      ampExponent - Decay exponent of amplitude with frequency.
%                    A value of -1 will produce amplitude inversely
%                    proportional to frequency (this will produce a step
%                    feature if offset is 0)
%                    A value of -2 with an offset of pi/2 will result in a
%                    triangular waveform.
%      offset      - Phase offset to apply to star pattern.
%
% Examples:
% nScales = 1             - You get a simple sine wave pattern radiating out
%                           from the centre. Use 'offset' if you wish to
%                           rotate it a bit.
% nScales 50, ampExponent -1, offset 0     - Square waveform
% nScales 50, ampExponent -2, offset pi/2  - Triangular waveform
% nScales 50, ampExponent -1.5, offset pi/4  - Something in between square and
%                                              triangular
% nScales 50, ampExponent -1.5, offset 0   - Looks like a square but is not.
%
% See also: CIRCSINE, STEP2LINE

% Copyright (c) 2010 Peter Kovesi
% Centre for Exploration Targeting
% School of Earth and Enironment
% The University of Western Australia
% peter.kovesi at uwa edu au
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction, subject to the following conditions:
%
% The above copyright notice and this permission notice shall be included in
% all copies or substantial portions of the Software.
%
% The Software is provided "as is", without warranty of any kind.

% December 2010

function im = starsine(sze, nCycles, nScales, ampExponent, offset)

    if ~exist('offset', 'var')
	offset = 0;
    end

    % Place origin at centre for odd sized image, and below and the the
    % right of centre for an even sized image
    if mod(sze,2) == 0   % even sized image
	l = -sze/2;
	u = sze/2-1;
    else
	l = -(sze-1)/2;
	u = (sze-1)/2;
    end

    [x,y] = meshgrid(l:u);
    theta = atan2(y,x);

    im = zeros(size(theta));

    for scale = 1:2:(nScales*2 - 1)
        im = im + scale^ampExponent*sin(scale*nCycles*theta + offset);
    end

redpajama_set_name: RedPajamaGithub


text:
-- Liquibase version: 2.0.1
-- *********************************************************************

-- Lock Database
-- Changeset changelog_4.0.0.groovy::4.0.0-3::owf::(Checksum: 3:d066b39ebec901b63dbe5b674825449d)
-- Added defaultSettings column into Dashboard Table
ALTER TABLE dashboard ADD default_settings CLOB;

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('owf', 'Added defaultSettings column into Dashboard Table', SYSTIMESTAMP, 'Add Column', 'EXECUTED', 'changelog_4.0.0.groovy', '4.0.0-3', '2.0.1', '3:d066b39ebec901b63dbe5b674825449d', 1);

-- Changeset changelog_4.0.0.groovy::4.0.0-4::owf::(Checksum: 3:c4ccbcf8a10f33b5063af97a9d15d28c)
-- Added background column for WidgetDefinition
ALTER TABLE widget_definition ADD background NUMBER(1);

UPDATE widget_definition SET background = 0;

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('owf', 'Added background column for WidgetDefinition', SYSTIMESTAMP, 'Add Column', 'EXECUTED', 'changelog_4.0.0.groovy', '4.0.0-4', '2.0.1', '3:c4ccbcf8a10f33b5063af97a9d15d28c', 2);

-- Changeset changelog_4.0.0.groovy::4.0.0-47::owf::(Checksum: 3:967a5a6cb7f1d94dfef9beb90b77e1e5)
-- Added showLaunchMenu column into Dashboard Table
ALTER TABLE dashboard ADD show_launch_menu NUMBER(1) DEFAULT 0;

UPDATE dashboard SET show_launch_menu = 0;

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('owf', 'Added showLaunchMenu column into Dashboard Table', SYSTIMESTAMP, 'Add Column', 'EXECUTED', 'changelog_4.0.0.groovy', '4.0.0-47', '2.0.1', '3:967a5a6cb7f1d94dfef9beb90b77e1e5', 3);

-- Changeset changelog_4.0.0.groovy::4.0.0-48::owf::(Checksum: 3:43eac589305fd819d29fe84a43414c3f)
-- Create widget type table and linking table
CREATE TABLE widget_type (id NUMBER(38,0) NOT NULL, version NUMBER(38,0) NOT NULL, name VARCHAR2(255) NOT NULL, CONSTRAINT widget_typePK PRIMARY KEY (id));

CREATE TABLE widget_definition_widget_types (widget_definition_id NUMBER(38,0) NOT NULL, widget_type_id NUMBER(38,0) NOT NULL);

ALTER TABLE widget_definition_widget_types ADD PRIMARY KEY (widget_definition_id, widget_type_id);

ALTER TABLE widget_definition_widget_types ADD CONSTRAINT FK8A59D92F293A835C FOREIGN KEY (widget_definition_id) REFERENCES widget_definition (id);

ALTER TABLE widget_definition_widget_types ADD CONSTRAINT FK8A59D92FD46C6F7C FOREIGN KEY (widget_type_id) REFERENCES widget_type (id);

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('owf', 'Create widget type table and linking table', SYSTIMESTAMP, 'Create Table (x2), Add Primary Key, Add Foreign Key Constraint (x2)', 'EXECUTED', 'changelog_4.0.0.groovy', '4.0.0-48', '2.0.1', '3:43eac589305fd819d29fe84a43414c3f', 4);

-- Changeset changelog_4.0.0.groovy::4.0.0-51::owf::(Checksum: 3:dc8cf89d14b68c19d487908ef28c89b1)
-- Add widget types to table
INSERT INTO widget_type (id, name, version) VALUES (1, 'standard', 0);

INSERT INTO widget_type (id, name, version) VALUES (2, 'administration', 0);

INSERT INTO widget_type (id, name, version) VALUES (3, 'marketplace', 0);

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('owf', 'Add widget types to table', SYSTIMESTAMP, 'Insert Row (x3)', 'EXECUTED', 'changelog_4.0.0.groovy', '4.0.0-51', '2.0.1', '3:dc8cf89d14b68c19d487908ef28c89b1', 5);

-- Changeset changelog_4.0.0.groovy::4.0.0-53::owf::(Checksum: 3:7fed1a797ab9d36fdb18255281541337)
-- Insert widget type mapping links
insert into widget_definition_widget_types (widget_definition_id, widget_type_id)
      select id, 1 from widget_definition
      where widget_url not in (
        'admin/DashboardEdit.gsp',
        'admin/GroupDashboardManagement.gsp',
        'admin/GroupEdit.gsp',
        'admin/GroupManagement.gsp',
        'admin/MarketplaceApprovals.gsp',
        'admin/UserManagement.gsp',
        'admin/UserEdit.gsp',
        'admin/WidgetEdit.gsp',
        'admin/WidgetManagement.gsp'
        );

insert into widget_definition_widget_types (widget_definition_id, widget_type_id)
      select id, 2 from widget_definition
      where widget_url in (
        'admin/DashboardEdit.gsp',
        'admin/GroupDashboardManagement.gsp',
        'admin/GroupEdit.gsp',
        'admin/GroupManagement.gsp',
        'admin/MarketplaceApprovals.gsp',
        'admin/UserManagement.gsp',
        'admin/UserEdit.gsp',
        'admin/WidgetEdit.gsp',
        'admin/WidgetManagement.gsp'
        );

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('owf', 'Insert widget type mapping links', SYSTIMESTAMP, 'Custom SQL (x2)', 'EXECUTED', 'changelog_4.0.0.groovy', '4.0.0-53', '2.0.1', '3:7fed1a797ab9d36fdb18255281541337', 6);

-- Changeset changelog_4.0.0.groovy::4.0.0-55::owf::(Checksum: 3:43c93ef1d7f35a92c470fdcfde7b2d6f)
-- Updating Admin Widget Icons and Names
UPDATE widget_definition SET display_name = 'Users', image_url_large = 'themes/common/images/adm-tools/Users64.png', image_url_small = 'themes/common/images/adm-tools/Users24.png' WHERE widget_url='admin/UserManagement.gsp';

UPDATE widget_definition SET image_url_large = 'themes/common/images/adm-tools/Users64.png', image_url_small = 'themes/common/images/adm-tools/Users24.png' WHERE widget_url='admin/UserEdit.gsp';

UPDATE widget_definition SET display_name = 'Widgets', image_url_large = 'themes/common/images/adm-tools/Widgets64.png', image_url_small = 'themes/common/images/adm-tools/Widgets24.png' WHERE widget_url='admin/WidgetManagement.gsp';

UPDATE widget_definition SET image_url_large = 'themes/common/images/adm-tools/Widgets64.png', image_url_small = 'themes/common/images/adm-tools/Widgets24.png' WHERE widget_url='admin/WidgetEdit.gsp';

UPDATE widget_definition SET display_name = 'Groups', image_url_large = 'themes/common/images/adm-tools/Groups64.png', image_url_small = 'themes/common/images/adm-tools/Groups24.png' WHERE widget_url='admin/GroupManagement.gsp';

UPDATE widget_definition SET image_url_large = 'themes/common/images/adm-tools/Groups64.png', image_url_small = 'themes/common/images/adm-tools/Groups24.png' WHERE widget_url='admin/GroupEdit.gsp';

UPDATE widget_definition SET display_name = 'Group Dashboards', image_url_large = 'themes/common/images/adm-tools/Dashboards64.png', image_url_small = 'themes/common/images/adm-tools/Dashboards24.png' WHERE widget_url='admin/GroupDashboardManagement.gsp';

UPDATE widget_definition SET image_url_large = 'themes/common/images/adm-tools/Dashboards64.png', image_url_small = 'themes/common/images/adm-tools/Dashboards24.png' WHERE widget_url='admin/DashboardEdit.gsp';

UPDATE widget_definition SET display_name = 'Approvals', image_url_large = 'themes/common/images/adm-tools/Approvals64.png', image_url_small = 'themes/common/images/adm-tools/Approvals24.png', visible = 1 WHERE widget_url='admin/MarketplaceApprovals.gsp';

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('owf', 'Updating Admin Widget Icons and Names', SYSTIMESTAMP, 'Update Data (x9)', 'EXECUTED', 'changelog_4.0.0.groovy', '4.0.0-55', '2.0.1', '3:43c93ef1d7f35a92c470fdcfde7b2d6f', 7);

-- Changeset changelog_4.0.0.groovy::4.0.0-56::owf::(Checksum: 3:7e4d6568d91e79149f8b895501eb8579)
-- Updating display_name column to 256 chars
ALTER TABLE widget_definition MODIFY display_name VARCHAR2(256);

INSERT INTO DATABASECHANGELOG (AUTHOR, COMMENTS, DATEEXECUTED, DESCRIPTION, EXECTYPE, FILENAME, ID, LIQUIBASE, MD5SUM, ORDEREXECUTED) VALUES ('owf', 'Updating display_name column to 256 chars', SYSTIMESTAMP, 'Modify data type', 'EXECUTED', 'changelog_4.0.0.groovy', '4.0.0-56', '2.0.1', '3:7e4d6568d91e79149f8b895501eb8579', 8);

-- Release Database Lock


text:
using namespace arangodb;

using PathEnumerator = arangodb::traverser::PathEnumerator;
using DepthFirstEnumerator = arangodb::traverser::DepthFirstEnumerator;
using Traverser = arangodb::traverser::Traverser;
using TraverserOptions = arangodb::traverser::TraverserOptions;

namespace arangodb {
namespace traverser {

EnumeratedPath::EnumeratedPath(arangodb::ResourceMonitor& resourceMonitor)
    : _resourceMonitor(resourceMonitor) {}

EnumeratedPath::~EnumeratedPath() {
  size_t memoryUsage =
      (_vertices.capacity() * sizeof(typename decltype(_vertices)::value_type)) +
      (_edges.capacity() * sizeof(typename decltype(_edges)::value_type));

  _resourceMonitor.decreaseMemoryUsage(memoryUsage);
}

template <typename T>
void EnumeratedPath::growStorage(std::vector<T>& data) {
  size_t capacity = arangodb::containers::Helpers::nextCapacity(data, 8);

  if (capacity > data.capacity()) {
    // reserve space
    ResourceUsageScope guard(_resourceMonitor, (capacity - data.capacity()) * sizeof(T));
    // if this fails, we don't have to rollback anything
    data.reserve(capacity);

    // now we are responsible for tracking the memory usage
    guard.steal();
  }
}

void EnumeratedPath::pushVertex(arangodb::velocypack::StringRef const& v) {
  growStorage(_vertices);
  _vertices.emplace_back(v);
}

void EnumeratedPath::pushEdge(graph::EdgeDocumentToken const& e) {
  growStorage(_edges);
  _edges.emplace_back(e);
}

void EnumeratedPath::popVertex() noexcept {
  TRI_ASSERT(!_vertices.empty());
  _vertices.pop_back();
}

void EnumeratedPath::popEdge() noexcept {
  TRI_ASSERT(!_edges.empty());
  _edges.pop_back();
}

void EnumeratedPath::clear() {
  _vertices.clear();
  _edges.clear();
}

size_t EnumeratedPath::numVertices() const noexcept { return _vertices.size(); }

size_t EnumeratedPath::numEdges() const noexcept { return _edges.size(); }

std::vector<arangodb::velocypack::StringRef> const& EnumeratedPath::vertices() const noexcept {
  return _vertices;
}

std::vector<graph::EdgeDocumentToken> const& EnumeratedPath::edges() const noexcept {
  return _edges;
}

arangodb::velocypack::StringRef const& EnumeratedPath::lastVertex() const noexcept {
  TRI_ASSERT(!_vertices.empty());
  return _vertices.back();
}

graph::EdgeDocumentToken const& EnumeratedPath::lastEdge() const noexcept {
  TRI_ASSERT(!_edges.empty());
  return _edges.back();
}

}  // namespace traverser
}  // namespace arangodb

PathEnumerator::PathEnumerator(Traverser* traverser, TraverserOptions* opts)
    : _traverser(traverser),
      _opts(opts),
      _enumeratedPath(_opts->resourceMonitor()),
      _httpRequests(0),
      _isFirst(true) {}

PathEnumerator::~PathEnumerator() = default;

void PathEnumerator::setStartVertex(arangodb::velocypack::StringRef startVertex) {
  _isFirst = true;
  _httpRequests = 0;

  _enumeratedPath.clear();
  _enumeratedPath.pushVertex(startVertex);
}

bool PathEnumerator::usePostFilter(aql::PruneExpressionEvaluator* evaluator) {
  TRI_ASSERT(evaluator != nullptr);

  aql::AqlValue vertex, edge;
  aql::AqlValueGuard vertexGuard{vertex, true}, edgeGuard{edge, true};
  if (evaluator->needsVertex()) {
    vertex = lastVertexToAqlValue();
    evaluator->injectVertex(vertex.slice());
  }
  if (evaluator->needsEdge()) {
    edge = lastEdgeToAqlValue();
    evaluator->injectEdge(edge.slice());
  }
  TRI_ASSERT(!evaluator->needsPath());
  if (!evaluator->evaluate()) {
    // do not return the path in that case
    return false;
  }
  return true;
};

bool PathEnumerator::keepEdge(arangodb::graph::EdgeDocumentToken& eid,
                              arangodb::velocypack::Slice edge,
                              arangodb::velocypack::StringRef sourceVertex,
                              size_t depth, size_t cursorId) {
  if (_opts->hasEdgeFilter(depth, cursorId)) {
    VPackSlice e = edge;
    if (edge.isString()) {
      e = _opts->cache()->lookupToken(eid);
    }
    if (!_traverser->edgeMatchesConditions(e, sourceVertex, depth, cursorId)) {
      // This edge does not pass the filtering
      return false;
    }
  }

  return _opts->destinationCollectionAllowed(edge, sourceVertex);
}

graph::EdgeCursor* PathEnumerator::getCursor(arangodb::velocypack::StringRef nextVertex,
                                             uint64_t currentDepth) {
  if (currentDepth >= _cursors.size()) {
    _cursors.emplace_back(_opts->buildCursor(currentDepth));
  }
  graph::EdgeCursor* cursor = _cursors.at(currentDepth).get();
  cursor->rearm(nextVertex, currentDepth);
  return cursor;
}

DepthFirstEnumerator::DepthFirstEnumerator(Traverser* traverser, TraverserOptions* opts)
    : PathEnumerator(traverser, opts), _activeCursors(0), _pruneNext(false) {}

DepthFirstEnumerator::~DepthFirstEnumerator() = default;

void DepthFirstEnumerator::setStartVertex(arangodb::velocypack::StringRef startVertex) {
  PathEnumerator::setStartVertex(startVertex);

  _activeCursors = 0;
  _pruneNext = false;
}

bool DepthFirstEnumerator::next() {
  if (_isFirst) {
    _isFirst = false;
    if (shouldPrune()) {
      _pruneNext = true;
    }
    if (_opts->minDepth == 0) {
      if (_opts->usesPostFilter()) {
        auto evaluator = _opts->getPostFilterEvaluator();
        if (usePostFilter(evaluator)) {
          return true;
        }
      } else {
        return true;
      }
    }
  }
  if (_enumeratedPath.numVertices() == 0) {
    // We are done;
    return false;
  }

  while (true) {
    if (_enumeratedPath.numEdges() < _opts->maxDepth && !_pruneNext) {
      // We are not done with this path, so
      // we reserve the cursor for next depth
      graph::EdgeCursor* cursor =
          getCursor(arangodb::velocypack::StringRef(_enumeratedPath.lastVertex()),
                    _enumeratedPath.numEdges());
      incHttpRequests(cursor->httpRequests());
      ++_activeCursors;
    } else {
      if (_enumeratedPath.numEdges() > 0) {
        // This path is at the end. cut the last step
        _enumeratedPath.popVertex();
        _enumeratedPath.popEdge();
      }
    }
    _pruneNext = false;

    bool foundPath = false;

    auto callback = [&](graph::EdgeDocumentToken&& eid, VPackSlice const& edge, size_t cursorId) {
      if (!keepEdge(eid, edge, arangodb::velocypack::StringRef(_enumeratedPath.lastVertex()),
                    _enumeratedPath.numEdges(), cursorId)) {
        return;
      }

      if (_opts->uniqueEdges == TraverserOptions::UniquenessLevel::PATH) {
        if (ServerState::instance()->isCoordinator()) {
          for (auto const& it : _enumeratedPath.edges()) {
            // We might already have this edge on the path.
            if (it.equalsCoordinator(eid)) {
              return;
            }
          }
        } else {
          for (auto const& it : _enumeratedPath.edges()) {
            if (it.equalsLocal(eid)) {
              return;
            }
          }
        }
      }

      // We have to check if edge and vertex is valid
      if (_traverser->getVertex(edge, _enumeratedPath)) {
        // case both are valid.
        if (_opts->uniqueVertices == TraverserOptions::UniquenessLevel::PATH) {
          auto& e = _enumeratedPath.lastVertex();
          bool foundOnce = false;
          for (auto const& it : _enumeratedPath.vertices()) {
            if (foundOnce) {
              foundOnce = false;  // if we leave with foundOnce == false we
              // found the vertex earlier
              break;
            }
            if (it == e) {
              foundOnce = true;
            }
          }
          if (!foundOnce) {
            // We found it and it was not the last element (expected)
            // This vertex is allready on the path
            _enumeratedPath.popVertex();
            return;
          }
        }

        if (!validDisjointPath()) {
          return;
        }

        _enumeratedPath.pushEdge(eid);
        foundPath = true;
      }
      // Vertex Invalid. Do neither insert edge nor vertex
    };

    while (_activeCursors > 0) {
      TRI_ASSERT(_activeCursors == _enumeratedPath.numEdges() + 1);
      auto& cursor = _cursors[_activeCursors - 1];

      if (cursor->next(callback)) {
        if (foundPath) {
          if (shouldPrune()) {
            _pruneNext = true;
          }
          if (_enumeratedPath.numEdges() < _opts->minDepth) {
            // We have a valid prefix, but do NOT return this path
            break;
          }

          if (_opts->usesPostFilter()) {
            auto evaluator = _opts->getPostFilterEvaluator();
            if (!usePostFilter(evaluator)) {
              break;
            }
          }

          return true;
        }
      } else {
        // cursor is empty.
        TRI_ASSERT(_activeCursors > 0);
        --_activeCursors;
        if (_enumeratedPath.numEdges() > 0) {
          _enumeratedPath.popEdge();
          _enumeratedPath.popVertex();
        }
      }
    }

    if (_activeCursors == 0) {
      // If we get here all cursors are exhausted.
      _enumeratedPath.clear();
      return false;
    }

    _opts->isQueryKilledCallback();
  }  // while (true)
}

arangodb::aql::AqlValue DepthFirstEnumerator::lastVertexToAqlValue() {
  return _traverser->fetchVertexData(
      arangodb::velocypack::StringRef(_enumeratedPath.lastVertex()));
}

arangodb::aql::AqlValue DepthFirstEnumerator::lastEdgeToAqlValue() {
  if (_enumeratedPath.numEdges() == 0) {
    return arangodb::aql::AqlValue(arangodb::aql::AqlValueHintNull());
  }
  return _opts->cache()->fetchEdgeAqlResult(_enumeratedPath.lastEdge());
}

VPackSlice DepthFirstEnumerator::pathToSlice(VPackBuilder& result, bool fromPrune) {
  result.clear();
  result.openObject();
  if (fromPrune || _opts->producePathsEdges()) {
    result.add(StaticStrings::GraphQueryEdges, VPackValue(VPackValueType::Array));
    for (auto const& it : _enumeratedPath.edges()) {
      _opts->cache()->insertEdgeIntoResult(it, result);
    }
    result.close();
  }
  if (fromPrune || _opts->producePathsVertices()) {
    result.add(StaticStrings::GraphQueryVertices, VPackValue(VPackValueType::Array));
    for (auto const& it : _enumeratedPath.vertices()) {
      _traverser->addVertexToVelocyPack(VPackStringRef(it), result);
    }
    result.close();
  }
  result.close();
  TRI_ASSERT(result.isClosed());
  return result.slice();
}

arangodb::aql::AqlValue DepthFirstEnumerator::pathToAqlValue(VPackBuilder& result) {
  return arangodb::aql::AqlValue(pathToSlice(result, false));
}

bool DepthFirstEnumerator::shouldPrune() {
  // We need to call prune here
  if (!_opts->usesPrune()) {
    return false;
  }

  transaction::BuilderLeaser pathBuilder(_opts->trx());
  // evaluator->evaluate() might access these, so they have to live long
  // enough
  aql::AqlValue vertex, edge;
  aql::AqlValueGuard vertexGuard{vertex, true}, edgeGuard{edge, true};

  aql::PruneExpressionEvaluator* evaluator = _opts->getPruneEvaluator();
  TRI_ASSERT(evaluator != nullptr);

  if (evaluator->needsVertex()) {
    vertex = lastVertexToAqlValue();
    evaluator->injectVertex(vertex.slice());
  }
  if (evaluator->needsEdge()) {
    edge = lastEdgeToAqlValue();
    evaluator->injectEdge(edge.slice());
  }
  if (evaluator->needsPath()) {
    VPackSlice path = pathToSlice(*pathBuilder.get(), true);
    evaluator->injectPath(path);
  }
  return evaluator->evaluate();
}

#ifndef USE_ENTERPRISE
bool DepthFirstEnumerator::validDisjointPath() const {
  return true;
}
#endif


text:
Ui.LBox.extend('Ui.DropBox', {
	watchers: undefined,
	allowedTypes: undefined,

	constructor: function(config) {
		this.addEvents('drageffect', 'dragenter', 'dragleave', 'drop', 'dropfile');
		this.watchers = [];
		this.connect(this, 'dragover', this.onDragOver);
	},

	addType: function(type, effects) {
		if(typeof(type) === 'string')
			type = type.toLowerCase();
		if(this.allowedTypes === undefined)
			this.allowedTypes = [];
		if(typeof(effects) === 'string')
			effects = [ effects ];
		if(typeof(effects) !== 'function') {
			for(var i = 0; i < effects.length; i++) {
				var effect = effects[i];
				if(typeof(effect) === 'string')
					effect = { action: effect };
				if(!('text' in effect)) {
					if(effect.action === 'copy')
						effect.text = 'Copier';
					else if(effect.action === 'move')
						effect.text = 'Déplacer';
					else if(effect.action === 'link')
						effect.text = 'Lier';
					else
						effect.text = effect.action;
				}
				if(!('dragicon' in effect))
					effect.dragicon = 'drag'+effect.action;
				effects[i] = effect;
			}
		}
		this.allowedTypes.push({ type: type, effect: effects });
	},

	onDragOver: function(event) {
		//console.log(this+'.onDragOver');
		//console.log(event.dataTransfer.draggable);

		// test if we already captured this dataTransfer
		var found = false;
		for(var i = 0; !found && (i < this.watchers.length); i++)
			found = (this.watchers[i].getDataTransfer() === event.dataTransfer);

		if(!found) {
			// get allowed effect for the given dataTransfer
			var effect = this.onDragEffect(event.dataTransfer);
			if((effect !== undefined) && (effect.length > 0)) {
				// capture the dataTransfer
				var watcher = event.dataTransfer.capture(this, effect);
				this.watchers.push(watcher);
				this.connect(watcher, 'move', this.onWatcherMove);
				this.connect(watcher, 'drop', this.onWatcherDrop);
				this.connect(watcher, 'leave', this.onWatcherLeave);
				event.stopImmediatePropagation();

				this.onWatcherEnter(watcher);
			}
		}
		// we are already interrested
		else
			event.stopImmediatePropagation();
	},

	getWatchers: function() {
		return this.watchers;
	},

	onWatcherEnter: function(watcher) {
		this.onDragEnter(watcher.getDataTransfer());
	},

	onWatcherMove: function(watcher) {
	},

	onWatcherDrop: function(watcher, effect, x, y) {
		var point = this.pointFromWindow(new Ui.Point({ x: x, y: y }));
		this.onDrop(watcher.getDataTransfer(), effect, point.getX(), point.getY());
	},

	onWatcherLeave: function(watcher) {
		var found = false;
		var i = 0;
		for(; !found && (i < this.watchers.length); i++) {
			found = (this.watchers[i] === watcher);
		}
		i--;
		if(found)
			this.watchers.splice(i, 1);
		if(this.watchers.length === 0)
			this.onDragLeave();
	},

	getAllowedTypesEffect: function(dataTransfer) {
		if(this.allowedTypes !== undefined) {
			var data = dataTransfer.getData();
			var effect = undefined;
			for(var i = 0; (effect === undefined) && (i < this.allowedTypes.length); i++) {
				var type = this.allowedTypes[i];
				if(typeof(type.type) === 'string') {
					if(type.type === 'all')
						effect = type.effect;
					else if(Ui.DragNativeData.hasInstance(data)) {
				 		if((type.type === 'files') && data.hasFiles())
				 			effect = type.effect;
				 		else if(((type.type === 'text') || (type.type === 'text/plain')) && data.hasTypes('text/plain', 'text'))
				 			effect = type.effect;
				 		else if(data.hasType(type.type))
							effect = type.effect;
				 	}
				}
				else if(type.type.hasInstance(data))
					effect = type.effect;
			}
			if(typeof(effect) === 'function') {
				var effects = this.onDragEffectFunction(dataTransfer, effect);

				for(var i = 0; i < effects.length; i++) {
					var effect = effects[i];
					if(typeof(effect) === 'string')
						effect = { action: effect };
					if(!('text' in effect)) {
						if(effect.action === 'copy')
							effect.text = 'Copier';
						else if(effect.action === 'move')
							effect.text = 'Déplacer';
						else if(effect.action === 'link')
							effect.text = 'Lier';
						else if(effect.action === 'run')
							effect.text = 'Exécuter';
						else if(effect.action === 'play')
							effect.text = 'Jouer';
						else
							effect.text = effect.action;
					}
					if(!('dragicon' in effect))
						effect.dragicon = 'drag'+effect.action;
					effects[i] = effect;
				}
				effect = effects;
			}
			if(effect === undefined)
				effect = [];
			return effect;
		}
		else
			return [];
	},

	//
	// Override to allow a drop for the given dataTransfer.
	// This method return the possible allowed effect [move|copy|link|...] in an array
	//
	onDragEffect: function(dataTransfer) {
		var dragEvent = new Ui.DragEvent({
			type: 'drageffect', bubbles: false,
			dataTransfer: dataTransfer
		});
		dragEvent.dispatchEvent(this);
		var effectAllowed = dragEvent.getEffectAllowed();
		if(effectAllowed !== undefined)
			return dragEvent.getEffectAllowed();
		else
			return this.getAllowedTypesEffect(dataTransfer);
	},

	onDragEffectFunction: function(dataTransfer, func) {
		return func(dataTransfer.getData(), dataTransfer);
	},

	//
	// Override to get the drop when it happends. The default
	// action is to raise the 'drop' event.
	//
	onDrop: function(dataTransfer, dropEffect, x, y) {
		var done = false;
		if(!this.fireEvent('drop', this, dataTransfer.getData(), dropEffect, x, y, dataTransfer)) {
			var data = dataTransfer.getData();
			if(Ui.DragNativeData.hasInstance(data) && data.hasFiles()) {
				var files = data.getFiles();
				var done = true;
				for(var i = 0; i < files.length; i++)
					done &= this.fireEvent('dropfile', this, files[i], dropEffect, x, y);
			}
		}
		else
			done = true;
		return done;
	},

	//
	// Override to do something when the first allowed drag enter the element.
	// The default action is to raise the 'dragenter' event
	//
	onDragEnter: function(dataTransfer) {
		this.fireEvent('dragenter', this, dataTransfer.getData());
	},

	//
	// Override to do something when the last allowed drag leave the element.
	// The default action is to raise the 'dragleave' event
	//
	onDragLeave: function() {
		this.fireEvent('dragleave', this);
	}
});


text:
package util;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.EntityTransaction;
import javax.persistence.Persistence;

/**
 * @author Maxim
 */
public class JPAUtil
{
    private static final String PERSISTENCE_UNIT_NAME = "school";
    private static EntityManagerFactory entityManagerFactory;
    private static ThreadLocal<EntityManager> manager = new ThreadLocal<EntityManager>();

    public static synchronized EntityManager getEntityManager()
    {
        if (entityManagerFactory == null) {
            entityManagerFactory = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT_NAME);
        }

        EntityManager em = manager.get();

        if (em == null || !em.isOpen()) {
            em = entityManagerFactory.createEntityManager();
            manager.set(em);
        }
        return em;
    }

    public static void closeEntityManager() {
        EntityManager em = manager.get();
        if (em != null) {
            EntityTransaction tx = em.getTransaction();
            if (tx.isActive()) {
                    tx.commit();
            }
            em.close();
            manager.set(null);
        }
    }

    public static void closeEntityManagerFactory(){
        closeEntityManager();
        entityManagerFactory.close();
    }

	private JPAUtil() {}

}


text:
package net.sf.jasperreports.charts.base;

import java.io.IOException;
import java.io.ObjectInputStream;

import net.sf.jasperreports.charts.JRItemLabel;
import net.sf.jasperreports.charts.JRPie3DPlot;
import net.sf.jasperreports.engine.JRChart;
import net.sf.jasperreports.engine.JRChartPlot;
import net.sf.jasperreports.engine.JRConstants;
import net.sf.jasperreports.engine.JRExpressionCollector;
import net.sf.jasperreports.engine.base.JRBaseChartPlot;
import net.sf.jasperreports.engine.base.JRBaseObjectFactory;

/**
 * @author Teodor Danciu (teodord@users.sourceforge.net)
 * @version $Id: JRBasePie3DPlot.java 7199 2014-08-27 13:58:10Z teodord $
 */
public class JRBasePie3DPlot extends JRBaseChartPlot implements JRPie3DPlot
{

	/**
	 *
	 */
	private static final long serialVersionUID = JRConstants.SERIAL_VERSION_UID;

	public static final String PROPERTY_CIRCULAR = "isCircular";

	public static final String PROPERTY_DEPTH_FACTOR = "depthFactor";

	public static final String PROPERTY_LABEL_FORMAT = "labelFormat";
	public static final String PROPERTY_LEGEND_LABEL_FORMAT = "legendLabelFormat";
	public static final String PROPERTY_ITEM_LABEL = "itemLabel";
	public static final String PROPERTY_SHOW_LABELS = "isShowLabels";

	protected Double depthFactorDouble;
	protected Boolean circular;
	protected String labelFormat;
	protected String legendLabelFormat;

	protected JRItemLabel itemLabel;
	protected Boolean showLabels;

	/**
	 *
	 */
	public JRBasePie3DPlot(JRChartPlot chartPlot, JRChart chart)
	{
		super(chartPlot, chart);

		JRPie3DPlot pie3DPlot = chartPlot instanceof JRPie3DPlot ? (JRPie3DPlot)chartPlot : null;

		if (pie3DPlot == null)
		{
			itemLabel = new JRBaseItemLabel(null, chart);
		}
		else
		{
			itemLabel = new JRBaseItemLabel(pie3DPlot.getItemLabel(), chart);
		}
	}

	/**
	 *
	 */
	public JRBasePie3DPlot(JRPie3DPlot pie3DPlot, JRBaseObjectFactory factory)
	{
		super(pie3DPlot, factory);

		depthFactorDouble = pie3DPlot.getDepthFactorDouble();
		circular = pie3DPlot.getCircular();
		labelFormat = pie3DPlot.getLabelFormat();
		legendLabelFormat = pie3DPlot.getLegendLabelFormat();
		itemLabel = new JRBaseItemLabel(pie3DPlot.getItemLabel(), factory);
		showLabels = pie3DPlot.getShowLabels();
	}

	/**
	 *
	 */
	public Double getDepthFactorDouble()
	{
		return depthFactorDouble;
	}

	/**
	 *
	 */
	public JRItemLabel getItemLabel()
	{
		return itemLabel;
	}

	/**
	 *
	 */
	public void setDepthFactor(Double depthFactor)
	{
		Double old = this.depthFactorDouble;
		this.depthFactorDouble = depthFactor;
		getEventSupport().firePropertyChange(PROPERTY_DEPTH_FACTOR, old, this.depthFactorDouble);
	}

	/**
	 *
	 */
	public void collectExpressions(JRExpressionCollector collector)
	{
	}

	/**
	 *
	 */
	public Boolean getCircular() {
		return circular;
	}

	/**
	 * @param isCircular the isCircular to set
	 */
	public void setCircular(Boolean isCircular) {
		Boolean old = this.circular;
		this.circular = isCircular;
		getEventSupport().firePropertyChange(PROPERTY_CIRCULAR, old, this.circular);
	}

	/**
	 * @return the labelFormat
	 */
	public String getLabelFormat() {
		return labelFormat;
	}

	/**
	 * @param labelFormat the labelFormat to set
	 */
	public void setLabelFormat(String labelFormat) {
		String old = this.labelFormat;
		this.labelFormat = labelFormat;
		getEventSupport().firePropertyChange(PROPERTY_LABEL_FORMAT, old, this.labelFormat);
	}

	/**
	 * @return the legendLabelFormat
	 */
	public String getLegendLabelFormat() {
		return legendLabelFormat;
	}

	/**
	 * @param legendLabelFormat the legendLabelFormat to set
	 */
	public void setLegendLabelFormat(String legendLabelFormat) {
		String old = this.legendLabelFormat;
		this.legendLabelFormat = legendLabelFormat;
		getEventSupport().firePropertyChange(PROPERTY_LEGEND_LABEL_FORMAT, old, this.legendLabelFormat);
	}

	/**
	 * @param itemLabel the itemLabel to set
	 */
	public void setItemLabel(JRItemLabel itemLabel) {
		JRItemLabel old = this.itemLabel;
		this.itemLabel = itemLabel;
		getEventSupport().firePropertyChange(PROPERTY_ITEM_LABEL, old, this.itemLabel);
	}

	/**
	 *
	 */
	public Boolean getShowLabels(){
		return showLabels;
	}

	/**
	 *
	 */
	public void setShowLabels( Boolean showLabels ){
		Boolean old = this.showLabels;
		this.showLabels = showLabels;
		getEventSupport().firePropertyChange(PROPERTY_SHOW_LABELS, old, this.showLabels);
	}

	public Object clone(JRChart parentChart)
	{
		JRBasePie3DPlot clone = (JRBasePie3DPlot) super.clone(parentChart);
		clone.itemLabel = itemLabel == null ? null : itemLabel.clone(parentChart);
		return clone;
	}

	/*
	 * These fields are only for serialization backward compatibility.
	 */
	private int PSEUDO_SERIAL_VERSION_UID = JRConstants.PSEUDO_SERIAL_VERSION_UID; //NOPMD
	/**
	 * @deprecated
	 */
	private double depthFactor = DEPTH_FACTOR_DEFAULT;
	/**
	 * @deprecated
	 */
	private boolean isCircular;

	private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException
	{
		in.defaultReadObject();

		if (PSEUDO_SERIAL_VERSION_UID < JRConstants.PSEUDO_SERIAL_VERSION_UID_3_1_3)
		{
			depthFactorDouble = new Double(depthFactor);
			circular = Boolean.valueOf(isCircular);
		}
	}

}


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

#ifndef TEST_VECTOR2_H
#define TEST_VECTOR2_H

#include "core/math/vector2.h"
#include "core/math/vector2i.h"
#include "tests/test_macros.h"

namespace TestVector2 {

TEST_CASE("[Vector2] Constructor methods") {
	const Vector2 vector_empty = Vector2();
	const Vector2 vector_zero = Vector2(0.0, 0.0);
	CHECK_MESSAGE(
			vector_empty == vector_zero,
			"Vector2 Constructor with no inputs should return a zero Vector2.");
}

TEST_CASE("[Vector2] Angle methods") {
	const Vector2 vector_x = Vector2(1, 0);
	const Vector2 vector_y = Vector2(0, 1);
	CHECK_MESSAGE(
			Math::is_equal_approx(vector_x.angle_to(vector_y), (real_t)Math_TAU / 4),
			"Vector2 angle_to should work as expected.");
	CHECK_MESSAGE(
			Math::is_equal_approx(vector_y.angle_to(vector_x), (real_t)-Math_TAU / 4),
			"Vector2 angle_to should work as expected.");
	CHECK_MESSAGE(
			Math::is_equal_approx(vector_x.angle_to_point(vector_y), (real_t)Math_TAU * 3 / 8),
			"Vector2 angle_to_point should work as expected.");
	CHECK_MESSAGE(
			Math::is_equal_approx(vector_y.angle_to_point(vector_x), (real_t)-Math_TAU / 8),
			"Vector2 angle_to_point should work as expected.");
}

TEST_CASE("[Vector2] Axis methods") {
	Vector2 vector = Vector2(1.2, 3.4);
	CHECK_MESSAGE(
			vector.max_axis_index() == Vector2::Axis::AXIS_Y,
			"Vector2 max_axis_index should work as expected.");
	CHECK_MESSAGE(
			vector.min_axis_index() == Vector2::Axis::AXIS_X,
			"Vector2 min_axis_index should work as expected.");
	CHECK_MESSAGE(
			vector[vector.min_axis_index()] == (real_t)1.2,
			"Vector2 array operator should work as expected.");
	vector[Vector2::Axis::AXIS_Y] = 3.7;
	CHECK_MESSAGE(
			vector[Vector2::Axis::AXIS_Y] == (real_t)3.7,
			"Vector2 array operator setter should work as expected.");
}

TEST_CASE("[Vector2] Interpolation methods") {
	const Vector2 vector1 = Vector2(1, 2);
	const Vector2 vector2 = Vector2(4, 5);
	CHECK_MESSAGE(
			vector1.lerp(vector2, 0.5) == Vector2(2.5, 3.5),
			"Vector2 lerp should work as expected.");
	CHECK_MESSAGE(
			vector1.lerp(vector2, 1.0 / 3.0).is_equal_approx(Vector2(2, 3)),
			"Vector2 lerp should work as expected.");
	CHECK_MESSAGE(
			vector1.normalized().slerp(vector2.normalized(), 0.5).is_equal_approx(Vector2(0.538953602313995361, 0.84233558177947998)),
			"Vector2 slerp should work as expected.");
	CHECK_MESSAGE(
			vector1.normalized().slerp(vector2.normalized(), 1.0 / 3.0).is_equal_approx(Vector2(0.508990883827209473, 0.860771894454956055)),
			"Vector2 slerp should work as expected.");
	CHECK_MESSAGE(
			Vector2(5, 0).slerp(Vector2(0, 5), 0.5).is_equal_approx(Vector2(5, 5) * Math_SQRT12),
			"Vector2 slerp with non-normalized values should work as expected.");
	CHECK_MESSAGE(
			Vector2(1, 1).slerp(Vector2(2, 2), 0.5).is_equal_approx(Vector2(1.5, 1.5)),
			"Vector2 slerp with colinear inputs should behave as expected.");
	CHECK_MESSAGE(
			Vector2().slerp(Vector2(), 0.5) == Vector2(),
			"Vector2 slerp with both inputs as zero vectors should return a zero vector.");
	CHECK_MESSAGE(
			Vector2().slerp(Vector2(1, 1), 0.5) == Vector2(0.5, 0.5),
			"Vector2 slerp with one input as zero should behave like a regular lerp.");
	CHECK_MESSAGE(
			Vector2(1, 1).slerp(Vector2(), 0.5) == Vector2(0.5, 0.5),
			"Vector2 slerp with one input as zero should behave like a regular lerp.");
	CHECK_MESSAGE(
			Vector2(4, 6).slerp(Vector2(8, 10), 0.5).is_equal_approx(Vector2(5.9076470794008017626, 8.07918879020090480697)),
			"Vector2 slerp should work as expected.");
	CHECK_MESSAGE(
			Math::is_equal_approx(vector1.slerp(vector2, 0.5).length(), (real_t)4.31959610746631919),
			"Vector2 slerp with different length input should return a vector with an interpolated length.");
	CHECK_MESSAGE(
			Math::is_equal_approx(vector1.angle_to(vector1.slerp(vector2, 0.5)) * 2, vector1.angle_to(vector2)),
			"Vector2 slerp with different length input should return a vector with an interpolated angle.");
	CHECK_MESSAGE(
			vector1.cubic_interpolate(vector2, Vector2(), Vector2(7, 7), 0.5) == Vector2(2.375, 3.5),
			"Vector2 cubic_interpolate should work as expected.");
	CHECK_MESSAGE(
			vector1.cubic_interpolate(vector2, Vector2(), Vector2(7, 7), 1.0 / 3.0).is_equal_approx(Vector2(1.851851940155029297, 2.962963104248046875)),
			"Vector2 cubic_interpolate should work as expected.");
	CHECK_MESSAGE(
			Vector2(1, 0).move_toward(Vector2(10, 0), 3) == Vector2(4, 0),
			"Vector2 move_toward should work as expected.");
}

TEST_CASE("[Vector2] Length methods") {
	const Vector2 vector1 = Vector2(10, 10);
	const Vector2 vector2 = Vector2(20, 30);
	CHECK_MESSAGE(
			vector1.length_squared() == 200,
			"Vector2 length_squared should work as expected and return exact result.");
	CHECK_MESSAGE(
			Math::is_equal_approx(vector1.length(), 10 * (real_t)Math_SQRT2),
			"Vector2 length should work as expected.");
	CHECK_MESSAGE(
			vector2.length_squared() == 1300,
			"Vector2 length_squared should work as expected and return exact result.");
	CHECK_MESSAGE(
			Math::is_equal_approx(vector2.length(), (real_t)36.05551275463989293119),
			"Vector2 length should work as expected.");
	CHECK_MESSAGE(
			vector1.distance_squared_to(vector2) == 500,
			"Vector2 distance_squared_to should work as expected and return exact result.");
	CHECK_MESSAGE(
			Math::is_equal_approx(vector1.distance_to(vector2), (real_t)22.36067977499789696409),
			"Vector2 distance_to should work as expected.");
}

TEST_CASE("[Vector2] Limiting methods") {
	const Vector2 vector = Vector2(10, 10);
	CHECK_MESSAGE(
			vector.limit_length().is_equal_approx(Vector2(Math_SQRT12, Math_SQRT12)),
			"Vector2 limit_length should work as expected.");
	CHECK_MESSAGE(
			vector.limit_length(5).is_equal_approx(5 * Vector2(Math_SQRT12, Math_SQRT12)),
			"Vector2 limit_length should work as expected.");

	CHECK_MESSAGE(
			Vector2(-5, 15).clamp(Vector2(), vector).is_equal_approx(Vector2(0, 10)),
			"Vector2 clamp should work as expected.");
	CHECK_MESSAGE(
			vector.clamp(Vector2(0, 15), Vector2(5, 20)).is_equal_approx(Vector2(5, 15)),
			"Vector2 clamp should work as expected.");
}

TEST_CASE("[Vector2] Normalization methods") {
	CHECK_MESSAGE(
			Vector2(1, 0).is_normalized() == true,
			"Vector2 is_normalized should return true for a normalized vector.");
	CHECK_MESSAGE(
			Vector2(1, 1).is_normalized() == false,
			"Vector2 is_normalized should return false for a non-normalized vector.");
	CHECK_MESSAGE(
			Vector2(1, 0).normalized() == Vector2(1, 0),
			"Vector2 normalized should return the same vector for a normalized vector.");
	CHECK_MESSAGE(
			Vector2(1, 1).normalized().is_equal_approx(Vector2(Math_SQRT12, Math_SQRT12)),
			"Vector2 normalized should work as expected.");

	Vector2 vector = Vector2(3.2, -5.4);
	vector.normalize();
	CHECK_MESSAGE(
			vector == Vector2(3.2, -5.4).normalized(),
			"Vector2 normalize should convert same way as Vector2 normalized.");
	CHECK_MESSAGE(
			vector.is_equal_approx(Vector2(0.509802390301732898898, -0.860291533634174266891)),
			"Vector2 normalize should work as expected.");
}

TEST_CASE("[Vector2] Operators") {
	const Vector2 decimal1 = Vector2(2.3, 4.9);
	const Vector2 decimal2 = Vector2(1.2, 3.4);
	const Vector2 power1 = Vector2(0.75, 1.5);
	const Vector2 power2 = Vector2(0.5, 0.125);
	const Vector2 int1 = Vector2(4, 5);
	const Vector2 int2 = Vector2(1, 2);

	CHECK_MESSAGE(
			(decimal1 + decimal2).is_equal_approx(Vector2(3.5, 8.3)),
			"Vector2 addition should behave as expected.");
	CHECK_MESSAGE(
			(power1 + power2) == Vector2(1.25, 1.625),
			"Vector2 addition with powers of two should give exact results.");
	CHECK_MESSAGE(
			(int1 + int2) == Vector2(5, 7),
			"Vector2 addition with integers should give exact results.");

	CHECK_MESSAGE(
			(decimal1 - decimal2).is_equal_approx(Vector2(1.1, 1.5)),
			"Vector2 subtraction should behave as expected.");
	CHECK_MESSAGE(
			(power1 - power2) == Vector2(0.25, 1.375),
			"Vector2 subtraction with powers of two should give exact results.");
	CHECK_MESSAGE(
			(int1 - int2) == Vector2(3, 3),
			"Vector2 subtraction with integers should give exact results.");

	CHECK_MESSAGE(
			(decimal1 * decimal2).is_equal_approx(Vector2(2.76, 16.66)),
			"Vector2 multiplication should behave as expected.");
	CHECK_MESSAGE(
			(power1 * power2) == Vector2(0.375, 0.1875),
			"Vector2 multiplication with powers of two should give exact results.");
	CHECK_MESSAGE(
			(int1 * int2) == Vector2(4, 10),
			"Vector2 multiplication with integers should give exact results.");

	CHECK_MESSAGE(
			(decimal1 / decimal2).is_equal_approx(Vector2(1.91666666666666666, 1.44117647058823529)),
			"Vector2 division should behave as expected.");
	CHECK_MESSAGE(
			(power1 / power2) == Vector2(1.5, 12.0),
			"Vector2 division with powers of two should give exact results.");
	CHECK_MESSAGE(
			(int1 / int2) == Vector2(4, 2.5),
			"Vector2 division with integers should give exact results.");

	CHECK_MESSAGE(
			(decimal1 * 2).is_equal_approx(Vector2(4.6, 9.8)),
			"Vector2 multiplication should behave as expected.");
	CHECK_MESSAGE(
			(power1 * 2) == Vector2(1.5, 3),
			"Vector2 multiplication with powers of two should give exact results.");
	CHECK_MESSAGE(
			(int1 * 2) == Vector2(8, 10),
			"Vector2 multiplication with integers should give exact results.");

	CHECK_MESSAGE(
			(decimal1 / 2).is_equal_approx(Vector2(1.15, 2.45)),
			"Vector2 division should behave as expected.");
	CHECK_MESSAGE(
			(power1 / 2) == Vector2(0.375, 0.75),
			"Vector2 division with powers of two should give exact results.");
	CHECK_MESSAGE(
			(int1 / 2) == Vector2(2, 2.5),
			"Vector2 division with integers should give exact results.");

	CHECK_MESSAGE(
			((Vector2i)decimal1) == Vector2i(2, 4),
			"Vector2 cast to Vector2i should work as expected.");
	CHECK_MESSAGE(
			((Vector2i)decimal2) == Vector2i(1, 3),
			"Vector2 cast to Vector2i should work as expected.");
	CHECK_MESSAGE(
			Vector2(Vector2i(1, 2)) == Vector2(1, 2),
			"Vector2 constructed from Vector2i should work as expected.");

	CHECK_MESSAGE(
			((String)decimal1) == "(2.3, 4.9)",
			"Vector2 cast to String should work as expected.");
	CHECK_MESSAGE(
			((String)decimal2) == "(1.2, 3.4)",
			"Vector2 cast to String should work as expected.");
	CHECK_MESSAGE(
			((String)Vector2(9.8, 9.9)) == "(9.8, 9.9)",
			"Vector2 cast to String should work as expected.");
#ifdef REAL_T_IS_DOUBLE
	CHECK_MESSAGE(
			((String)Vector2(Math_PI, Math_TAU)) == "(3.14159265358979, 6.28318530717959)",
			"Vector2 cast to String should print the correct amount of digits for real_t = double.");
#else
	CHECK_MESSAGE(
			((String)Vector2(Math_PI, Math_TAU)) == "(3.141593, 6.283185)",
			"Vector2 cast to String should print the correct amount of digits for real_t = float.");
#endif // REAL_T_IS_DOUBLE
}

TEST_CASE("[Vector2] Other methods") {
	const Vector2 vector = Vector2(1.2, 3.4);
	CHECK_MESSAGE(
			Math::is_equal_approx(vector.aspect(), (real_t)1.2 / (real_t)3.4),
			"Vector2 aspect should work as expected.");

	CHECK_MESSAGE(
			vector.direction_to(Vector2()).is_equal_approx(-vector.normalized()),
			"Vector2 direction_to should work as expected.");
	CHECK_MESSAGE(
			Vector2(1, 1).direction_to(Vector2(2, 2)).is_equal_approx(Vector2(Math_SQRT12, Math_SQRT12)),
			"Vector2 direction_to should work as expected.");

	CHECK_MESSAGE(
			vector.posmod(2).is_equal_approx(Vector2(1.2, 1.4)),
			"Vector2 posmod should work as expected.");
	CHECK_MESSAGE(
			(-vector).posmod(2).is_equal_approx(Vector2(0.8, 0.6)),
			"Vector2 posmod should work as expected.");
	CHECK_MESSAGE(
			vector.posmodv(Vector2(1, 2)).is_equal_approx(Vector2(0.2, 1.4)),
			"Vector2 posmodv should work as expected.");
	CHECK_MESSAGE(
			(-vector).posmodv(Vector2(2, 3)).is_equal_approx(Vector2(0.8, 2.6)),
			"Vector2 posmodv should work as expected.");

	CHECK_MESSAGE(
			vector.rotated(Math_TAU).is_equal_approx(Vector2(1.2, 3.4)),
			"Vector2 rotated should work as expected.");
	CHECK_MESSAGE(
			vector.rotated(Math_TAU / 4).is_equal_approx(Vector2(-3.4, 1.2)),
			"Vector2 rotated should work as expected.");
	CHECK_MESSAGE(
			vector.rotated(Math_TAU / 3).is_equal_approx(Vector2(-3.544486372867091398996, -0.660769515458673623883)),
			"Vector2 rotated should work as expected.");
	CHECK_MESSAGE(
			vector.rotated(Math_TAU / 2).is_equal_approx(vector.rotated(Math_TAU / -2)),
			"Vector2 rotated should work as expected.");

	CHECK_MESSAGE(
			vector.snapped(Vector2(1, 1)) == Vector2(1, 3),
			"Vector2 snapped to integers should be the same as rounding.");
	CHECK_MESSAGE(
			Vector2(3.4, 5.6).snapped(Vector2(1, 1)) == Vector2(3, 6),
			"Vector2 snapped to integers should be the same as rounding.");
	CHECK_MESSAGE(
			vector.snapped(Vector2(0.25, 0.25)) == Vector2(1.25, 3.5),
			"Vector2 snapped to 0.25 should give exact results.");

	CHECK_MESSAGE(
			Vector2(1.2, 2.5).is_equal_approx(vector.min(Vector2(3.0, 2.5))),
			"Vector2 min should return expected value.");

	CHECK_MESSAGE(
			Vector2(5.3, 3.4).is_equal_approx(vector.max(Vector2(5.3, 2.0))),
			"Vector2 max should return expected value.");
}

TEST_CASE("[Vector2] Plane methods") {
	const Vector2 vector = Vector2(1.2, 3.4);
	const Vector2 vector_y = Vector2(0, 1);
	const Vector2 vector_normal = Vector2(0.95879811270838721622267, 0.2840883296913739899919);
	const Vector2 vector_non_normal = Vector2(5.4, 1.6);
	CHECK_MESSAGE(
			vector.bounce(vector_y) == Vector2(1.2, -3.4),
			"Vector2 bounce on a plane with normal of the Y axis should.");
	CHECK_MESSAGE(
			vector.bounce(vector_normal).is_equal_approx(Vector2(-2.85851197982345523329, 2.197477931904161412358)),
			"Vector2 bounce with normal should return expected value.");
	CHECK_MESSAGE(
			vector.reflect(vector_y) == Vector2(-1.2, 3.4),
			"Vector2 reflect on a plane with normal of the Y axis should.");
	CHECK_MESSAGE(
			vector.reflect(vector_normal).is_equal_approx(Vector2(2.85851197982345523329, -2.197477931904161412358)),
			"Vector2 reflect with normal should return expected value.");
	CHECK_MESSAGE(
			vector.project(vector_y) == Vector2(0, 3.4),
			"Vector2 projected on the Y axis should only give the Y component.");
	CHECK_MESSAGE(
			vector.project(vector_normal).is_equal_approx(Vector2(2.0292559899117276166, 0.60126103404791929382)),
			"Vector2 projected on a normal should return expected value.");
	CHECK_MESSAGE(
			vector.slide(vector_y) == Vector2(1.2, 0),
			"Vector2 slide on a plane with normal of the Y axis should set the Y to zero.");
	CHECK_MESSAGE(
			vector.slide(vector_normal).is_equal_approx(Vector2(-0.8292559899117276166456, 2.798738965952080706179)),
			"Vector2 slide with normal should return expected value.");
	// There's probably a better way to test these ones?
	ERR_PRINT_OFF;
	CHECK_MESSAGE(
			vector.bounce(vector_non_normal).is_equal_approx(Vector2()),
			"Vector2 bounce should return empty Vector2 with non-normalised input.");
	CHECK_MESSAGE(
			vector.reflect(vector_non_normal).is_equal_approx(Vector2()),
			"Vector2 reflect should return empty Vector2 with non-normalised input.");
	CHECK_MESSAGE(
			vector.slide(vector_non_normal).is_equal_approx(Vector2()),
			"Vector2 slide should return empty Vector2 with non-normalised input.");
	ERR_PRINT_ON;
}

TEST_CASE("[Vector2] Rounding methods") {
	const Vector2 vector1 = Vector2(1.2, 5.6);
	const Vector2 vector2 = Vector2(1.2, -5.6);
	CHECK_MESSAGE(
			vector1.abs() == vector1,
			"Vector2 abs should work as expected.");
	CHECK_MESSAGE(
			vector2.abs() == vector1,
			"Vector2 abs should work as expected.");

	CHECK_MESSAGE(
			vector1.ceil() == Vector2(2, 6),
			"Vector2 ceil should work as expected.");
	CHECK_MESSAGE(
			vector2.ceil() == Vector2(2, -5),
			"Vector2 ceil should work as expected.");

	CHECK_MESSAGE(
			vector1.floor() == Vector2(1, 5),
			"Vector2 floor should work as expected.");
	CHECK_MESSAGE(
			vector2.floor() == Vector2(1, -6),
			"Vector2 floor should work as expected.");

	CHECK_MESSAGE(
			vector1.round() == Vector2(1, 6),
			"Vector2 round should work as expected.");
	CHECK_MESSAGE(
			vector2.round() == Vector2(1, -6),
			"Vector2 round should work as expected.");

	CHECK_MESSAGE(
			vector1.sign() == Vector2(1, 1),
			"Vector2 sign should work as expected.");
	CHECK_MESSAGE(
			vector2.sign() == Vector2(1, -1),
			"Vector2 sign should work as expected.");
}

TEST_CASE("[Vector2] Linear algebra methods") {
	const Vector2 vector_x = Vector2(1, 0);
	const Vector2 vector_y = Vector2(0, 1);
	const Vector2 a = Vector2(3.5, 8.5);
	const Vector2 b = Vector2(5.2, 4.6);
	CHECK_MESSAGE(
			vector_x.cross(vector_y) == 1,
			"Vector2 cross product of X and Y should give 1.");
	CHECK_MESSAGE(
			vector_y.cross(vector_x) == -1,
			"Vector2 cross product of Y and X should give negative 1.");
	CHECK_MESSAGE(
			Math::is_equal_approx(a.cross(b), (real_t)-28.1),
			"Vector2 cross should return expected value.");
	CHECK_MESSAGE(
			Math::is_equal_approx(Vector2(-a.x, a.y).cross(Vector2(b.x, -b.y)), (real_t)-28.1),
			"Vector2 cross should return expected value.");

	CHECK_MESSAGE(
			vector_x.dot(vector_y) == 0.0,
			"Vector2 dot product of perpendicular vectors should be zero.");
	CHECK_MESSAGE(
			vector_x.dot(vector_x) == 1.0,
			"Vector2 dot product of identical unit vectors should be one.");
	CHECK_MESSAGE(
			(vector_x * 10).dot(vector_x * 10) == 100.0,
			"Vector2 dot product of same direction vectors should behave as expected.");
	CHECK_MESSAGE(
			Math::is_equal_approx(a.dot(b), (real_t)57.3),
			"Vector2 dot should return expected value.");
	CHECK_MESSAGE(
			Math::is_equal_approx(Vector2(-a.x, a.y).dot(Vector2(b.x, -b.y)), (real_t)-57.3),
			"Vector2 dot should return expected value.");
}
} // namespace TestVector2

#endif // TEST_VECTOR2_H


text:
from django.apps import AppConfig

class CustomizeWagtailConfig(AppConfig):
    default_auto_field = 'django.db.models.BigAutoField'
    name = 'customize_wagtail'


text:
package br.com.digidev.messenger4j;

import br.com.digidev.messenger4j.receive.MessengerReceiveClientBuilder;
import br.com.digidev.messenger4j.send.MessengerSendClientBuilder;
import br.com.digidev.messenger4j.setup.MessengerSetupClientBuilder;
import br.com.digidev.messenger4j.user.UserProfileClientBuilder;

/**
 * This is the entry point for using the {@code Messenger Platform API}.
 * The {@code MessengerPlatform} returns instances of {@link MessengerReceiveClientBuilder}
 * and {@link MessengerSendClientBuilder}.
 *
 *

 * For further information on the {@code Messenger Platform} refer to:

 *
 * https://developers.facebook.com/docs/messenger-platform
 *
 *

 *
 * @author Messenger4J - http://github.com/messenger4j
 * @see MessengerReceiveClientBuilder
 * @see MessengerSendClientBuilder
 */
public final class MessengerPlatform {

    /**
     * Constant for the {@code hub.mode} request parameter name.
     */
    public static final String MODE_REQUEST_PARAM_NAME = "hub.mode";

    /**
     * Constant for the {@code hub.challenge} request parameter name.
     */
    public static final String CHALLENGE_REQUEST_PARAM_NAME = "hub.challenge";

    /**
     * Constant for the {@code hub.verify_token} request parameter name.
     */
    public static final String VERIFY_TOKEN_REQUEST_PARAM_NAME = "hub.verify_token";

    /**
     * Constant for the {@code X-Hub-Signature} header name.
     */
    public static final String SIGNATURE_HEADER_NAME = "X-Hub-Signature";

    /**
     * Private constructor to prevent instantiation.
     */
    private MessengerPlatform() {
    }

    /**
     * Returns an instance of {@code MessengerReceiveClientBuilder} that is used
     * to build instances of {@code MessengerReceiveClient}.
     *
     * @param appSecret   the {@code Application Secret} of your {@code Facebook App}
     * @param verifyToken the {@code Verification Token} that has been provided by you
     *                    during the setup of the {@code Webhook}
     * @return a {@code MessengerReceiveClientBuilder}
     */
    public static MessengerReceiveClientBuilder newReceiveClientBuilder(String appSecret, String verifyToken) {
        return new MessengerReceiveClientBuilder(appSecret, verifyToken);
    }

    /**
     * Returns an instance of {@code MessengerSendClientBuilder} that is used
     * to build instances of {@code MessengerSendClient}.
     *
     * @param pageAccessToken the generated {@code Page Access Token} of your {@code Facebook Page}
     * @return a {@code MessengerSendClientBuilder}
     */
    public static MessengerSendClientBuilder newSendClientBuilder(String pageAccessToken) {
        return new MessengerSendClientBuilder(pageAccessToken);
    }

    /**
     * @param pageAccessToken the generated {@code Page Access Token} of your {@code Facebook Page}
     * @return a {@code MessengerSetupClientBuilder}
     */
    public static MessengerSetupClientBuilder newSetupClientBuilder(String pageAccessToken) {
        return new MessengerSetupClientBuilder(pageAccessToken);
    }

    /**
     * @param pageAccessToken the generated {@code Page Access Token} of your {@code Facebook Page}
     * @return a {@code UserProfileClientBuilder}
     */
    public static UserProfileClientBuilder newUserProfileClientBuilder(String pageAccessToken) {
        return new UserProfileClientBuilder(pageAccessToken);
    }

}


text:
/*interface EventListener
 {
 void handleEvent(Event event);
 }
 interface EventTarget
 {
 void addEventListener(string type, EventListener? callback, boolean capture = false);
 void removeEventListener(string type, EventListener? callback, boolean capture	= false);
 bool dispatchEvent(Event event); //https://dom.spec.whatwg.org/#concept-event-dispatch
 }*/
//Adopted from https://github.com/WebReflection/event-target
EventTarget = (function() {

    "use strict";

    var PREFIX = "@@",
        EventTarget = {},
        descriptor = {
            // in ES5 does not bother with enumeration
            configurable: true,
            value: null
        },
        defineProperty = Object.defineProperty,
        indexOf = [].indexOf,
        has = EventTarget.hasOwnProperty;

    function configure(obj, prop, value) {
        descriptor.value = value;
        defineProperty(obj, prop, descriptor);
        descriptor.value = null;
    }

    function on(self, type, listener) {
        var array;
        if (has.call(self, type)) {
            array = self[type];
        } else {
            configure(self, type, array = []);
        }
        if (indexOf.call(array, listener) < 0) {
            array.push(listener);
        }
    }

    function dispatch(self, type, evt) {
        var array, current, i;
        if (has.call(self, type)) {
            evt.target = self;
            array = self[type].slice(0);
            for (i = 0; i < array.length; i++) {
                current = array[i];
                if (typeof current === "function") {
                    current.call(self, evt);
                } else if (typeof current.handleEvent === "function") {
                    current.handleEvent(evt);
                }
            }
        }
    }

    function off(self, type, listener) {
        var array, i;
        if (has.call(self, type)) {
            array = self[type];
            i = indexOf.call(array, listener);
            if (-1 < i) {
                array.splice(i, 1);
                if (!array.length) {
                    delete self[type];
                }
            }
        }
    }

    configure(EventTarget, "addEventListener", function addEventListener(type, listener) {
        on(this, PREFIX + type, listener);
    });

    configure(EventTarget, "dispatchEvent", function dispatchEvent(evt) {
        dispatch(this, PREFIX + evt.type, evt);
    });

    configure(EventTarget, "removeEventListener", function removeEventListener(type, listener) {
        off(this, PREFIX + type, listener);
    });

    return EventTarget;

})();

if (typeof window !== 'undefined') {
    Window.prototype.addEventListener = EventTarget.addEventListener;
    Window.prototype.removeEventListener = EventTarget.removeEventListener;
    Window.prototype.dispatchEvent = EventTarget.dispatchEvent;

    window.EventTarget = EventTarget;
}


text:
<?php

namespace Magento\Framework\Config\Test\Unit\Data;

class ScopedTest extends \PHPUnit_Framework_TestCase
{
    /**
     * @var \Magento\Framework\Config\Data\Scoped
     */
    protected $_model;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $_readerMock;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $_configScopeMock;

    /**
     * @var \PHPUnit_Framework_MockObject_MockObject
     */
    protected $_cacheMock;

    protected function setUp()
    {
        $this->_readerMock = $this->getMock('Magento\Framework\Config\ReaderInterface');
        $this->_configScopeMock = $this->getMock('Magento\Framework\Config\ScopeInterface');
        $this->_cacheMock = $this->getMock('Magento\Framework\Config\CacheInterface');

        $this->_model = new \Magento\Framework\Config\Data\Scoped(
            $this->_readerMock,
            $this->_configScopeMock,
            $this->_cacheMock,
            'tag'
        );
    }

    /**
     * @param string $path
     * @param mixed $expectedValue
     * @param string $default
     * @dataProvider getConfigByPathDataProvider
     */
    public function testgetConfigByPath($path, $expectedValue, $default)
    {
        $testData = [
            'key_1' => [
                'key_1.1' => ['key_1.1.1' => 'value_1.1.1'],
                'key_1.2' => ['some' => 'arrayValue'],
            ],
        ];
        $this->_cacheMock->expects($this->any())->method('load')->will($this->returnValue(serialize([])));
        $this->_model->merge($testData);
        $this->assertEquals($expectedValue, $this->_model->get($path, $default));
    }

    public function getConfigByPathDataProvider()
    {
        return [
            ['key_1/key_1.1/key_1.1.1', 'value_1.1.1', 'error'],
            ['key_1/key_1.2', ['some' => 'arrayValue'], 'error'],
            [
                'key_1',
                ['key_1.1' => ['key_1.1.1' => 'value_1.1.1'], 'key_1.2' => ['some' => 'arrayValue']],
                'error'
            ],
            ['key_1/notExistedKey', 'defaultValue', 'defaultValue']
        ];
    }

    public function testGetScopeSwitchingWithNonCachedData()
    {
        $testValue = ['some' => 'testValue'];

        /** change current area */
        $this->_configScopeMock->expects(
            $this->any()
        )->method(
            'getCurrentScope'
        )->will(
            $this->returnValue('adminhtml')
        );

        /** set empty cache data */
        $this->_cacheMock->expects(
            $this->once()
        )->method(
            'load'
        )->with(
            'adminhtml::tag'
        )->will(
            $this->returnValue(false)
        );

        /** get data from reader  */
        $this->_readerMock->expects(
            $this->once()
        )->method(
            'read'
        )->with(
            'adminhtml'
        )->will(
            $this->returnValue($testValue)
        );

        /** test cache saving  */
        $this->_cacheMock->expects($this->once())->method('save')->with(serialize($testValue), 'adminhtml::tag');

        /** test config value existence */
        $this->assertEquals('testValue', $this->_model->get('some'));

        /** test preventing of double config data loading from reader */
        $this->assertEquals('testValue', $this->_model->get('some'));
    }

    public function testGetScopeSwitchingWithCachedData()
    {
        $testValue = ['some' => 'testValue'];

        /** change current area */
        $this->_configScopeMock->expects(
            $this->any()
        )->method(
            'getCurrentScope'
        )->will(
            $this->returnValue('adminhtml')
        );

        /** set cache data */
        $this->_cacheMock->expects(
            $this->once()
        )->method(
            'load'
        )->with(
            'adminhtml::tag'
        )->will(
            $this->returnValue(serialize($testValue))
        );

        /** test preventing of getting data from reader  */
        $this->_readerMock->expects($this->never())->method('read');

        /** test preventing of cache saving  */
        $this->_cacheMock->expects($this->never())->method('save');

        /** test config value existence */
        $this->assertEquals('testValue', $this->_model->get('some'));

        /** test preventing of double config data loading from reader */
        $this->assertEquals('testValue', $this->_model->get('some'));
    }
}


text:
<?php

namespace MimeMailer;

use \Library\Converter\Html2Text;

/**
 * @TODO Cite all RFCs for each header field
 *
 * @author  piwi <me@e-piwi.fr>
 */
class MimeMessage
    extends AbstractMailerAware
    implements MessageInterface
{

    /**
     * @var array
     */
    protected $from;

    /**
     * @var array
     */
    protected $to;

    /**
     * @var array
     */
    protected $cc;

    /**
     * @var array
     */
    protected $bcc;

    /**
     * @var string
     */
    protected $attachment;

    /**
     * @var string
     */
    protected $subject;

    /**
     * @var string
     */
    protected $text;

    /**
     * @var string
     */
    protected $html;

    /**
     * @var int
     */
    protected $id;

    /**
     * @var string
     */
    protected $message;

    /**
     * @var array Set of clearing values
     */
    public static $clearings = array(
        'from'=>'',
        'to'=>array(),
        'cc'=>array(),
        'bcc'=>array(),
        'attachment'=>array(),
        'header'=>'',
        'subject'=>'',
        'text'=>'',
        'html'=>'',
        'id'=>null
    );

// --------------------
// Construction
// --------------------

    /**
     * Construction of a MimeEmail object
     *
     * @param string $from_name
     * @param string $from_mail
     * @param string|array $to
     * @param string $subject
     * @param string $message
     */
    public function __construct($from_name = '', $from_mail = null, $to = null, $subject = null, $message = null)
    {
        $this->_init();
        if (!is_null($from_mail)) {
            $this->setFrom($from_mail, $from_name);
        }
        if (!is_null($to)) {
            $this->setTo($to);
        }
        if (!is_null($subject)) {
            $this->setSubject($subject);
        }
        if (!is_null($message)) {
            $this->setText($message);
        }
    }

    /**
     * First initialization of the object
     *
     * @return void
     */
    protected function _init()
    {
        foreach (self::$clearings as $var=>$val) {
            $this->{$var} = $val;
        }
        if (is_null($this->id)) {
            $this->id = uniqid(time());
        }
    }

    /**
     * Initialization before sending messages
     *
     * @return void
     */
    protected function _buildInit()
    {
        $this->clear('message');

        $this->getMailer()
            ->setRegistry('boundary', $this->makeBoundary())
            ->setRegistry('boundary_ctt', $this->makeBoundary());

        // message type
        if (strlen($this->text)>0 && count($this->attachment)>0) {
            $this->getMailer()->setRegistry('message_type', 'multipart/mixed');
        } elseif (strlen($this->text)>0 && strlen($this->html)>0 && count($this->attachment)==0) {
            $this->getMailer()
                ->setRegistry('message_type', 'multipart/alternative')
                ->setRegistry('boundary_ctt', $this->getMailer()->getRegistry('boundary'));
        } else {
            $this->getMailer()->setRegistry('message_type', 'text/plain');
        }
    }

// --------------------
// Getters/Setters/Clearers
// --------------------

    /**
     * Global setter
     *
     * @param string $name
     * @param mixed $val
     * @return self
     */
    public function set($name, $val)
    {
        if (property_exists($this, $name)) {
            $this->{$name} = $val;
        }
        return $this;
    }

    /**
     * Global getter
     *
     * @param string $name
     * @return mixed
     */
    public function get($name)
    {
        return property_exists($this, $name) ? $this->{$name} : null;
    }

    /**
     * Global variable clearer
     *
     * @param string $name
     * @return self
     */
    public function clear($name = null)
    {
        if (!is_null($name)) {
            $name = strtolower($name);
            if (array_key_exists($name, self::$clearings)) {
                $this->{$name} = self::$clearings[$self::$clearings];
            }
        } else {
            foreach (self::$clearings as $n=>$v) {
                $this->{$n} = $v;
            }
        }
        return $this;
    }

    /**
     * Get a fromated address info (name <email>) for `$name` field
     *
     * @param string $name
     * @return string
     */
    public function getFormated($name)
    {
        $field_value = $this->get($name);
        return is_array($field_value) ? Helper::mailListTagger($field_value) : $field_value;
    }

    /**
     * Get message ID
     *
     * @return string
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set From field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @param bool $reply Set the "reply-to" to the same address ? (default is TRUE)
     * @return self
     * @see \MimeMailer\MimeEmail::checkPeopleArgs
     */
    public function setFrom($mail = '', $name = null, $reply = true)
    {
        $mail = trim($mail);
        if (strlen($mail) && Helper::isEmail($mail)) {
            $this->from = !empty($name) ? array($name=>$mail) : array($mail);
            $this->getMailer()->setRegistry('Return-Path', '<'.$mail.'>', 'headers');
            $this->getMailer()->setRegistry('X-Sender', $mail, 'headers');
            if ($reply) {
                $this->setReplyTo($mail, $name);
            }
        }
        return $this;
    }

    /**
     * Set To field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     * @see \MimeMailer\MimeEmail::checkPeopleArgs
     */
    public function setTo($mail = '', $name = null)
    {
        $this->to = Helper::deduplicate(
            array_merge($this->to, call_user_func_array(array('\MimeMailer\Helper', 'checkPeopleArgs'), func_get_args()))
        );
        return $this;
    }

    /**
     * Set Cc field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     * @see \MimeMailer\MimeEmail::checkPeopleArgs
     */
    public function setCc($mail = '', $name = null)
    {
        $this->cc = Helper::deduplicate(
            array_merge($this->cc, call_user_func_array(array('\MimeMailer\Helper', 'checkPeopleArgs'), func_get_args()))
        );
        return $this;
    }

    /**
     * Set Bcc field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     * @see \MimeMailer\MimeEmail::checkPeopleArgs
     */
    public function setBcc($mail = '', $name = null)
    {
        $this->bcc = Helper::deduplicate(
            array_merge($this->bcc, call_user_func_array(array('\MimeMailer\Helper', 'checkPeopleArgs'), func_get_args()))
        );
        return $this;
    }

    /**
     * Set mail file attachment
     *
     * @param string|array $file The file or files to attach
     * @param bool $clear Clear a set content first ? (default is to append a content)
     * @return self
     */
    public function setAttachment($file = '', $clear = false)
    {
        if (true===$clear) {
            $this->clear('text');
        }
        if (is_array($file)) {
            foreach ($file as $_f) {
                if (file_exists($_f)) {
                    $this->attachment[] = $_f;
                }
            }
        } else {
            if (file_exists($file)) {
                $this->attachment[] = $file;
            }
        }
        return $this;
    }

    /**
     * Set mail object
     *
     * @param string $subject The subject content
     * @param bool $clear Clear a set content first ? (default is to append a content)
     * @return self
     */
    public function setSubject($subject = '', $clear = false)
    {
        if (true===$clear) {
            $this->clear('subject');
        }
        $this->subject = $subject;
        return $this;
    }

    /**
     * Set plain text version
     *
     * If $text='auto', the text version will be generated from the HTML content
     *
     * @param string $text The plain text content or keyword 'auto' to auto-generate it from the HTML content
     * @param bool $clear Clear a set content first ? (default is to append a content)
     * @return self
     */
    public function setText($text = '', $clear = false)
    {
        if (true===$clear) {
            $this->clear('text');
        }
        if ('auto'==$text) {
            if (!empty($this->html)) {
                $html_content = preg_replace("/.*<body[^>]*>|<\/body>.*/si", "", $this->html);
                $this->text .= Helper::formatText(Helper::html2text($html_content));
            }
        } else {
            $this->text .= Helper::formatText($text);
        }
        return $this;
    }

    /**
     * Set HTML version
     *
     * @param string $html The HTML content
     * @param bool $clear Clear a set content first ? (default is to append a content)
     * @return self
     */
    public function setHtml($html = '', $clear = false)
    {
        if (true===$clear) {
            $this->clear('text');
        }
        $this->html .= Helper::formatText($html, 'ascii');
        return $this;
    }

    /**
     * Set Reply-To header field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     */
    public function setReplyTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()->setRegistry('Reply-To', $_m, 'headers');
        }
        return $this;
    }

    /**
     * Set Foolowup-To header field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     */
    public function setFollowupTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()->setRegistry('Followup-To', $_m, 'headers');
        }
        return $this;
    }

    /**
     * Set Errors-To header field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     */
    public function setErrorsTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()->setRegistry('Errors-To', $_m, 'headers');
        }
        return $this;
    }

    /**
     * Set Disposition-Notification-To header field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     */
    public function setDispositionNotificationTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()->setRegistry('Disposition-Notification-To', $_m, 'headers');
        }
        return $this;
    }

    /**
     * Set Abuse-Reports-To header field
     *
     * @param string/array $mail
     * @param string/bool $name
     * @return self
     */
    public function setAbuseReportsTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()
                ->setRegistry('Abuse-Reports-To', $_m, 'headers')
                ;
        }
        return $this;
    }

    /**
     * Set Return-Receipt-To header field
     *
     * @param string/array $mail The email address to add, or an array of name=>email pairs
     * @param string/bool $name The name to show for the email address if there is just one
     * @return self
     */
    public function setReturnReceiptTo($mail = '', $name = null)
    {
        if (strlen($mail) && Helper::isEmail($mail)) {
            if (!empty($name)) {
                $_m = Helper::mailTagger($mail, $name);
            } else {
                $_m = $mail;
            }
            $this->getMailer()->setRegistry('Return-Receipt-To', $_m, 'headers');
        }
        return $this;
    }

    /**
     * Get sent built message
     *
     * @return string
     */
    public function getMessage()
    {
        return $this->message;
    }

// --------------------
// Sending
// --------------------

    /**
     * Message builder
     *
     * @return self
     */
    public function buildMessage()
    {
        $this->_buildInit();

        // From header
        if (is_array($this->from) && count($this->from)>0) {
            $from = null;
            while (is_null($from)==true) {
                foreach ($this->from as $n=>$m) {
                    $from = array($n=>$m);
                }
            }
            $this->from = $from;
        }
        if (count($this->from)==0) {
            $this->getMailer()->addError('No sender setted!');
        } else {
            $this->message .= Helper::listAddresses($this->from, 'from');
        }

        // To header
        if (count($this->to)>0) {
            $this->message .= Helper::listAddresses($this->to, 'to');
        }

        // CC header
        if (count($this->cc)>0) {
            $this->message .= Helper::listAddresses($this->cc, 'cc');
        }

        // BCC header
        if (count($this->bcc)>0) {
            $this->message .= Helper::listAddresses($this->bcc, 'bcc');
        }

        // Headers
        foreach ($this->getMailer()->getRegistry('headers') as $entry=>$v_entry) {
            if (isset($v_entry)) {
                $this->message .= Helper::headerTagger($entry, $v_entry).Mailer::$LINE_ENDING;
            }
        }
        $bound = 0;

        // Mail type
        $type = $this->getMailer()->getRegistry('message_type');
        if (!is_null($type) && $type!='text/plain') {
            $bound = 1;
            $this->message .= Helper::headerTagger("Content-Type", $type,
                array('boundary'=>$this->getMailer()->getRegistry('boundary'))).Mailer::$LINE_ENDING;
            $this->message .= "This is a multi-part message in MIME format.".Mailer::$LINE_ENDING;
            if ($type == 'multipart/mixed') {
                $this->message .= Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER.$this->getMailer()->getRegistry('boundary').Mailer::$LINE_ENDING;
                $this->message .= Helper::headerTagger("Content-Type", "multipart/alternative",
                    array('boundary'=>$this->getMailer()->getRegistry('boundary_ctt'))).Mailer::$LINE_ENDING;
            }
        }

        // Text content
        if (strlen($this->text)/* && !strlen($this->html)*/) {
            if ($bound) {
                $this->message .= Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER.$this->getMailer()->getRegistry('boundary_ctt').Mailer::$LINE_ENDING;
                //ne prend pas les css en compte
//                $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "7bit").Mailer::$LINE_ENDING;
                $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "8bit").Mailer::$LINE_ENDING;
                $this->message .= Helper::headerTagger("Content-Type", "text/plain",
                    array('charset'=>$this->getMailer()->getOption('charset'))).Mailer::$LINE_ENDING;
            }
            $this->message .= Mailer::$LINE_ENDING.$this->text;
        }

        // HTML content
        if (strlen($this->html)) {
            if ($bound) {
                $this->message .= Mailer::$LINE_ENDING.Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER
                    .$this->getMailer()->getRegistry('boundary_ctt').Mailer::$LINE_ENDING;
            }
            // prend les css en compte
//            $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "7bit").Mailer::$LINE_ENDING;
            $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "8bit").Mailer::$LINE_ENDING;
//            $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "quoted-printable").Mailer::$LINE_ENDING;
            $this->message .= Helper::headerTagger("Content-Type", "text/html",
                array('charset'=>$this->getMailer()->getOption('charset'))).Mailer::$LINE_ENDING;
            $this->message .= Mailer::$LINE_ENDING.trim($this->html, Mailer::$LINE_ENDING);
        }
        if ($bound) {
            $this->message .= Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER
                .$this->getMailer()->getRegistry('boundary_ctt').Mailer::BOUNDARY_CLOSER.Mailer::$LINE_ENDING;
        }

        // Attachments
        /* @todo what is max ? */
        $max = 10;
        if (count($this->attachment)>0) {
            for ($i=0;$i<$max;$i++) {
                if (isset($this->attachment[$i])) {
                    $file = fread(fopen($this->attachment[$i], "r"), filesize($this->attachment[$i]));
                    $filename = basename($this->attachment[$i]);
                    $this->message .= Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER.$this->getMailer()->getRegistry('boundary').Mailer::$LINE_ENDING;
                    $this->message .= Helper::headerTagger("Content-Type", Helper::getMimeType($filename),
                        array('name'=>$filename, 'charset'=>$this->getMailer()->getOption('charset'))).Mailer::$LINE_ENDING;
                    $this->message .= Helper::headerTagger("Content-Transfer-Encoding", "base64").Mailer::$LINE_ENDING;
                    $this->message .= Helper::headerTagger("Content-Disposition", 'attachment',
                        array('filename'=>$filename)).Mailer::$LINE_ENDING;
                    $this->message .= Helper::headerTagger("Content-Description", $filename).Mailer::$LINE_ENDING;
                    $this->message .= Mailer::$LINE_ENDING.chunk_split(base64_encode($file));
                    $file = $filename = "";
                }
            }
            $this->message .= Mailer::$LINE_ENDING.Mailer::BOUNDARY_OPENER.$this->getMailer()->getRegistry('boundary').Mailer::BOUNDARY_CLOSER.Mailer::$LINE_ENDING;
        }

        return $this;
    }

    /**
     * Build a boundary value
     *
     * @return string The generated boundary
     */
    public function makeBoundary()
    {
        return Mailer::BOUNDARY_PREFIX.md5(uniqid(time())).'.'.$this->id;
    }

    /**
     * Make a basic substitution in the object body
     *
     * @param string $search The string to search
     * @param string $replace The string to use for replacement
     * @return string The generated body
     */
    public function substitution($search, $replace)
    {
        $this->body = str_replace($search, $replace, $this->body);
        return $this->body;
    }
}

// Endfile