text:
using System;
using System.Collections.Generic;
using System.Linq;
using OpenCvSharp.Internal;
using OpenCvSharp.Internal.Util;
using OpenCvSharp.Internal.Vectors;

// ReSharper disable InconsistentNaming
// ReSharper disable IdentifierTypo

namespace OpenCvSharp;

/// <summary>
/// Planar Subdivision
/// </summary>
public class Subdiv2D : DisposableCvObject
{
    #region Init and Disposal

    /// <summary>
    /// Creates an empty Subdiv2D object.
    /// To create a new empty Delaunay subdivision you need to use the #initDelaunay function.
    /// </summary>
    public Subdiv2D()
    {
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_new1(out ptr));
        if (ptr == IntPtr.Zero)
            throw new OpenCvSharpException($"Failed to create {nameof(Subdiv2D)}");
    }

    /// <summary>
    /// Creates an empty Subdiv2D object.
    /// </summary>
    /// <param name="rect">Rectangle that includes all of the 2D points that are to be added to the subdivision.</param>
    public Subdiv2D(Rect rect)
    {
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_new2(rect, out ptr));
        if (ptr == IntPtr.Zero)
            throw new OpenCvSharpException($"Failed to create {nameof(Subdiv2D)}");
    }

    /// <summary>
    /// Clean up any resources being used.
    /// </summary>
    public void Release()
    {
        Dispose();
    }

    /// <summary>
    /// Releases unmanaged resources
    /// </summary>
    protected override void DisposeUnmanaged()
    {
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_delete(ptr));
        base.DisposeUnmanaged();
    }

    #endregion

    #region Constants

#pragma warning disable 1591
    public const int
        PTLOC_ERROR = -2,
        PTLOC_OUTSIDE_RECT = -1,
        PTLOC_INSIDE = 0,
        PTLOC_VERTEX = 1,
        PTLOC_ON_EDGE = 2;
    public const int
        NEXT_AROUND_ORG = 0x00,
        NEXT_AROUND_DST = 0x22,
        PREV_AROUND_ORG = 0x11,
        PREV_AROUND_DST = 0x33,
        NEXT_AROUND_LEFT = 0x13,
        NEXT_AROUND_RIGHT = 0x31,
        PREV_AROUND_LEFT = 0x20,
        PREV_AROUND_RIGHT = 0x02;
#pragma warning restore 1591

    #endregion

    #region Methods

    /// <summary>
    /// Creates a new empty Delaunay subdivision
    /// </summary>
    /// <param name="rect">Rectangle that includes all of the 2D points that are to be added to the subdivision.</param>
    public void InitDelaunay(Rect rect)
    {
        ThrowIfDisposed();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_initDelaunay(ptr, rect));
        GC.KeepAlive(this);
    }

    /// <summary>
    /// Insert a single point into a Delaunay triangulation.
    /// </summary>
    /// <param name="pt">Point to insert.</param>
    /// <returns></returns>
    public int Insert(Point2f pt)
    {
        ThrowIfDisposed();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_insert1(ptr, pt, out var ret));
        GC.KeepAlive(this);
        return ret;
    }

    /// <summary>
    /// Insert multiple points into a Delaunay triangulation.
    /// </summary>
    /// <param name="ptVec">Points to insert.</param>
    public void Insert(IEnumerable<Point2f> ptVec)
    {
        ThrowIfDisposed();
        if (ptVec == null)
            throw new ArgumentNullException(nameof(ptVec));

        var ptVecArray = ptVec.CastOrToArray();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_insert2(ptr, ptVecArray, ptVecArray.Length));

        GC.KeepAlive(this);
    }

    /// <summary>
    /// Returns the location of a point within a Delaunay triangulation.
    /// </summary>
    /// <param name="pt">Point to locate.</param>
    /// <param name="edge">Output edge that the point belongs to or is located to the right of it.</param>
    /// <param name="vertex">Optional output vertex the input point coincides with.</param>
    /// <returns>an integer which specify one of the following five cases for point location:
    /// -  The point falls into some facet. The function returns #PTLOC_INSIDE and edge will contain one of edges of the facet.
    /// -  The point falls onto the edge. The function returns #PTLOC_ON_EDGE and edge will contain this edge.
    /// -  The point coincides with one of the subdivision vertices. The function returns #PTLOC_VERTEX and vertex will contain a pointer to the vertex.
    /// -  The point is outside the subdivision reference rectangle. The function returns #PTLOC_OUTSIDE_RECT and no pointers are filled.
    /// -  One of input arguments is invalid. A runtime error is raised or, if silent or "parent" error processing mode is selected, #PTLOC_ERROR is returned.</returns>
    public int Locate(Point2f pt, out int edge, out int vertex)
    {
        ThrowIfDisposed();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_locate(ptr, pt, out edge, out vertex, out var ret));
        GC.KeepAlive(this);
        return ret;
    }

    /// <summary>
    /// Finds the subdivision vertex closest to the given point.
    /// </summary>
    /// <param name="pt">Input point.</param>
    /// <param name="nearestPt">Output subdivision vertex point.</param>
    /// <returns>vertex ID.</returns>
    public int FindNearest(Point2f pt, out Point2f nearestPt)
    {
        ThrowIfDisposed();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_findNearest(ptr, pt, out nearestPt, out var ret));
        GC.KeepAlive(this);
        return ret;
    }

    /// <summary>
    /// Returns a list of all edges.
    /// </summary>
    /// <returns>Output vector.</returns>
    public Vec4f[] GetEdgeList()
    {
        ThrowIfDisposed();
        using var vec = new VectorOfVec4f();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_getEdgeList(ptr, vec.CvPtr));
        GC.KeepAlive(this);
        return vec.ToArray();
    }

    /// <summary>
    /// Returns a list of the leading edge ID connected to each triangle.
    /// The function gives one edge ID for each triangle.
    /// </summary>
    /// <returns>Output vector.</returns>
    public int[] GetLeadingEdgeList()
    {
        ThrowIfDisposed();

        using var leadingEdgeList = new VectorOfInt32();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_getLeadingEdgeList(ptr, leadingEdgeList.CvPtr));

        GC.KeepAlive(this);
        return leadingEdgeList.ToArray();
    }

    /// <summary>
    /// Returns a list of all triangles.
    /// </summary>
    /// <returns>Output vector.</returns>
    public Vec6f[] GetTriangleList()
    {
        ThrowIfDisposed();
        using var vec = new VectorOfVec6f();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_getTriangleList(ptr, vec.CvPtr));
        GC.KeepAlive(this);
        return vec.ToArray();
    }

    /// <summary>
    /// Returns a list of all Voronoi facets.
    /// </summary>
    /// <param name="idx">Vector of vertices IDs to consider. For all vertices you can pass empty vector.</param>
    /// <param name="facetList">Output vector of the Voronoi facets.</param>
    /// <param name="facetCenters">Output vector of the Voronoi facets center points.</param>
    public void GetVoronoiFacetList(IEnumerable<int>? idx, out Point2f[][] facetList, out Point2f[] facetCenters)
    {
        ThrowIfDisposed();

        int[]? idxArray = idx?.CastOrToArray();
        using var facetListVec = new VectorOfVectorPoint2f();
        using var facetCentersVec = new VectorOfPoint2f();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_getVoronoiFacetList(
                ptr, idxArray, idxArray?.Length ?? 0, facetListVec.CvPtr, facetCentersVec.CvPtr));
        GC.KeepAlive(this);
        facetList = facetListVec.ToArray();
        facetCenters = facetCentersVec.ToArray();
    }

    /// <summary>
    /// Returns vertex location from vertex ID.
    /// </summary>
    /// <param name="vertex">vertex ID.</param>
    /// <param name="firstEdge">The first edge ID which is connected to the vertex.</param>
    /// <returns>vertex (x,y)</returns>
    public Point2f GetVertex(int vertex, out int firstEdge)
    {
        ThrowIfDisposed();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_getVertex(ptr, vertex, out firstEdge, out var ret));
        GC.KeepAlive(this);
        return ret;
    }

    /// <summary>
    /// Returns one of the edges related to the given edge.
    /// </summary>
    /// <param name="edge">Subdivision edge ID.</param>
    /// <param name="nextEdgeType">Parameter specifying which of the related edges to return.
    /// The following values are possible:
    /// -   NEXT_AROUND_ORG next around the edge origin ( eOnext on the picture below if e is the input edge)
    /// -   NEXT_AROUND_DST next around the edge vertex ( eDnext )
    /// -   PREV_AROUND_ORG previous around the edge origin (reversed eRnext )
    /// -   PREV_AROUND_DST previous around the edge destination (reversed eLnext )
    /// -   NEXT_AROUND_LEFT next around the left facet ( eLnext )
    /// -   NEXT_AROUND_RIGHT next around the right facet ( eRnext )
    /// -   PREV_AROUND_LEFT previous around the left facet (reversed eOnext )
    /// -   PREV_AROUND_RIGHT previous around the right facet (reversed eDnext )</param>
    /// <returns></returns>
    public int GetEdge(int edge, NextEdgeType nextEdgeType)
    {
        ThrowIfDisposed();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_getEdge(ptr, edge, (int)nextEdgeType, out var ret));
        GC.KeepAlive(this);
        return ret;
    }

    /// <summary>
    /// Subdivision edge ID.
    /// </summary>
    /// <param name="edge">Subdivision edge ID.</param>
    /// <returns>an integer which is next edge ID around the edge origin: eOnext on the picture above if e is the input edge).</returns>
    public int NextEdge(int edge)
    {
        ThrowIfDisposed();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_nextEdge(ptr, edge, out var ret));
        GC.KeepAlive(this);
        return ret;
    }

    /// <summary>
    /// Returns another edge of the same quad-edge.
    /// </summary>
    /// <param name="edge">Subdivision edge ID.</param>
    /// <param name="rotate">Parameter specifying which of the edges of the same quad-edge as the input
    /// one to return. The following values are possible:
    /// -   0 - the input edge ( e on the picture below if e is the input edge)
    /// -   1 - the rotated edge ( eRot )
    /// -   2 - the reversed edge (reversed e (in green))
    /// -   3 - the reversed rotated edge (reversed eRot (in green))</param>
    /// <returns>one of the edges ID of the same quad-edge as the input edge.</returns>
    public int RotateEdge(int edge, int rotate)
    {
        ThrowIfDisposed();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_rotateEdge(ptr, edge, rotate, out var ret));
        GC.KeepAlive(this);
        return ret;
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="edge"></param>
    /// <returns></returns>
    public int SymEdge(int edge)
    {
        ThrowIfDisposed();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_symEdge(ptr, edge, out var ret));
        GC.KeepAlive(this);
        return ret;
    }

    /// <summary>
    /// Returns the edge origin.
    /// </summary>
    /// <param name="edge">Subdivision edge ID.</param>
    /// <param name="orgPt">Output vertex location.</param>
    /// <returns>vertex ID.</returns>
    public int EdgeOrg(int edge, out Point2f orgPt)
    {
        ThrowIfDisposed();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_edgeOrg(ptr, edge, out orgPt, out var ret));
        GC.KeepAlive(this);
        return ret;
    }

    /// <summary>
    /// Returns the edge destination.
    /// </summary>
    /// <param name="edge">Subdivision edge ID.</param>
    /// <param name="dstPt">Output vertex location.</param>
    /// <returns>vertex ID.</returns>
    public int EdgeDst(int edge, out Point2f dstPt)
    {
        ThrowIfDisposed();
        NativeMethods.HandleException(
            NativeMethods.imgproc_Subdiv2D_edgeDst(ptr, edge, out dstPt, out var ret));
        GC.KeepAlive(this);
        return ret;
    }

    #endregion
}

/// <summary>
/// Parameter for Subdiv2D.GetEdge() specifying which of the related edges to return.
/// </summary>
public enum NextEdgeType
{
    /// <summary>
    /// next around the edge origin ( eOnext on the picture below if e is the input edge)
    /// </summary>
    NEXT_AROUND_ORG = 0x00,

    /// <summary>
    /// next around the edge vertex ( eDnext )
    /// </summary>
    NEXT_AROUND_DST = 0x22,

    /// <summary>
    /// previous around the edge origin (reversed eRnext )
    /// </summary>
    PREV_AROUND_ORG = 0x11,

    /// <summary>
    /// previous around the edge destination (reversed eLnext )
    /// </summary>
    PREV_AROUND_DST = 0x33,

    /// <summary>
    /// next around the left facet ( eLnext )
    /// </summary>
    NEXT_AROUND_LEFT = 0x13,

    /// <summary>
    /// next around the right facet ( eRnext )
    /// </summary>
    NEXT_AROUND_RIGHT = 0x31,

    /// <summary>
    /// previous around the left facet (reversed eOnext )
    /// </summary>
    PREV_AROUND_LEFT = 0x20,

    /// <summary>
    /// previous around the right facet (reversed eDnext )
    /// </summary>
    PREV_AROUND_RIGHT = 0x02
}


text:
<?php
/**
 * Main view for backend "sort" actions.
 *
 * @author         Krzysztof Trzos
 * @package        base
 * @subpackage     views
 * @since          1.0.0-alpha
 * @version        1.0.0-alpha
 */
?>

<?php /* @var $aList array */ ?>
<?php /* @var $oModel \Plethora\ModelCore */ ?>
<?php /* @var $sColumn string */ ?>

<?php if(!empty($aList)): ?>
    <div id="sorted_list">
        <?php
        echo \Plethora\View::factory('base/backend/list_sort_group')
            ->bind('aList', $aList)
            ->bind('oModel', $oModel)
            ->bind('sColumn', $sColumn)
            ->render()
        ?>
    </div>
<?php endif; ?>

<form action="/">
    <input type="hidden" name="model" value="<?php echo $oModel->getClass() ?>" id="model_name"/>
    <button class="btn btn-primary" id="sort_save_conf"><?php echo __('Save configuration') ?></button>
</form>

redpajama_set_name: RedPajamaGithub


text:
@interface SMMasterViewController () {
    NSMutableArray *_dates;
}
@end

@implementation SMMasterViewController

- (void)awakeFromNib
{
    [super awakeFromNib];
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    _dates = [NSMutableArray array];

    NSDate *now = [NSDate date];

    for (NSInteger i = 0; i < 5000; i++) {

        [_dates addObject:[now dateByAddingTimeInterval:60*i]];
        sleep(0.1);

    }
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table View

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return _dates.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
    NSDate *date = _dates[indexPath.row];
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setDateFormat:@"yyyyMMdd HH:mm:ss.SSS"];
    cell.textLabel.text = [dateFormatter stringFromDate:date];
    return cell;

}

@end


text:
<?php

namespace Fdr\AdminBundle\Controller;

use Symfony\Component\HttpFoundation\Request;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Fdr\AdminBundle\Entity\Chauffeur;
use Fdr\AdminBundle\Form\ChauffeurType;

/**
 * Chauffeur controller.
 *
 */
class ChauffeurController extends Controller {

    /**
     * Lists all Chauffeur entities.
     *
     */
    public function indexAction(Request $request) {
        $emRole = $this->getDoctrine()->getManager();
        $roles = ($this->getUser()) ? $this->getUser()->getRoles() : array(null);
        $role = $emRole->getRepository('FdrAdminBundle:Role')->findOneByNomRole(substr(strtoupper($roles[0]), 5));
        $methodes = array('getAffChauffeur', 'getCrChauffeur', 'getUpChauffeur', 'getDelChauffeur');
        $this->get('entitie_manager')->ayantRoles($this, $role, $emRole, $methodes);
        $em = $this->getDoctrine()->getManager();

        $entities = $em->getRepository('FdrAdminBundle:Chauffeur')->findBy(array(), array('id' => 'DESC'));

        //--
        $form = array();
        $search_form = $this->createSearchForm();

        foreach ($entities as $entity) {
            $form[$entity->getId()] = $this->createDeleteForm($entity->getId())->createView();
        }
        //--
        $paginator = $this->get('knp_paginator');
        $pagination = $paginator->paginate($entities, $request->query->get('page', 1), 10);
        return $this->render('FdrAdminBundle:Chauffeur:index.html.twig', array(
                    'entities' => $entities,
                    'form' => $form,
                    'search_form' => $search_form->createView(),
                    'pagination' => $pagination,
                    'role' => $role
        ));
    }

    public function rechercheAction(Request $request) {
        $emRole = $this->getDoctrine()->getManager();
        $roles = ($this->getUser()) ? $this->getUser()->getRoles() : array(null);
        $role = $emRole->getRepository('FdrAdminBundle:Role')->findOneByNomRole(substr(strtoupper($roles[0]), 5));
        $methodes = array('getAffChauffeur', 'getCrChauffeur', 'getUpChauffeur', 'getDelChauffeur');
        $this->get('entitie_manager')->ayantRoles($this, $role, $emRole, $methodes);
        //--
        $form = array();
        $search_form = $this->createSearchForm();
        $search_form->handleRequest($request);
        if ($search_form->isValid()) {
            //$par="libelle";
            $keyword = strtolower($search_form->get('libelle')->getData());
            $par = $search_form->get('par')->getData();
            $em = $this->getDoctrine()->getManager();
            $query = $em->createQuery('SELECT p FROM FdrAdminBundle:Chauffeur p WHERE p.' . $par . ' like :keyword ORDER BY p.' . $par . ' ASC')
                    ->setParameter('keyword', strtolower('%' . $keyword . '%'));
            $entities = $query->getResult();
            $paginator = $this->get('knp_paginator');
            $pagination = $paginator->paginate($entities, $request->query->get('page', 1), 10);
        } else {
            $this->get('session')->getFlashBag()->add('notFoundException', 'Erreur Dans la recherche');
            return $this->redirect($this->generateUrl('chauffeur'));
        }

        foreach ($entities as $entity) {
            $form[$entity->getId()] = $this->createDeleteForm($entity->getId())->createView();
        }
        //--
        return $this->render('FdrAdminBundle:Chauffeur:recherche.html.twig', array(
                    'entities' => $entities,
                    'form' => $form,
                    'search_form' => $search_form->createView(),
                    'keyword' => $keyword,
                    'par' => $par,
                    'pagination' => $pagination,
                    'role' => $role
        ));
    }

    /**
     * Creates a new Chauffeur entity.
     *
     */
    public function createAction(Request $request) {
        $emRole = $this->getDoctrine()->getManager();
        $roles = ($this->getUser()) ? $this->getUser()->getRoles() : array(null);
        $role = $emRole->getRepository('FdrAdminBundle:Role')->findOneByNomRole(substr(strtoupper($roles[0]), 5));
        $methodes = array('getCrChauffeur');
        $this->get('entitie_manager')->ayantRoles($this, $role, $emRole, $methodes);
        $entity = new Chauffeur();
        $form = $this->createCreateForm($entity);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($entity);
            $em->flush();
            $this->get('session')->getFlashBag()->add('accuseAjout', 'Chauffeur ayant id=' . $entity->getId() . ' a bien été ajouté');
            return $this->redirect($this->generateUrl('chauffeur_show', array('id' => $entity->getId())));
        }

        return $this->render('FdrAdminBundle:Chauffeur:new.html.twig', array(
                    'entity' => $entity,
                    'form' => $form->createView(),
                    'role' => $role
        ));
    }

    /**
     * Creates a form to create a Chauffeur entity.
     *
     * @param Chauffeur $entity The entity
     *
     * @return \Symfony\Component\Form\Form The form
     */
    private function createCreateForm(Chauffeur $entity) {

        $form = $this->createForm(new ChauffeurType(), $entity, array(
            'action' => $this->generateUrl('chauffeur_create'),
            'method' => 'POST',
        ));
        //--
        $form->add('submit', 'submit', array('label' => 'Enregistrer', 'attr' => array('class' => 'btn-default span2 offset5')));

        return $form;
    }

    /**
     * Displays a form to create a new Chauffeur entity.
     *
     */
    public function newAction() {
        $emRole = $this->getDoctrine()->getManager();
        $roles = ($this->getUser()) ? $this->getUser()->getRoles() : array(null);
        $role = $emRole->getRepository('FdrAdminBundle:Role')->findOneByNomRole(substr(strtoupper($roles[0]), 5));
        $methodes = array('getCrChauffeur');
        $this->get('entitie_manager')->ayantRoles($this, $role, $emRole, $methodes);
        $entity = new Chauffeur();
        $form = $this->createCreateForm($entity);

        return $this->render('FdrAdminBundle:Chauffeur:new.html.twig', array(
                    'entity' => $entity,
                    'form' => $form->createView(),
                    'role' => $role
        ));
    }

    /**
     * Finds and displays a Chauffeur entity.
     *
     */
    public function showAction($id) {
        $emRole = $this->getDoctrine()->getManager();
        $roles = ($this->getUser()) ? $this->getUser()->getRoles() : array(null);
        $role = $emRole->getRepository('FdrAdminBundle:Role')->findOneByNomRole(substr(strtoupper($roles[0]), 5));
        $methodes = array('getAffChauffeur', 'getCrChauffeur', 'getUpChauffeur', 'getDelChauffeur');
        $this->get('entitie_manager')->ayantRoles($this, $role, $emRole, $methodes);
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('FdrAdminBundle:Chauffeur')->find($id);

        if (!$entity) {
            $this->get('session')->getFlashBag()->add('notFoundException', 'Impossible de trouver chauffeur ayant code=' . $id);
            return $this->redirect($this->generateUrl('chauffeur'));
        }

        $deleteForm = $this->createDeleteForm($id);

        //---
        $form = $this->createForm(new ChauffeurType(), $entity);
        //---

        return $this->render('FdrAdminBundle:Chauffeur:show.html.twig', array(
                    'entity' => $entity,
                    'delete_form' => $deleteForm->createView(),
                    //--
                    'form' => $form->createView(),
                    'role' => $role
                        //--
        ));
    }

    /**
     * Displays a form to edit an existing Chauffeur entity.
     *
     */
    public function editAction($id) {
        $emRole = $this->getDoctrine()->getManager();
        $roles = ($this->getUser()) ? $this->getUser()->getRoles() : array(null);
        $role = $emRole->getRepository('FdrAdminBundle:Role')->findOneByNomRole(substr(strtoupper($roles[0]), 5));
        $methodes = array('getUpChauffeur');
        $this->get('entitie_manager')->ayantRoles($this, $role, $emRole, $methodes);
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('FdrAdminBundle:Chauffeur')->find($id);

        if (!$entity) {
            $this->get('session')->getFlashBag()->add('notFoundException', 'Impossible de trouver chauffeur ayant code=' . $id);
            return $this->redirect($this->generateUrl('chauffeur'));
        }

        $editForm = $this->createEditForm($entity);
        $deleteForm = $this->createDeleteForm($id);

        return $this->render('FdrAdminBundle:Chauffeur:edit.html.twig', array(
                    'entity' => $entity,
                    'edit_form' => $editForm->createView(),
                    'delete_form' => $deleteForm->createView(),
                    'role' => $role
        ));
    }

    /**
     * Creates a form to edit a Chauffeur entity.
     *
     * @param Chauffeur $entity The entity
     *
     * @return \Symfony\Component\Form\Form The form
     */
    private function createEditForm(Chauffeur $entity) {

        $form = $this->createForm(new ChauffeurType(), $entity, array(
            'action' => $this->generateUrl('chauffeur_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));
        //--
        $form->add('submit', 'submit', array('label' => 'Modifier', 'attr' => array('class' => 'btn-primary span2 offset5')));
        //--
        return $form;
    }

    /**
     * Edits an existing Chauffeur entity.
     *
     */
    public function updateAction(Request $request, $id) {
        $emRole = $this->getDoctrine()->getManager();
        $roles = ($this->getUser()) ? $this->getUser()->getRoles() : array(null);
        $role = $emRole->getRepository('FdrAdminBundle:Role')->findOneByNomRole(substr(strtoupper($roles[0]), 5));
        $methodes = array('getUpChauffeur');
        $this->get('entitie_manager')->ayantRoles($this, $role, $emRole, $methodes);
        $em = $this->getDoctrine()->getManager();

        $entity = $em->getRepository('FdrAdminBundle:Chauffeur')->find($id);

        if (!$entity) {
            $this->get('session')->getFlashBag()->add('notFoundException', 'Impossible de trouver chauffeur ayant code=' . $id);
            return $this->redirect($this->generateUrl('chauffeur'));
        }

        $deleteForm = $this->createDeleteForm($id);
        $editForm = $this->createEditForm($entity);
        $editForm->handleRequest($request);

        if ($editForm->isValid()) {
            $em->flush();
            $this->get('session')->getFlashBag()->add('accuseModification', 'Chauffeur a bien été modifié');

            return $this->redirect($this->generateUrl('chauffeur_edit', array('id' => $id)));
        }

        return $this->render('FdrAdminBundle:Chauffeur:edit.html.twig', array(
                    'entity' => $entity,
                    'edit_form' => $editForm->createView(),
                    'delete_form' => $deleteForm->createView(),
                    'role' => $role
        ));
    }

    /**
     * Deletes a Chauffeur entity.
     *
     */
    public function deleteAction(Request $request, $id) {
        $emRole = $this->getDoctrine()->getManager();
        $roles = ($this->getUser()) ? $this->getUser()->getRoles() : array(null);
        $role = $emRole->getRepository('FdrAdminBundle:Role')->findOneByNomRole(substr(strtoupper($roles[0]), 5));
        $methodes = array('getDelChauffeur');
        $this->get('entitie_manager')->ayantRoles($this, $role, $emRole, $methodes);
        $form = $this->createDeleteForm($id);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $entity = $em->getRepository('FdrAdminBundle:Chauffeur')->find($id);

            if (!$entity) {
                $this->get('session')->getFlashBag()->add('notFoundException', 'Impossible de trouver chauffeur ayant code=' . $id);
                return $this->redirect($this->generateUrl('chauffeur'));
            }

            $em->remove($entity);
            $em->flush();
            $this->get('session')->getFlashBag()->add('accuseSuppression', 'Chauffeur ayant id=' . $id . ' a bien été supprimé');
        }

        return $this->redirect($this->generateUrl('chauffeur'));
    }

    /**
     * Creates a form to delete a Chauffeur entity by id.
     *
     * @param mixed $id The entity id
     *
     * @return \Symfony\Component\Form\Form The form
     */
    private function createDeleteForm($id) {
        return $this->createFormBuilder()
                        ->setAction($this->generateUrl('chauffeur_delete', array('id' => $id)))
                        ->setMethod('DELETE')
                        //--
                        ->add('supprimer', 'submit', array('label' => 'S', 'attr' => array('class' => 'btn btn-danger supp', 'title' => 'Supprimer')))
                        //--
                        ->getForm()
        ;
    }

    private function createSearchForm() {
        return $this->createFormBuilder()
                        ->setAction($this->generateUrl('chauffeur_recherche', array()))
                        ->setMethod('GET')
                        //--
                        ->add('par', 'choice', array('choices' => array(
                                'id' => "Code",
                                'nom' => 'Nom',
                                'matricule' => 'Matricule',
                                'etatContrat' => 'Etat de Contrat',
                                'typeconvention' => 'Type De Convention',
                            ), 'placeholder' => "Rechercher par :"))
                        ->add('libelle', 'text', array('label' => ' ', 'attr' => array('class' => 'input-sm', 'title' => 'Rechercher', 'placeholder' => ' Par mot clè...?')))
                        ->add('submit', 'submit', array('label' => ' Rechercher ', 'attr' => array('class' => 'btn-default', 'title' => 'Rechercher')))
                        //--
                        ->getForm()
        ;
    }

}


text:
package com.shapesecurity.shift.es2018.fuzzer;

import com.shapesecurity.functional.data.ImmutableList;
import com.shapesecurity.functional.data.Maybe;
import com.shapesecurity.functional.data.NonEmptyImmutableList;
import com.shapesecurity.shift.es2018.ast.*;
import com.shapesecurity.shift.es2018.ast.Module;
import com.shapesecurity.shift.es2018.ast.operators.BinaryOperator;
import com.shapesecurity.shift.es2018.ast.operators.CompoundAssignmentOperator;
import com.shapesecurity.shift.es2018.ast.operators.UnaryOperator;
import com.shapesecurity.shift.es2018.ast.operators.UpdateOperator;
import com.shapesecurity.shift.es2018.utils.Utils;

import javax.annotation.Nonnull;

import java.util.Random;

public class Fuzzer {
    private static final String identifierStart = "_$abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    private static final String identifierPart = identifierStart + "0123456789";
    private static final char[] identifierStartArr = identifierStart.toCharArray();
    private static final char[] identifierPartArr = identifierPart.toCharArray();

    private static final int MANY_BOUND = 5;
    private static final int MAX_IDENT_LENGTH = 15;
    private static final int MAX_STRING_LENGTH = 3;
    private static final double SPECIAL_IDENT_PROBABILITY = 0.5;
    private static final String[] RESERVED_WORDS = new String[]{
            "false",
            "null",
            "true",
            "let",
            "if",
            "in",
            "do",
            "var",
            "for",
            "new",
            "try",
            "this",
            "else",
            "case",
            "void",
            "with",
            "enum",
            "while",
            "break",
            "catch",
            "throw",
            "const",
            "class",
            "super",
            "return",
            "typeof",
            "delete",
            "switch",
            "export",
            "import",
            "default",
            "finally",
            "extends",
            "function",
            "continue",
            "debugger",
            "instanceof",
    };
    private static final String[] STRICT_MODE_RESERVED_WORDS = new String[]{
            "implements",
            "interface",
            "package",
            "private",
            "protected",
            "public",
            "static",
            "yield",
            "false",
            "null",
            "true",
            "let",
            "if",
            "in",
            "do",
            "var",
            "for",
            "new",
            "try",
            "this",
            "else",
            "case",
            "void",
            "with",
            "enum",
            "while",
            "break",
            "catch",
            "throw",
            "const",
            "class",
            "super",
            "return",
            "typeof",
            "delete",
            "switch",
            "export",
            "import",
            "default",
            "finally",
            "extends",
            "function",
            "continue",
            "debugger",
            "instanceof",
    };
    private static final String[] RESTRICTED_WORDS = new String[]{
            "arguments",
            "eval",
    };
    private final static int kGenBreakStatement = 0;
    private final static int kGenContinueStatement = 1;
    private final static int kGenWithStatement = 2;
    private final static int kGenReturnStatement = 3;
    private final static int kGenLabeledStatement = 4;
    private final static Gen<AssignmentTarget>[] assignmentTargetGens = Fuzzer.<Gen<AssignmentTarget>>array(
            Fuzzer::randomArrayAssignmentTarget,
            Fuzzer::randomAssignmentTargetIdentifier,
            Fuzzer::randomComputedMemberAssignmentTarget,
            Fuzzer::randomObjectAssignmentTarget,
            Fuzzer::randomStaticMemberAssignmentTarget
    );
    private final static Gen<Binding>[] bindingGens = Fuzzer.<Gen<Binding>>array(
            Fuzzer::randomArrayBinding,
            Fuzzer::randomBindingIdentifier,
            Fuzzer::randomObjectBinding
    );
    private static final Gen<Expression>[] expressionGens = Fuzzer.<Gen<Expression>>array(
            Fuzzer::randomArrayExpression,
            Fuzzer::randomArrowExpression,
            Fuzzer::randomAssignmentExpression,
            Fuzzer::randomCompoundAssignmentExpression,
            Fuzzer::randomBinaryExpression,
            Fuzzer::randomCallExpression,
            Fuzzer::randomComputedMemberExpression,
            Fuzzer::randomConditionalExpression,
            Fuzzer::randomFunctionExpression,
            Fuzzer::randomIdentifierExpression,
            Fuzzer::randomLiteralBooleanExpression,
            Fuzzer::randomLiteralNullExpression,
            Fuzzer::randomLiteralInfinityExpression,
            Fuzzer::randomLiteralNumericExpression,
            Fuzzer::randomLiteralRegExpExpression,
            Fuzzer::randomLiteralStringExpression,
            Fuzzer::randomNewExpression,
            Fuzzer::randomObjectExpression,
            Fuzzer::randomUpdateExpression,
            Fuzzer::randomStaticMemberExpression,
            Fuzzer::randomThisExpression,
            Fuzzer::randomClassExpression,
            Fuzzer::randomNewTargetExpression,
            Fuzzer::randomTemplateExpression,
            Fuzzer::randomUnaryExpression,
            Fuzzer::randomYieldExpression,
            Fuzzer::randomYieldGeneratorExpression,
            Fuzzer::randomAwaitExpression
    );
    private final static Gen<ExportDeclaration>[] exportDeclarationGens = Fuzzer.<Gen<ExportDeclaration>>array(
            Fuzzer::randomExport,
            Fuzzer::randomExportAllFrom,
            Fuzzer::randomExportDefault,
            Fuzzer::randomExportFrom,
            Fuzzer::randomExportLocals
    );
    private final static Gen<Statement>[] nonIterationStatementGens = Fuzzer.<Gen<Statement>>array(
            Fuzzer::randomBlockStatement,
            Fuzzer::randomBreakStatement,
            Fuzzer::randomClassDeclaration,
            Fuzzer::randomContinueStatement,
            Fuzzer::randomDebuggerStatement,
            Fuzzer::randomEmptyStatement,
            Fuzzer::randomExpressionStatement,
            Fuzzer::randomFunctionDeclaration,
            Fuzzer::randomIfStatement,
            Fuzzer::randomLabeledStatement,
            Fuzzer::randomReturnStatement,
            Fuzzer::randomSwitchStatement,
            Fuzzer::randomSwitchStatementWithDefault,
            Fuzzer::randomThrowStatement,
            Fuzzer::randomTryCatchStatement,
            Fuzzer::randomTryFinallyStatement,
            Fuzzer::randomVariableDeclarationStatement,
            Fuzzer::randomWithStatement
    );
    private final static Gen<IterationStatement>[] iterationStatementGens = Fuzzer.<Gen<IterationStatement>>array(
            Fuzzer::randomDoWhileStatement,
            Fuzzer::randomForInStatement,
            Fuzzer::randomForOfStatement,
            Fuzzer::randomForStatement,
            Fuzzer::randomWhileStatement
    );

    private final static int totalStatements = nonIterationStatementGens.length + iterationStatementGens.length + 5;

    @SafeVarargs
    private static <T> T[] array(T... arr) {
        return arr;
    }

    private static <T> Gen<T> choice(T[] arr) {
        return (ctx, depth) -> arr[ctx.random.nextInt(arr.length)];
    }

    @Nonnull
    public static Program generate(@Nonnull Random random, int depth) {
        return random.nextBoolean() ? randomScript(new GenCtx(random), depth) : randomModule(new GenCtx(random), depth);
    }

    private static boolean isFunctionBodyStrict(FunctionBody body) {
        for (Directive directive : body.directives) {
            if (directive.rawValue.equals("use strict")) {
                return true;
            }
        }
        return false;
    }

    @Nonnull
    private static <T> Gen<ImmutableList<T>> many(final int bound, @Nonnull Gen<T> gen) {
        return (ctx, depth) -> {
            if (depth <= 0) {
                return ImmutableList.empty();
            }
            int number = ctx.random.nextInt(bound);
            ImmutableList<T> result = ImmutableList.empty();
            for (int i = 0; i < number; i++) {
                result = result.cons(gen.apply(ctx, depth));
            }
            return result;
        };
    }

    @Nonnull
    private static <T> Gen<ImmutableList<T>> many(@Nonnull Gen<T> gen) {
        return many(MANY_BOUND, gen);
    }

    @Nonnull
    private static <T> Gen<NonEmptyImmutableList<T>> many1(@Nonnull Gen<T> gen) {
        return (ctx, depth) -> many(MANY_BOUND - 1, gen).apply(ctx, depth).cons(gen.apply(ctx, depth));
    }

    @Nonnull
    private static <T> Gen<Maybe<T>> optional(@Nonnull Gen<T> gen) {
        return (ctx, depth) -> {
            if (depth <= 0) {
                return Maybe.empty();
            }
            if (ctx.random.nextBoolean()) {
                return Maybe.empty();
            }
            return Maybe.of(gen.apply(ctx, depth));
        };
    }

    @Nonnull
    private static ArrayBinding randomArrayBinding(@Nonnull GenCtx ctx, int depth) {
        return new ArrayBinding(many(optional(Fuzzer::randomBindingBindingWithDefault)).apply(ctx, depth - 1), optional(Fuzzer::randomBinding).apply(ctx, depth - 1));
    }

    @Nonnull
    private static ArrayAssignmentTarget randomArrayAssignmentTarget(@Nonnull GenCtx ctx, int depth) {
        return new ArrayAssignmentTarget(many(optional(Fuzzer::randomAssignmentTargetAssignmentTargetWithDefault)).apply(ctx, depth - 1), optional(Fuzzer::randomAssignmentTarget).apply(ctx, depth - 1));
    }

    @Nonnull
    private static ArrayExpression randomArrayExpression(@Nonnull GenCtx ctx, int depth) {
        return new ArrayExpression(many(optional(Fuzzer::randomSpreadElementExpression)).apply(ctx, depth - 1));
    }

    @Nonnull
    private static ArrowExpression randomArrowExpression(@Nonnull GenCtx ctx, int depth) {
        boolean isAsync = ctx.random.nextBoolean();
        if (isAsync) {
            ctx = ctx.inAsyncFunction();
        }
        return new ArrowExpression(isAsync, randomFormalParameters(ctx, depth - 1), randomFunctionBodyExpression(ctx, depth - 1));
    }

    @Nonnull
    private static AssignmentExpression randomAssignmentExpression(@Nonnull GenCtx ctx, int depth) {
        return new AssignmentExpression(randomAssignmentTarget(ctx, depth - 1), randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static AssignmentTarget randomAssignmentTarget(@Nonnull GenCtx ctx, int depth) {
        return choice(assignmentTargetGens).apply(ctx, depth).apply(ctx, depth - 1);
    }

    @Nonnull
    private static BinaryExpression randomBinaryExpression(@Nonnull GenCtx ctx, int depth) {
        return new BinaryExpression(randomExpression(ctx, depth - 1), choice(BinaryOperator.values()).apply(ctx, depth - 1), randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static Binding randomBinding(@Nonnull GenCtx ctx, int depth) {
//        if (ctx.inForInOfStatement) { // todo why was this here?
//            return randomBindingIdentifier(ctx, depth - 1);
//        }
        return choice(bindingGens).apply(ctx, depth).apply(ctx, depth - 1);
    }

    @Nonnull
    private static BindingBindingWithDefault randomBindingBindingWithDefault(@Nonnull GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomBinding(ctx, depth);
        } else {
            return randomBindingWithDefault(ctx, depth);
        }
    }

    @Nonnull
    private static AssignmentTargetAssignmentTargetWithDefault randomAssignmentTargetAssignmentTargetWithDefault(@Nonnull GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomAssignmentTarget(ctx, depth);
        } else {
            return randomAssignmentTargetWithDefault(ctx, depth);
        }
    }

    @Nonnull
    private static BindingIdentifier randomBindingIdentifier(@Nonnull GenCtx ctx, int depth) {
        return new BindingIdentifier(randomIdentifierString(ctx, depth - 1));
    }

    @Nonnull
    private static AssignmentTargetIdentifier randomAssignmentTargetIdentifier(@Nonnull GenCtx ctx, int depth) {
        return new AssignmentTargetIdentifier(randomIdentifierString(ctx, depth - 1));
    }

    @Nonnull
    private static SimpleAssignmentTarget randomSimpleAssignmentTarget(@Nonnull GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomAssignmentTargetIdentifier(ctx, depth);
        } else {
            number = ctx.random.nextInt();
            if (number % 2 == 0) {
                return randomComputedMemberAssignmentTarget(ctx, depth);
            } else {
                return randomStaticMemberAssignmentTarget(ctx, depth);
            }
        }
    }

    @Nonnull
    private static BindingProperty randomBindingProperty(@Nonnull GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomBindingPropertyIdentifier(ctx, depth);
        } else {
            return randomBindingPropertyProperty(ctx, depth);
        }
    }

    @Nonnull
    private static AssignmentTargetProperty randomAssignmentTargetProperty(@Nonnull GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomAssignmentTargetPropertyIdentifier(ctx, depth);
        } else {
            return randomAssignmentTargetPropertyProperty(ctx, depth);
        }
    }

    @Nonnull
    private static BindingPropertyIdentifier randomBindingPropertyIdentifier(@Nonnull GenCtx ctx, int depth) {
        return new BindingPropertyIdentifier(randomBindingIdentifier(ctx, depth - 1), optional(Fuzzer::randomExpression).apply(ctx, depth - 1));
    }

    @Nonnull
    private static AssignmentTargetPropertyIdentifier randomAssignmentTargetPropertyIdentifier(@Nonnull GenCtx ctx, int depth) {
        return new AssignmentTargetPropertyIdentifier(randomAssignmentTargetIdentifier(ctx, depth - 1), optional(Fuzzer::randomExpression).apply(ctx, depth - 1));
    }

    @Nonnull
    private static BindingPropertyProperty randomBindingPropertyProperty(@Nonnull GenCtx ctx, int depth) {
        return new BindingPropertyProperty(randomPropertyName(ctx, depth - 1), randomBindingBindingWithDefault(ctx, depth - 1));
    }

    @Nonnull
    private static AssignmentTargetPropertyProperty randomAssignmentTargetPropertyProperty(@Nonnull GenCtx ctx, int depth) {
        return new AssignmentTargetPropertyProperty(randomPropertyName(ctx, depth - 1), randomAssignmentTargetAssignmentTargetWithDefault(ctx, depth - 1));
    }

    @Nonnull
    private static BindingWithDefault randomBindingWithDefault(@Nonnull GenCtx ctx, int depth) {
        return new BindingWithDefault(randomBinding(ctx, depth - 1), randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static AssignmentTargetWithDefault randomAssignmentTargetWithDefault(@Nonnull GenCtx ctx, int depth) {
        return new AssignmentTargetWithDefault(randomAssignmentTarget(ctx, depth - 1), randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static Block randomBlock(@Nonnull GenCtx ctx, int depth) {
        if (depth < 1) {
            return new Block(ImmutableList.empty());
        }
        return new Block(many(Fuzzer::randomStatement).apply(ctx.allowMissingElse(), depth - 1));
    }

    @Nonnull
    private static BlockStatement randomBlockStatement(@Nonnull GenCtx ctx, int depth) {
        return new BlockStatement(randomBlock(ctx.allowMissingElse(), depth - 1));
    }

    @Nonnull
    private static BreakStatement randomBreakStatement(@Nonnull GenCtx ctx, int depth) {
        return new BreakStatement(optional(Fuzzer::randomIdentifierString).apply(ctx, depth - 1));
    }

    @Nonnull
    private static CallExpression randomCallExpression(@Nonnull GenCtx ctx, int depth) {
        return new CallExpression(randomExpressionSuper(ctx, depth - 1), many(Fuzzer::randomSpreadElementExpression).apply(ctx, depth - 1));
    }

    @Nonnull
    private static CatchClause randomCatchClause(@Nonnull GenCtx ctx, int depth) {
        Binding binding = (Binding) randomParameter(ctx, depth - 1);
        return new CatchClause(binding, randomBlock(ctx, depth - 1));
    }

    @Nonnull
    private static ClassDeclaration randomClassDeclaration(@Nonnull GenCtx ctx, int depth) {
        return new ClassDeclaration(randomBindingIdentifier(ctx, depth - 1), optional(Fuzzer::randomExpression).apply(ctx, depth - 1), many(Fuzzer::randomClassElement).apply(ctx, depth - 1));
    }

    @Nonnull
    private static ClassElement randomClassElement(@Nonnull GenCtx ctx, int depth) {
        return new ClassElement(false, randomMethodDefinition(ctx, depth - 1));
    }

    @Nonnull
    private static ClassExpression randomClassExpression(@Nonnull GenCtx ctx, int depth) {
        return new ClassExpression(optional(Fuzzer::randomBindingIdentifier).apply(ctx, depth - 1), optional(Fuzzer::randomExpression).apply(ctx, depth - 1), many(Fuzzer::randomClassElement).apply(ctx, depth - 1));
    }

    @Nonnull
    private static CompoundAssignmentExpression randomCompoundAssignmentExpression(@Nonnull GenCtx ctx, int depth) {
        SimpleAssignmentTarget lhs;
        do {
            lhs = randomSimpleAssignmentTarget(ctx, depth - 1);
        }
        while (ctx.inStrictMode && lhs instanceof IdentifierExpression && Utils.isRestrictedWord(((IdentifierExpression) lhs).name));
        return new CompoundAssignmentExpression(
                lhs,
                choice(CompoundAssignmentOperator.values()).apply(ctx, depth - 1),
                randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static ComputedMemberExpression randomComputedMemberExpression(@Nonnull GenCtx ctx, int depth) {
        return new ComputedMemberExpression(randomExpression(ctx, depth - 1), randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static ComputedMemberAssignmentTarget randomComputedMemberAssignmentTarget(@Nonnull GenCtx ctx, int depth) {
        return new ComputedMemberAssignmentTarget(randomExpression(ctx, depth - 1), randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static ComputedPropertyName randomComputedPropertyName(@Nonnull GenCtx ctx, int depth) {
        return new ComputedPropertyName(randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static ConditionalExpression randomConditionalExpression(@Nonnull GenCtx ctx, int depth) {
        return new ConditionalExpression(randomExpression(ctx, depth - 1), randomExpression(ctx, depth - 1), randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static ContinueStatement randomContinueStatement(@Nonnull GenCtx ctx, int depth) {
        return new ContinueStatement(optional(Fuzzer::randomIdentifierString).apply(ctx, depth - 1));
    }

    @Nonnull
    private static DataProperty randomDataProperty(@Nonnull GenCtx ctx, int depth) {
        return new DataProperty(randomPropertyName(ctx, depth - 1), randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static DebuggerStatement randomDebuggerStatement(@Nonnull GenCtx ctx, int depth) {
        return new DebuggerStatement();
    }

    @Nonnull
    private static Directive randomDirective(@Nonnull GenCtx ctx, int depth) {
        String value = Utils.escapeStringLiteral(randomIdentifierString(ctx, depth - 1));
        return new Directive(value.substring(1, value.length() - 1));
    }

    @Nonnull
    private static DoWhileStatement randomDoWhileStatement(@Nonnull GenCtx ctx, int depth) {
        return new DoWhileStatement(randomStatement(ctx.enterIteration().allowMissingElse(), depth - 1), randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static EmptyStatement randomEmptyStatement(@Nonnull GenCtx ctx, int depth) {
        return new EmptyStatement();
    }

    @Nonnull
    private static Export randomExport(@Nonnull GenCtx ctx, int depth) {
        return new Export(randomFunctionDeclarationClassDeclarationVariableDeclaration(ctx, depth - 1));
    }

    @Nonnull
    private static ExportAllFrom randomExportAllFrom(@Nonnull GenCtx ctx, int depth) {
        return new ExportAllFrom(randomIdentifierString(ctx, depth - 1));
    }

    @Nonnull
    private static ExportDeclaration randomExportDeclaration(@Nonnull GenCtx ctx, int depth) {
        return choice(exportDeclarationGens).apply(ctx, depth - 1).apply(ctx, depth - 1);
    }

    @Nonnull
    private static ExportDefault randomExportDefault(@Nonnull GenCtx ctx, int depth) {
        return new ExportDefault(randomFunctionDeclarationClassDeclarationExpression(ctx, depth - 1));
    }

    @Nonnull
    private static ExportFrom randomExportFrom(@Nonnull GenCtx ctx, int depth) {
        return new ExportFrom(many(Fuzzer::randomExportFromSpecifier).apply(ctx, depth - 1), randomIdentifierString(ctx, depth-1));
    }

    @Nonnull
    private static ExportFromSpecifier randomExportFromSpecifier(@Nonnull GenCtx ctx, int depth) {
        return new ExportFromSpecifier(randomIdentifierString(ctx, depth-1), optional(Fuzzer::randomIdentifierString).apply(ctx, depth - 1));
    }

    @Nonnull
    private static ExportLocals randomExportLocals(@Nonnull GenCtx ctx, int depth) {
        return new ExportLocals(many(Fuzzer::randomExportLocalSpecifier).apply(ctx, depth - 1));
    }

    @Nonnull
    private static ExportLocalSpecifier randomExportLocalSpecifier(@Nonnull GenCtx ctx, int depth) {
        return new ExportLocalSpecifier(randomIdentifierExpression(ctx, depth-1), optional(Fuzzer::randomIdentifierString).apply(ctx, depth - 1));
    }

    @Nonnull
    private static Expression randomExpression(@Nonnull GenCtx ctx, int depth) {
        if (depth < 0) {
            return randomLiteralStringExpression(ctx, depth - 1);
        }
        Expression expression;
        do {
            expression = choice(expressionGens).apply(ctx, depth - 1).apply(ctx, depth - 1);
        } while (!ctx.allowYieldExpression && (expression instanceof YieldExpression || expression instanceof YieldGeneratorExpression) || !ctx.allowAwaitExpression && (expression instanceof AwaitExpression));
        return expression;
    }

    @Nonnull
    private static ExpressionStatement randomExpressionStatement(@Nonnull GenCtx ctx, int depth) {
        return new ExpressionStatement(randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static ExpressionSuper randomExpressionSuper(@Nonnull GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomExpression(ctx, depth);
        } else {
            return randomSuper();
        }
    }

    @Nonnull
    private static ImmutableList<ExpressionTemplateElement> randomAlternatingTemplateElementExpression(@Nonnull GenCtx ctx, int depth) {
        return ImmutableList.of(randomTemplateElement(ctx, depth - 1), randomExpression(ctx, depth - 1), randomTemplateElement(ctx, depth - 1));
    }

    @Nonnull
    private static ForInStatement randomForInStatement(@Nonnull GenCtx ctx, int depth) {
        return new ForInStatement(randomVariableDeclarationAssignmentTarget(ctx.inForInOfStatement(), depth - 1), randomExpression(ctx, depth - 1), randomStatement(ctx, depth - 1));
    }

    @Nonnull
    private static ForOfStatement randomForOfStatement(@Nonnull GenCtx ctx, int depth) {
        return new ForOfStatement(randomVariableDeclarationAssignmentTarget(ctx.inForInOfStatement(), depth - 1), randomExpression(ctx, depth - 1), randomStatement(ctx, depth - 1));
    }

    @Nonnull
    private static ForStatement randomForStatement(@Nonnull GenCtx ctx, int depth) {
        return new ForStatement(optional(Fuzzer::randomVariableDeclarationExpression).apply(ctx, depth - 1), optional(Fuzzer::randomExpression).apply(ctx, depth - 1), optional(Fuzzer::randomExpression).apply(ctx, depth - 1), randomStatement(ctx, depth - 1));
    }

    @Nonnull
    private static FormalParameters randomFormalParameters(@Nonnull GenCtx ctx, int depth) {
        return new FormalParameters(many(Fuzzer::randomParameter).apply(ctx, depth - 1), optional(Fuzzer::randomBinding).apply(ctx, depth - 1));
    }

    @Nonnull
    private static Parameter randomParameter(@Nonnull GenCtx ctx, int depth) {
        // returns nodes that are Binding, but not Member Expression
        switch (ctx.random.nextInt(3)) {
            case 0:
                return randomArrayBinding(ctx, depth);
            case 1:
                return randomObjectBinding(ctx, depth);
            default:
                return randomBindingIdentifier(ctx, depth);
        }
    }

    @Nonnull
    private static FunctionBody randomFunctionBody(@Nonnull GenCtx ctx, int depth) {
        ImmutableList<Directive> directives = many(Fuzzer::randomDirective).apply(ctx, depth - 1);
        if (!ctx.inStrictMode && directives.exists(dir -> dir != null)) {
            ctx = ctx.enterStrictMode();
        }
        return new FunctionBody(directives, many(Fuzzer::randomStatement).apply(ctx.enterFunctional(), depth - 1));
    }

    private static FunctionBodyExpression randomFunctionBodyExpression(GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomFunctionBody(ctx, depth);
        } else {
            return randomExpression(ctx, depth);
        }
    }

    @Nonnull
    private static FunctionDeclaration randomFunctionDeclaration(@Nonnull GenCtx ctx, int depth) {
        FunctionBody body = randomFunctionBody(ctx.enterFunctional().clearLabels(), depth - 1);
        if (isFunctionBodyStrict(body)) {
            ctx = ctx.enterStrictMode();
        }
        boolean isGenerator = ctx.random.nextBoolean();
        if (isGenerator) {
            ctx = ctx.inGeneratorFunction();
        }
        boolean isAsync = ctx.random.nextBoolean();
        if (isAsync) {
            ctx = ctx.inAsyncFunction();
        }
        return new FunctionDeclaration(isAsync, isGenerator, randomBindingIdentifier(ctx, depth - 1), randomFormalParameters(ctx, depth - 1), body);
    }

    @Nonnull
    private static FunctionDeclarationClassDeclarationExpression randomFunctionDeclarationClassDeclarationExpression(@Nonnull GenCtx ctx, int depth) {
        switch (ctx.random.nextInt(3)) {
            case 0:
                return randomFunctionDeclaration(ctx, depth);
            case 1:
                return randomClassDeclaration(ctx, depth);
            default:
                return randomExpression(ctx, depth);
        }
    }

    @Nonnull
    private static FunctionDeclarationClassDeclarationVariableDeclaration randomFunctionDeclarationClassDeclarationVariableDeclaration(@Nonnull GenCtx ctx, int depth) {
        switch (ctx.random.nextInt(3)) {
            case 0:
                return randomFunctionDeclaration(ctx, depth);
            case 1:
                return randomClassDeclaration(ctx, depth);
            default:
                return randomVariableDeclaration(ctx, depth);
        }
    }

    @Nonnull
    private static FunctionExpression randomFunctionExpression(@Nonnull GenCtx ctx, int depth) {
        FunctionBody body = randomFunctionBody(ctx.enterFunctional(), depth - 1);
        if (isFunctionBodyStrict(body)) {
            ctx = ctx.enterStrictMode();
        }
        boolean isGenerator = ctx.random.nextBoolean();
        if (isGenerator) {
            ctx = ctx.inGeneratorFunction();
        }
        boolean isAsync = ctx.random.nextBoolean();
        if (isAsync) {
            ctx = ctx.inAsyncFunction();
        }
        return new FunctionExpression(isAsync, isGenerator, optional(Fuzzer::randomBindingIdentifier).apply(ctx, depth - 1), randomFormalParameters(ctx, depth - 1), body);
    }

    @Nonnull
    private static Getter randomGetter(@Nonnull GenCtx ctx, int depth) {
        FunctionBody body = randomFunctionBody(ctx.enterFunctional(), depth - 1);
        if (isFunctionBodyStrict(body)) {
            ctx = ctx.enterStrictMode();
        }
        return new Getter(randomPropertyName(ctx, depth - 1), body);
    }

    @Nonnull
    private static IdentifierExpression randomIdentifier(@Nonnull GenCtx ctx, int depth, boolean allowReserved, boolean allowRestricted) {
        String name;
        boolean genarateSpecial = ctx.random.nextDouble() < SPECIAL_IDENT_PROBABILITY;
        if (genarateSpecial && allowReserved) {
            if (ctx.inStrictMode) {
                name = choice(STRICT_MODE_RESERVED_WORDS).apply(ctx, depth - 1);
            } else {
                name = choice(RESERVED_WORDS).apply(ctx, depth - 1);
            }
        } else if (genarateSpecial && allowRestricted) {
            name = choice(RESTRICTED_WORDS).apply(ctx, depth - 1);
        } else {
            boolean disallow;
            do {
                disallow = false;
                name = randomIdentifierString(ctx, depth - 1);
                for (String reservedWord : (ctx.inStrictMode ? STRICT_MODE_RESERVED_WORDS : RESERVED_WORDS)) {
                    if (reservedWord.equals(name)) {
                        disallow = true;
                    }
                }
            } while (disallow);
        }
        return new IdentifierExpression(name);
    }

    @Nonnull
    private static IdentifierExpression randomIdentifierExpression(@Nonnull GenCtx ctx, int depth) {
        // restricted word are filtered in assignment expression.
        return randomIdentifier(ctx, depth - 1, false, true);
    }

    @Nonnull
    private static String randomIdentifierString(@Nonnull GenCtx ctx, int depth) {
        StringBuilder result = new StringBuilder();
        result.append(identifierStartArr[ctx.random.nextInt(identifierStartArr.length)]);
        int length = ctx.random.nextInt(MAX_IDENT_LENGTH);
        for (int i = 0; i < length; i++) {
            result.append(identifierPartArr[ctx.random.nextInt(identifierPartArr.length)]);
        }
        return result.toString();
    }

    @Nonnull
    private static IfStatement randomIfStatement(@Nonnull GenCtx ctx, int depth) {
        if (ctx.allowMissingElse) {
            boolean missElse = ctx.random.nextBoolean();
            if (missElse) {
                return new IfStatement(randomExpression(ctx, depth - 1), randomStatement(ctx, depth - 1), Maybe.empty());
            }
        }
        return new IfStatement(randomExpression(ctx, depth - 1), randomStatement(ctx.forbidMissingElse(), depth - 1), Maybe.of(randomStatement(ctx, depth - 1)));
    }

    @Nonnull
    private static Import randomImport(@Nonnull GenCtx ctx, int depth) {
        return new Import(optional(Fuzzer::randomBindingIdentifier).apply(ctx, depth - 1), many(Fuzzer::randomImportSpecifier).apply(ctx, depth - 1), randomIdentifierString(ctx, depth - 1));
    }

    @Nonnull
    private static ImportDeclaration randomImportDeclaration(@Nonnull GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomImport(ctx, depth);
        } else {
            return randomImportNamespace(ctx, depth);
        }
    }

    @Nonnull
    private static ImportDeclarationExportDeclarationStatement randomImportDeclarationExportDeclarationStatement(@Nonnull GenCtx ctx, int depth) {
        switch (ctx.random.nextInt(3)) {
            case 0:
                return randomImportDeclaration(ctx, depth);
            case 1:
                return randomExportDeclaration(ctx, depth);
            default:
                return randomStatement(ctx, depth);
        }
    }

    @Nonnull
    private static ImportNamespace randomImportNamespace(@Nonnull GenCtx ctx, int depth) {
        return new ImportNamespace(optional(Fuzzer::randomBindingIdentifier).apply(ctx, depth - 1), randomBindingIdentifier(ctx, depth - 1), randomIdentifierString(ctx, depth - 1));
    }

    @Nonnull
    private static ImportSpecifier randomImportSpecifier(@Nonnull GenCtx ctx, int depth) {
        return new ImportSpecifier(optional(Fuzzer::randomIdentifierString).apply(ctx, depth - 1), randomBindingIdentifier(ctx, depth - 1));
    }

    @Nonnull
    private static LabeledStatement randomLabeledStatement(@Nonnull GenCtx ctx, int depth) {
        return new LabeledStatement(randomIdentifierString(ctx, depth - 1), randomStatement(ctx, depth - 1));
    }

    @Nonnull
    private static LiteralBooleanExpression randomLiteralBooleanExpression(@Nonnull GenCtx ctx, int depth) {
        return new LiteralBooleanExpression(ctx.random.nextBoolean());
    }

    @Nonnull
    private static LiteralInfinityExpression randomLiteralInfinityExpression(@Nonnull GenCtx ctx, int depth) {
        return new LiteralInfinityExpression();
    }

    @Nonnull
    private static LiteralNullExpression randomLiteralNullExpression(@Nonnull GenCtx ctx, int depth) {
        return new LiteralNullExpression();
    }

    @Nonnull
    private static LiteralNumericExpression randomLiteralNumericExpression(@Nonnull GenCtx ctx, int depth) {
        return new LiteralNumericExpression(randomNumber(ctx));
    }

    @Nonnull
    private static LiteralRegExpExpression randomLiteralRegExpExpression(@Nonnull GenCtx ctx, int depth) {
        return new LiteralRegExpExpression(randomRegExpString(ctx, depth - 1), ctx.random.nextBoolean(), ctx.random.nextBoolean(), ctx.random.nextBoolean(), ctx.random.nextBoolean(), ctx.random.nextBoolean(), ctx.random.nextBoolean());
    }

    @Nonnull
    private static LiteralStringExpression randomLiteralStringExpression(@Nonnull GenCtx ctx, int depth) {
        return new LiteralStringExpression(randomIdentifierString(ctx, depth - 1));
    }

    @Nonnull
    private static MemberExpression randomMemberExpression(@Nonnull GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomComputedMemberExpression(ctx, depth);
        } else {
            return randomStaticMemberExpression(ctx, depth);
        }
    }

    @Nonnull
    private static Method randomMethod(@Nonnull GenCtx ctx, int depth) {
        return new Method(false, false, randomPropertyName(ctx, depth - 1), randomFormalParameters(ctx, depth - 1), randomFunctionBody(ctx, depth - 1));
    }

    @Nonnull
    private static MethodDefinition randomMethodDefinition(@Nonnull GenCtx ctx, int depth) {
        switch (ctx.random.nextInt(3)) {
            case 0:
                return randomGetter(ctx, depth);
            case 1:
                return randomSetter(ctx, depth);
            default:
                return randomMethod(ctx, depth);
        }
    }

    @Nonnull
    private static Module randomModule(@Nonnull GenCtx ctx, int depth) {
        return new Module(many(Fuzzer::randomDirective).apply(ctx, depth - 1), many(Fuzzer::randomImportDeclarationExportDeclarationStatement).apply(ctx, depth - 1));
    }

    @Nonnull
    private static NewExpression randomNewExpression(@Nonnull GenCtx ctx, int depth) {
        return new NewExpression(randomExpression(ctx, depth - 1), many(Fuzzer::randomSpreadElementExpression).apply(ctx, depth - 1));
    }

    @Nonnull
    private static NewTargetExpression randomNewTargetExpression(@Nonnull GenCtx ctx, int depth) {
        return new NewTargetExpression();
    }

    @Nonnull
    private static double randomNumber(@Nonnull GenCtx ctx) {
        return Math.exp(ctx.random.nextGaussian());
    }

    @Nonnull
    private static ObjectBinding randomObjectBinding(@Nonnull GenCtx ctx, int depth) {
        return new ObjectBinding(many(Fuzzer::randomBindingProperty).apply(ctx, depth - 1), optional(Fuzzer::randomBinding).apply(ctx, depth - 1));
    }

    @Nonnull
    private static ObjectAssignmentTarget randomObjectAssignmentTarget(@Nonnull GenCtx ctx, int depth) {
        return new ObjectAssignmentTarget(many(Fuzzer::randomAssignmentTargetProperty).apply(ctx, depth - 1), optional(Fuzzer::randomAssignmentTarget).apply(ctx, depth - 1));
    }

    @Nonnull
    private static ObjectExpression randomObjectExpression(@Nonnull GenCtx ctx, int depth) {
        return new ObjectExpression(many(Fuzzer::randomObjectProperty).apply(ctx, depth - 1));
    }

    @Nonnull
    private static ObjectProperty randomObjectProperty(@Nonnull GenCtx ctx, int depth) {
        switch (ctx.random.nextInt(5)) {
            case 0:
                return randomDataProperty(ctx, depth);
            case 1:
                return randomShorthandProperty(ctx, depth);
            default:
                return randomMethodDefinition(ctx, depth);
        }
    }

    @Nonnull
    private static PropertyName randomPropertyName(@Nonnull GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomComputedPropertyName(ctx, depth);
        } else {
            return randomStaticPropertyName(ctx, depth);
        }
    }

    @Nonnull
    private static String randomRegExpString(@Nonnull GenCtx ctx, int depth) {
        return "/" + randomIdentifierString(ctx, depth - 1) + "/";
    }

    @Nonnull
    private static Statement randomReturnStatement(@Nonnull GenCtx ctx, int depth) {
        if (ctx.allowReturn) {
            return new ReturnStatement(optional(Fuzzer::randomExpression).apply(ctx, depth - 1));
        } else {
            return new EmptyStatement();
        }
    }

    @Nonnull
    private static Script randomScript(@Nonnull GenCtx ctx, int depth) {
        FunctionBody randomFunctionBody = randomFunctionBody(ctx, depth - 1);
        return new Script(randomFunctionBody.directives, randomFunctionBody.statements);
    }

    @Nonnull
    private static Setter randomSetter(@Nonnull GenCtx ctx, int depth) {
        FunctionBody body = randomFunctionBody(ctx.enterFunctional(), depth - 1);
        if (isFunctionBodyStrict(body)) {
            ctx = ctx.enterStrictMode();
        }
        return new Setter(randomPropertyName(ctx, depth - 1), randomParameter(ctx, depth - 1), body);
    }

    @Nonnull
    private static ShorthandProperty randomShorthandProperty(@Nonnull GenCtx ctx, int depth) {
        return new ShorthandProperty(randomIdentifierExpression(ctx, depth - 1));
    }

    @Nonnull
    private static SpreadElement randomSpreadElement(@Nonnull GenCtx ctx, int depth) {
        return new SpreadElement(randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static SpreadElementExpression randomSpreadElementExpression(@Nonnull GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomSpreadElement(ctx, depth);
        } else {
            return randomExpression(ctx, depth);
        }
    }

    @Nonnull
    private static Statement randomStatement(@Nonnull GenCtx ctx, int depth) {
        return randomStatementGeneric(ctx, depth, true);
    }

    @Nonnull
    private static Statement randomStatementGeneric(@Nonnull GenCtx ctx, int depth, boolean allowIteration) {
        if (depth <= 0) {
            switch (ctx.random.nextInt(ctx.inIteration ? 4 : 2)) {
                case 0:
                    return randomDebuggerStatement(ctx, depth - 1);
                case 1:
                    return randomEmptyStatement(ctx, depth - 1);
                case 2:
                    return randomBreakStatement(ctx, depth - 1);
                default:
                    return randomContinueStatement(ctx, depth - 1);
            }
        }
        int n;
        int total = totalStatements - (allowIteration ? 0 : iterationStatementGens.length);
        do {
            n = ctx.random.nextInt(total);
            switch (n) {
                case kGenBreakStatement:
                    if (ctx.labelsInFunctionBoundary.length == 0 && !ctx.inSwitch && !ctx.inIteration) {
                        continue;
                    }
                    break;
                case kGenContinueStatement:
                    if (!ctx.inIteration) {
                        continue;
                    }
                    break;
                case kGenWithStatement:
                    if (ctx.inStrictMode) {
                        continue;
                    }
                    break;
                case kGenReturnStatement:
                    if (!ctx.inFunctional) {
                        continue;
                    }
                    break;
            }
            break;
        } while (true);

        switch (n) {
            case kGenBreakStatement:
                if ((!ctx.inSwitch && !ctx.inIteration) || ctx.labelsInFunctionBoundary.length > 0 && ctx.random.nextBoolean()) {
                    // with label
//        Maybe<String> label = ctx.labelsInFunctionBoundary.index(ctx.random.nextInt(ctx.labelsInFunctionBoundary.length));
                    Maybe<String> label = optional(Fuzzer::randomIdentifierString).apply(ctx, depth);
                    return new BreakStatement(label);
                } else {
                    return new BreakStatement(Maybe.empty());
                }
            case kGenContinueStatement:
                if (ctx.iterationLabelsInFunctionBoundary.length > 0 && ctx.random.nextBoolean()) {
                    // with label
//        Maybe<IdentifierExpression> label = ctx.iterationLabelsInFunctionBoundary.index(
//            ctx.random.nextInt(ctx.iterationLabelsInFunctionBoundary.length));
                    Maybe<String> label = optional(Fuzzer::randomIdentifierString).apply(ctx, depth);
                    return new ContinueStatement(label);
                } else {
                    return new ContinueStatement(Maybe.empty());
                }
            case kGenWithStatement:
                return new WithStatement(randomExpression(ctx, depth - 1), randomStatement(ctx, depth - 1));
            case kGenReturnStatement:
                if (ctx.allowReturn) {
                    if (ctx.random.nextBoolean()) {
                        return new ReturnStatement(Maybe.of(randomExpression(ctx, depth - 1)));
                    } else {
                        return new ReturnStatement(Maybe.empty());
                    }
                } else {
                    return new EmptyStatement();
                }
            case kGenLabeledStatement:
                IdentifierExpression label = randomIdentifier(ctx, depth - 1, false, true);
                while (ctx.labels.exists(label::equals)) {
                    label = randomIdentifier(ctx, depth - 1, false, true);
                }
                int bodyN = ctx.random.nextInt(totalStatements);
                if (bodyN < iterationStatementGens.length) {
                    // generate iteration statement
                    IterationStatement body = iterationStatementGens[bodyN].apply(ctx.withIterationLabel(label), depth - 1);
                    return new LabeledStatement(label.name, body);
                } else {
                    Statement body = randomStatementGeneric(ctx.withLabel(label), depth - 1, false);
                    return new LabeledStatement(label.name, body);
                }
            default:
                if (n < nonIterationStatementGens.length + 5) {
                    return nonIterationStatementGens[n - 5].apply(ctx, depth - 1);
                } else {
                    return iterationStatementGens[n - nonIterationStatementGens.length - 5].apply(ctx, depth - 1);
                }
        }
    }

    @Nonnull
    private static StaticMemberExpression randomStaticMemberExpression(@Nonnull GenCtx ctx, int depth) {
        return new StaticMemberExpression(randomExpressionSuper(ctx, depth - 1), randomIdentifierString(ctx, depth - 1));
    }

    @Nonnull
    private static StaticMemberAssignmentTarget randomStaticMemberAssignmentTarget(@Nonnull GenCtx ctx, int depth) {
        return new StaticMemberAssignmentTarget(randomExpressionSuper(ctx, depth - 1), randomIdentifierString(ctx, depth - 1));
    }

    @Nonnull
    private static StaticPropertyName randomStaticPropertyName(@Nonnull GenCtx ctx, int depth) {
        return new StaticPropertyName(randomIdentifierString(ctx, depth - 1));
    }

    @Nonnull
    private static String randomString(@Nonnull GenCtx ctx, int depth) {
        int length = ctx.random.nextInt(MAX_STRING_LENGTH);
        StringBuilder sb = new StringBuilder();
        ctx.random.ints(length, 20, 127).forEach((i) -> sb.append((char) i));
        return sb.toString();
    }

    @Nonnull
    private static Super randomSuper() {
        return new Super();
    }

    @Nonnull
    private static SwitchCase randomSwitchCase(@Nonnull GenCtx ctx, int depth) {
        return new SwitchCase(randomExpression(ctx, depth - 1), many(Fuzzer::randomStatement).apply(ctx, depth - 1));
    }

    @Nonnull
    private static SwitchDefault randomSwitchDefault(@Nonnull GenCtx ctx, int depth) {
        return new SwitchDefault(many(Fuzzer::randomStatement).apply(ctx, depth - 1));
    }

    @Nonnull
    private static SwitchStatement randomSwitchStatement(@Nonnull GenCtx ctx, int depth) {
        ctx = ctx.allowMissingElse().enterSwitch();
        return new SwitchStatement(
                randomExpression(ctx, depth - 1),
                Fuzzer.many(Fuzzer::randomSwitchCase).apply(ctx, depth - 1));
    }

    @Nonnull
    private static SwitchStatementWithDefault randomSwitchStatementWithDefault(@Nonnull GenCtx ctx, int depth) {
        ctx = ctx.allowMissingElse().enterSwitch();
        return new SwitchStatementWithDefault(
                randomExpression(ctx, depth - 1),
                Fuzzer.many(Fuzzer::randomSwitchCase).apply(ctx, depth - 1),
                randomSwitchDefault(ctx, depth - 1),
                Fuzzer.many(Fuzzer::randomSwitchCase).apply(ctx, depth - 1));
    }

    @Nonnull
    private static TemplateElement randomTemplateElement(@Nonnull GenCtx ctx, int depth) {
        return new TemplateElement(randomIdentifierString(ctx, depth - 1));
    }

    @Nonnull
    private static TemplateExpression randomTemplateExpression(@Nonnull GenCtx ctx, int depth) {
        return new TemplateExpression(optional(Fuzzer::randomExpression).apply(ctx, depth - 1), randomAlternatingTemplateElementExpression(ctx, depth - 1));
    }

    @Nonnull
    private static ThisExpression randomThisExpression(@Nonnull GenCtx ctx, int depth) {
        return new ThisExpression();
    }

    @Nonnull
    private static ThrowStatement randomThrowStatement(@Nonnull GenCtx ctx, int depth) {
        return new ThrowStatement(randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static TryCatchStatement randomTryCatchStatement(@Nonnull GenCtx ctx, int depth) {
        return new TryCatchStatement(randomBlock(ctx, depth - 1), randomCatchClause(ctx, depth - 1));
    }

    @Nonnull
    private static TryFinallyStatement randomTryFinallyStatement(@Nonnull GenCtx ctx, int depth) {
        return new TryFinallyStatement(
                randomBlock(ctx, depth - 1),
                optional(Fuzzer::randomCatchClause).apply(ctx, depth - 1),
                randomBlock(ctx, depth - 1));
    }

    @Nonnull
    private static UnaryExpression randomUnaryExpression(@Nonnull GenCtx ctx, int depth) {
        UnaryOperator operator = choice(UnaryOperator.values()).apply(ctx, depth - 1);
        return new UnaryExpression(operator, randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static UpdateExpression randomUpdateExpression(@Nonnull GenCtx ctx, int depth) {
        UpdateOperator operator = choice(UpdateOperator.values()).apply(ctx, depth - 1);
        return new UpdateExpression(false, operator, randomSimpleAssignmentTarget(ctx, depth - 1));
    }

    @Nonnull
    private static VariableDeclaration randomVariableDeclaration(@Nonnull GenCtx ctx, int depth) {
        VariableDeclarationKind kind = choice(VariableDeclarationKind.values()).apply(ctx, depth - 1);
        if (kind.name.equals("const")) {
            ctx = ctx.variableDeclarationKindIsConst();
        }
        return new VariableDeclaration(ctx.inStrictMode ? VariableDeclarationKind.Var : kind, ctx.inForInOfStatement ? ImmutableList.of(randomVariableDeclaratorWithoutInit(ctx, depth - 1)) : many1(Fuzzer::randomVariableDeclarator).apply(ctx, depth - 1));
    }

    @Nonnull
    private static VariableDeclarationAssignmentTarget randomVariableDeclarationAssignmentTarget(@Nonnull GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomVariableDeclaration(ctx, depth);
//            return randomVariableDeclarationWithoutInit(ctx, depth);
        } else {
            return randomAssignmentTarget(ctx, depth);
        }
    }

    @Nonnull
    private static VariableDeclarator randomVariableDeclaratorWithoutInit(@Nonnull GenCtx ctx, int depth) {
        Binding binding = (Binding) randomParameter(ctx, depth - 1);
        return new VariableDeclarator(binding, Maybe.empty());
    }

    @Nonnull
    private static VariableDeclarationExpression randomVariableDeclarationExpression(GenCtx ctx, int depth) {
        int number = ctx.random.nextInt();
        if (number % 2 == 0) {
            return randomVariableDeclaration(ctx, depth);
        } else {
            return randomExpression(ctx, depth);
        }
    }

    @Nonnull
    private static VariableDeclarationStatement randomVariableDeclarationStatement(@Nonnull GenCtx ctx, int depth) {
        return new VariableDeclarationStatement(randomVariableDeclaration(ctx, depth - 1));
    }

    @Nonnull
    private static VariableDeclarator randomVariableDeclarator(@Nonnull GenCtx ctx, int depth) {
        Binding binding = (Binding) randomParameter(ctx, depth - 1);
        if (binding instanceof BindingIdentifier && !ctx.isVariableDeclarationKindConst) {
            return new VariableDeclarator(binding, optional(Fuzzer::randomExpression).apply(ctx, depth - 1));
        } else {
            return new VariableDeclarator(binding, Maybe.of(randomExpression(ctx, depth - 1)));
        }
    }

    @Nonnull
    private static WhileStatement randomWhileStatement(@Nonnull GenCtx ctx, int depth) {
        return new WhileStatement(randomExpression(ctx, depth - 1), randomStatement(ctx, depth - 1));
    }

    @Nonnull
    private static WithStatement randomWithStatement(@Nonnull GenCtx ctx, int depth) {
        return new WithStatement(randomExpression(ctx, depth - 1), randomStatement(ctx, depth - 1));
    }

    @Nonnull
    private static YieldExpression randomYieldExpression(@Nonnull GenCtx ctx, int depth) {
        return new YieldExpression(optional(Fuzzer::randomExpression).apply(ctx, depth - 1));
    }

    @Nonnull
    private static YieldGeneratorExpression randomYieldGeneratorExpression(@Nonnull GenCtx ctx, int depth) {
        return new YieldGeneratorExpression(randomExpression(ctx, depth - 1));
    }

    @Nonnull
    private static AwaitExpression randomAwaitExpression(@Nonnull GenCtx ctx, int depth) {
        return new AwaitExpression(Fuzzer.randomExpression(ctx, depth));
    }

    private interface Gen<T> {
        @Nonnull
        T apply(@Nonnull GenCtx ctx, int depth);
    }
}


text:
// Copyright 2011-2014 UFNA, LLC. All Rights Reserved.

#pragma once

#include "GameFramework/Pawn.h"
#include "SeaCraftVehicle.generated.h"

/**
 * Basic class for all vehicles that controls weapons, seats, effects and animations
 */
UCLASS(abstract/*, HeaderGroup=Pawn*/, config = Game, BlueprintType, Blueprintable, hidecategories = (Navigation, "AI|Navigation"))
class ASeaCraftVehicle : public APawn
{
	GENERATED_UCLASS_BODY()

	/** Configure weapons and setup initial variables */
	virtual void PostInitializeComponents() override;

	//////////////////////////////////////////////////////////////////////////
	// Vehicle mesh

	/** The main skeletal mesh associated with this Vehicle */
	UPROPERTY(Category = Vehicle, VisibleDefaultsOnly, BlueprintReadOnly)
	TSubobjectPtr<class USkeletalMeshComponent> VehicleMesh;

	/** Name of the MeshComponent. Use this name if you want to prevent creation of the component (with PCIP.DoNotCreateDefaultSubobject). */
	static FName VehicleMeshComponentName;

	//////////////////////////////////////////////////////////////////////////
	// Weapon control

	/** List of unique weapon groups */
	TArray<FName> WeaponGroups;

	/** Current controlled weapon group */
	FName CurrentWeaponGroup;

	/** Returns index of desired weapon group, -1 if group is not found */
	int32 FindWeaponGroup(const FName& WeaponGroup);

	/** Activates weapon group and makes it controlled by player */
	UFUNCTION(BlueprintCallable, Category = "Player|Vehicle|SeaCraftVehicle")
	void SetWeaponGroup(FName WeaponGroup);

	/** Cached current weapon group */
	UPROPERTY(Category = Vehicle, VisibleAnywhere, BlueprintReadOnly)
	TArray<USeaCraftVehicleWeaponComponent*> CurrentWeapons;

	//////////////////////////////////////////////////////////////////////////
	// Weapon usage

	/** [local] starts weapon fire */
	void StartWeaponFire();

	/** [local] stops weapon fire */
	void StopWeaponFire();

	/** Check if vehicle can fire weapon */
	bool CanFire() const;

	//////////////////////////////////////////////////////////////////////////
	// Input handlers

	/** Setup vehicle specific input handlers */
	virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;

	/** Player pressed start fire action */
	void OnStartFire();

	/** Player released start fire action */
	void OnStopFire();

	/** Player pressed next weapon action */
	void OnNextWeapon();

	/** Player pressed prev weapon action */
	void OnPrevWeapon();

	//////////////////////////////////////////////////////////////////////////
	// Damage & death

public:
	/** Identifies if pawn is in its dying state */
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Health)
	uint32 bIsDying : 1;

	/** Current health of the Pawn */
	UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = Health)
	float Health;

	/** Take damage, handle death */
	virtual float TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, class AActor* DamageCauser) override;

	/** Pawn suicide */
	virtual void Suicide();

	/** Kill this pawn */
	virtual void KilledBy(class APawn* EventInstigator);

	/** Returns True if the pawn can die in the current state */
	virtual bool CanDie(float KillingDamage, FDamageEvent const& DamageEvent, AController* Killer, AActor* DamageCauser) const;

	/**
	 * Kills pawn.  Server/authority only.
	 * @param KillingDamage - Damage amount of the killing blow
	 * @param DamageEvent - Damage event of the killing blow
	 * @param Killer - Who killed this pawn
	 * @param DamageCauser - the Actor that directly caused the damage (i.e. the Projectile that exploded, the Weapon that fired, etc)
	 * @returns true if allowed
	 */
	virtual bool Die(float KillingDamage, struct FDamageEvent const& DamageEvent, class AController* Killer, class AActor* DamageCauser);

	/** Die when we fall out of the world */
	virtual void FellOutOfWorld(const class UDamageType& dmgType) override;

	/** Called on the actor right before replication occurs */
	virtual void PreReplication(IRepChangedPropertyTracker & ChangedPropertyTracker) override;
protected:
	/** Notification when killed, for both the server and client. */
	virtual void OnDeath(float KillingDamage, struct FDamageEvent const& DamageEvent, class APawn* InstigatingPawn, class AActor* DamageCauser);

	/** Play effects on hit */
	virtual void PlayHit(float DamageTaken, struct FDamageEvent const& DamageEvent, class APawn* PawnInstigator, class AActor* DamageCauser);

	/** Sets up the replication for taking a hit */
	void ReplicateHit(float Damage, struct FDamageEvent const& DamageEvent, class APawn* InstigatingPawn, class AActor* DamageCauser, bool bKilled);

	/** Play hit or death on client */
	UFUNCTION()
	void OnRep_LastTakeHitInfo();

	/** Responsible for cleaning up bodies on clients. */
	virtual void TornOff();

	//////////////////////////////////////////////////////////////////////////
	// Reading data

public:
	/** Get current health */
	UFUNCTION(BlueprintCallable, Category = "Player|Vehicle|SeaCraftVehicle")
	float GetHealth() const;

	/** Get max health */
	UFUNCTION(BlueprintCallable, Category = "Player|Vehicle|SeaCraftVehicle")
	int32 GetMaxHealth() const;

	/** Check if pawn is still alive */
	UFUNCTION(BlueprintCallable, Category = "Player|Vehicle|SeaCraftVehicle")
	bool IsAlive() const;

protected:
	/** Replicate where this pawn was last hit and damaged */
	UPROPERTY(Transient, ReplicatedUsing=OnRep_LastTakeHitInfo)
	struct FTakeHitInfo LastTakeHitInfo;

	/** Time at which point the last take hit info for the actor times out and won't be replicated; Used to stop join-in-progress effects all over the screen */
	float LastTakeHitTimeTimeout;

	/** Current firing state */
	uint8 bWantsToFire : 1;

};


text:
namespace hana = boost::hana;

template <int> struct undefined { };

int main() {
    auto container = ::seq;

    {
        auto storage1 = container();
        auto storage2 = container();
        auto joined = hana::experimental::joined(storage1, storage2);
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::length(joined),
            hana::size_c<0>
        ));
    }

    {
        auto storage1 = container(undefined<0>{});
        auto storage2 = container();
        auto joined = hana::experimental::joined(storage1, storage2);
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::length(joined),
            hana::size_c<1>
        ));
    }

    {
        auto storage1 = container();
        auto storage2 = container(undefined<0>{});
        auto joined = hana::experimental::joined(storage1, storage2);
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::length(joined),
            hana::size_c<1>
        ));
    }

    {
        auto storage1 = container(undefined<0>{});
        auto storage2 = container(undefined<1>{});
        auto joined = hana::experimental::joined(storage1, storage2);
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::length(joined),
            hana::size_c<2>
        ));
    }

    {
        auto storage1 = container(undefined<0>{});
        auto storage2 = container(undefined<1>{});
        auto joined = hana::experimental::joined(storage1, storage2);
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::length(joined),
            hana::size_c<2>
        ));
    }

    {
        auto storage1 = container(undefined<0>{}, undefined<1>{});
        auto storage2 = container(undefined<2>{});
        auto joined = hana::experimental::joined(storage1, storage2);
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::length(joined),
            hana::size_c<3>
        ));
    }

    {
        auto storage1 = container(undefined<0>{}, undefined<1>{}, undefined<2>{});
        auto storage2 = container(undefined<3>{}, undefined<4>{});
        auto joined = hana::experimental::joined(storage1, storage2);
        BOOST_HANA_CONSTANT_CHECK(hana::equal(
            hana::length(joined),
            hana::size_c<5>
        ));
    }
}


text:
%%% RenderToolbox3 Copyright (c) 2012-2013 The RenderToolbox3 Team.
%%% About Us://github.com/DavidBrainard/RenderToolbox3/wiki/About-Us
%%% RenderToolbox3 is released under the MIT License.  See LICENSE.txt.
%
%% Render the ColorIllusion scene, with a texture.

%% Choose example files, make sure they're on the Matlab path.
parentSceneFile = 'ColorIllusion.dae';
mappingsFile = 'ColorIllusionMappings.txt';

%% Choose batch renderer options.
hints.whichConditions = [];
hints.imageWidth = 320;
hints.imageHeight = 240;
hints.recipeName = mfilename();
ChangeToWorkingFolder(hints);

%% Render with Mitsuba and PBRT.
toneMapFactor = 100;
isScale = true;
for renderer = {'Mitsuba', 'PBRT'}
    hints.renderer = renderer{1};
    nativeSceneFiles = MakeSceneFiles(parentSceneFile, '', mappingsFile, hints);
    radianceDataFiles = BatchRender(nativeSceneFiles, hints);
    montageName = sprintf('%s (%s)', 'ColorIllusion', hints.renderer);
    montageFile = [montageName '.png'];
    [SRGBMontage, XYZMontage] = ...
        MakeMontage(radianceDataFiles, montageFile, toneMapFactor, isScale, hints);
    ShowXYZAndSRGB([], SRGBMontage, montageName);
end


text:
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.facebook.presto.jdbc;

import com.facebook.presto.server.TestingPrestoServer;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;

import static com.facebook.presto.jdbc.TestDriver.closeQuietly;
import static java.lang.String.format;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;

public class TestJdbcResultSet
{
    private TestingPrestoServer server;

    private Connection connection;
    private Statement statement;

    @SuppressWarnings("JDBCResourceOpenedButNotSafelyClosed")
    @BeforeMethod
    public void setup()
            throws Exception
    {
        server = new TestingPrestoServer();
        connection = createConnection();
        statement = connection.createStatement();
    }

    @AfterMethod
    public void teardown()
    {
        closeQuietly(statement);
        closeQuietly(connection);
        closeQuietly(server);
    }

    @Test
    public void testDuplicateColumnLabels()
            throws Exception
    {
        try (ResultSet rs = statement.executeQuery("SELECT 123 x, 456 x")) {
            ResultSetMetaData metadata = rs.getMetaData();
            assertEquals(metadata.getColumnCount(), 2);
            assertEquals(metadata.getColumnName(1), "x");
            assertEquals(metadata.getColumnName(2), "x");

            assertTrue(rs.next());
            assertEquals(rs.getLong(1), 123L);
            assertEquals(rs.getLong(2), 456L);
            assertEquals(rs.getLong("x"), 123L);
        }
    }

    @SuppressWarnings("UnnecessaryBoxing")
    @Test
    public void testObjectTypes()
            throws Exception
    {
        // TODO: enable these after the server is fixed
//        String sql = "SELECT 123, 0.1, true, 'hello', 1.0 / 0.0, 0.0 / 0.0";
        String sql = "SELECT 123, 0.1, true, 'hello'";
        try (ResultSet rs = statement.executeQuery(sql)) {
            ResultSetMetaData metadata = rs.getMetaData();
//            assertEquals(metadata.getColumnCount(), 6);
            assertEquals(metadata.getColumnCount(), 4);
            assertEquals(metadata.getColumnType(1), Types.BIGINT);
            assertEquals(metadata.getColumnType(2), Types.DOUBLE);
            assertEquals(metadata.getColumnType(3), Types.BOOLEAN);
            assertEquals(metadata.getColumnType(4), Types.LONGNVARCHAR);
//            assertEquals(metadata.getColumnType(5), Types.DOUBLE);
//            assertEquals(metadata.getColumnType(6), Types.DOUBLE);

            assertTrue(rs.next());
            assertEquals(rs.getObject(1), 123L);
            assertEquals(rs.getObject(2), 0.1d);
            assertEquals(rs.getObject(3), true);
            assertEquals(rs.getObject(4), "hello");
//            assertEquals(rs.getObject(5), Double.POSITIVE_INFINITY);
//            assertEquals(rs.getObject(6), Double.NaN);
        }
    }

    private Connection createConnection()
            throws SQLException
    {
        String url = format("jdbc:presto://%s/", server.getAddress());
        return DriverManager.getConnection(url, "test", null);
    }
}