text:
<?php

class CM_Process_ForkHandler {

    /** @var int */
    private $_pid;

    /** @var Closure */
    private $_workload;

    /** @var int */
    private $_identifier;

    /**
     * @param int      $pid
     * @param Closure  $workload
     * @param int|null $identifier
     */
    public function __construct($pid, Closure $workload, $identifier = null) {
        $this->_pid = (int) $pid;
        $this->_workload = $workload;
        if (null !== $identifier) {
            $identifier = (int) $identifier;
        }
        $this->_identifier = $identifier;
    }

    /**
     * @return int
     */
    public function getPid() {
        return $this->_pid;
    }

    /**
     * @return Closure
     */
    public function getWorkload() {
        return $this->_workload;
    }

    /**
     * @throws CM_Exception
     * @return int
     */
    public function getIdentifier() {
        if (null === $this->_identifier) {
            throw new CM_Exception('Fork-handler has no identifier');
        }
        return $this->_identifier;
    }

    /**
     * @throws Exception
     */
    public function runWorkload() {
        $workload = $this->_workload;
        try {
            call_user_func($workload);
        } catch (Exception $e) {
            CM_Bootloader::getInstance()->getExceptionHandler()->handleException($e);
        }
    }
}

redpajama_set_name: RedPajamaGithub


text:
using System;
using System.IO;
using System.Linq;
using NUnit.Framework;
using Xamarin.UITest;
using Xamarin.UITest.iOS;
using Xamarin.UITest.Queries;
using System.Threading;

namespace UITests
{
	[TestFixture]
	public class Tests
	{
		iOSApp app;

		AppQuery ToggleButton(AppQuery app) { return app.All().Button("Toggle Side Menu"); }

		AppQuery IntroTitle(AppQuery app) { return app.Class("UILabel").Marked("Sidebar Navigation"); }

		AppQuery ContentTitle(AppQuery app) { return app.Class("UILabel").Marked("Content"); }

		AppQuery MenuIntroButton(AppQuery app) { return app.Button("Intro"); }
		AppQuery MenuContentButton(AppQuery app) { return app.Button("Content"); }

		[TestFixtureSetUp]
		public void BeforeAnyTests() {
			// TODO: If the iOS app being tested is included in the solution then open
			// the Unit Tests window, right click Test Apps, select Add App Project
			// and select the app projects that should be tested.
			app = ConfigureApp
				.iOS
				// TODO: Update this path to point to your iOS app and uncomment the
				// code if the app is not included in the solution.
				//.AppBundle ("../../../iOS/bin/iPhoneSimulator/Debug/UITests.iOS.app")
				.StartApp();
		}

		[SetUp]
		public void BeforeEachTest()
		{
			var introButtonVisible = app.Query(MenuIntroButton).Any();
			if (introButtonVisible)
				app.Tap(MenuIntroButton);
		}

		[Test]
		public void CanOpenSideMenuWithButton()
		{
			AssertMenuClosed();
			app.Tap(ToggleButton);
			AssertMenuOpen();
		}

		[Test]
		public void CanOpenSideMenuWithSlide()
		{
			AssertMenuClosed();
			app.DragCoordinates(15, 50, 305, 50, TimeSpan.FromMilliseconds(1400));
			AssertMenuOpen();
		}

		[Test]
		public void CanCloseMenuWithTap()
		{
			AssertMenuClosed();
			app.Tap(ToggleButton);
			AssertMenuOpen();
			app.TapCoordinates(315, 50);
			AssertMenuClosed();
		}

		[Test]
		public void CanCloseMenuWithSlide()
		{
			AssertMenuClosed();
			app.Tap(ToggleButton);
			AssertMenuOpen();
			app.DragCoordinates(305, 50, 15, 50, TimeSpan.FromMilliseconds(1000));
			AssertMenuClosed();
		}

		[Test]
		public void CanOpenMenuWithFlick()
		{
			AssertMenuClosed();
			app.DragCoordinates(15, 50, 250, 50, TimeSpan.FromMilliseconds(1000));
			AssertMenuOpen();
		}

		[Test]
		public void CanCloseMenuWithFlick()
		{
			AssertMenuClosed();
			app.Tap(ToggleButton);
			AssertMenuOpen();
			app.DragCoordinates(305, 50, 200, 50, TimeSpan.FromMilliseconds(800));
			AssertMenuClosed();
		}

		[Test]
		public void CanSwitchToContentViewAndBackToIntro()
		{
			Assert.Greater(app.Query(IntroTitle).Length, 0);
			app.Tap(ToggleButton);
			app.Tap(MenuContentButton);
			Assert.Greater(app.Query(ContentTitle).Length, 0);
			app.Tap(ToggleButton);
			app.Tap(MenuIntroButton);
			Assert.Greater(app.Query(IntroTitle).Length, 0);
		}

		private void AssertMenuOpen() {
			Assert.AreEqual(310, app.Query(ToggleButton).First().Rect.X);
		}

		private void AssertMenuClosed() {
			Assert.AreEqual(50, app.Query(ToggleButton).First().Rect.X);
		}
	}
}


text:
package models.manager.commands

import models.manager.commands.traits.SimpleCommand

/**
  * Created by rbrowning on 4/26/17.
  *
  * Sent from the endpoints to the manager, the manager will tell the player to stop it's current item
  */
case class StopPlayer() extends SimpleCommand


text:
#ifndef __COMMONS_H__
#define __COMMONS_H__

#ifdef ARDUINO

const unsigned long DEFAULT_TIME = 1420092000; // 06:00:00, 1/1/2015

/************************************************************************/
/*  ANALOG PIN DEFINITIONS                                              */
/************************************************************************/
#define PIN_A0 A0
#define PIN_A1 A1
#define PIN_A2 A2
#define PIN_A3 A3
#define PIN_A4_I2C_SDA A4
#define PIN_A5_I2C_SCL A5

/************************************************************************/
/*  DIGITAL PIN DEFINITIONS                                             */
/************************************************************************/

#define PIN0_RX 0
#define PIN1_TX 1
#define PIN2_INT0 2  //interrupt 0
#define PIN3_INT1 3  //interrupt 1
#define PIN4 4
#define PIN5 5
#define PIN6 6
#define PIN7 7
#define PIN8 8
#define PIN9_RF_CE 9
/** SPI CONNECTIONS **/
#define PIN10_CS 10  // Reserved for ChipSelect
/*
* Note that even if you don't use the hardware CS/SS pin,
* it must be left as an output or the SD library won't work.
*/
#define PIN11_MISO 11
#define PIN12_MOSI 12
#define PIN13_SCK 13
//LED_BUILTIN = 13

#define OFF false
#define ON  true

/************************************************************************/
/* Debugging Helpers                                                    */
/************************************************************************/

bool DEBUG = false;

void isDebugMode ( bool forceDebug )
{
	Serial.begin(19200);
	Serial.println(F("DEBUG MODE?"));
	//Wait for 5 seconds or until data is available on serial,
	//whichever occurs first.
	int test = 0;
	while( millis() < 5000 ) {
		test = Serial.read(); //We then clear the input buffer
		if (forceDebug) { test = forceDebug; }
		if ( test > 0 )
		{
			//If data is available, we enter here.
			Serial.print(F("received:  ") );
			Serial.println( test );
			//On timeout or availability of data, we come here.
			DEBUG = true; //Enable debug
			break;
		}
	} // end while

//	if ( DEBUG == false ) { Serial.println("Goodbye!"); Serial.end(); }
}

/*
What free_ram() is actually reporting
is the space between the heap and the stack.
it does not report any de-allocated memory
that is buried in the heap.
Buried heap space is not usable by the stack,
and may be fragmented enough that it is not
usable for many heap allocations either.
The space between the heap and the stack
is what you really need to monitor if you are
trying to avoid stack crashes.
*/

int freeRam () {
	extern int __heap_start, *__brkval;
	int v;
	return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}

/***********************************************************************
*
* Interrupt Service Routine (ISR)
*
* When writing an Interrupt Service Routine (ISR):
*** Keep it short
*** Don't use delay ()
*** Don't do serial prints
*** Make variables shared with the main code: volatile
*** Variables shared with main code may need to be protected by "critical sections"
*** Don't try to turn interrupts off or on
************************************************************************/

//void interrupted() {
// digitalWrite(PIN8, HIGH);
//}

void errorHandler ( uint8_t result )
{
	if ( DEBUG ) {
		switch ( result )
		{
			case 0: //success
			break;
			case 1: Serial.println(F("1 - Waiting for Start bit")); break;
			case 2: Serial.println(F("2 - slave in transmit mode")); break;
			case 3: Serial.println(F("3 - Sending to slave")); break;
			case 4: Serial.println(F("4 - Repeated Start")); break;
			case 5: Serial.println(F("5 - Slave in receiver mode")); break;
			case 6: Serial.println(F("6 - Receiving from slave")); break;
			case 7: Serial.println(F("7 - Stop bit")); break;
		}
	}
}

#else
#error This example is only for use on Arduino.
#endif // ARDUINO

#endif // __COMMONS_H__


text:
package taxii20

import (
	"github.com/mitchellh/mapstructure"

	"gopkg.in/tin.v0/model"
	plg "gopkg.in/tin.v0/plugin"
)

const (
	// DefaultMaxContentLength is 25 mebibytes
	DefaultMaxContentLength = 26214400
)

var (
	// ConfigData contains all config for TAXII 2.0 plugin
	ConfigData *Config
)

// Config represents TAXII 2.0 plugin structure
type Config struct {
	Title       string
	Description string
	Contact     string
	DefaultRoot string
	APIRoots    []model.APIRoot
}

// Intermediate config for mapstructure
type configRaw struct {
	Title       string                `mapstructure:"title"`
	Description string                `mapstructure:"description"`
	Contact     string                `mapstructure:"contact"`
	DefaultRoot string                `mapstructure:"default"`
	APIRoots    map[string]apiRootRaw `mapstructure:"api_roots"`
}
type apiRootRaw struct {
	Title            string                   `mapstructure:"title"`
	Description      string                   `mapstructure:"description"`
	MaxContentLength int64                    `mapstructure:"max_content_length"`
	AuthMethods      []string                 `mapstructure:"auth"`
	Collections      map[string]collectionRaw `mapstructure:"collections"`
}
type collectionRaw struct {
	Selector          string `mapstructure:"selector"`
	SelectorQueryLang string `mapstructure:"selector_query_lang"`
}

func parseTaxiiConfig() error {
	plg.ConfigMutex.Lock()
	defer plg.ConfigMutex.Unlock()

	taxiiConfig := plg.ConfigData.Plugins["taxii20"].(map[interface{}]interface{})
	ConfigData = &Config{}
	raw := &configRaw{}
	err := mapstructure.Decode(taxiiConfig, raw)
	if err != nil {
		return err
	}

	ConfigData.Title = raw.Title
	if ConfigData.Title == "" {
		ConfigData.Title = "TIN"
	}
	ConfigData.Description = raw.Description
	if ConfigData.Description == "" {
		ConfigData.Description = "TIN TAXII Server"
	}
	ConfigData.Contact = raw.Contact
	if ConfigData.Contact == "" {
		ConfigData.Contact = "https://github.com/go-tin/tin/issues"
	}
	ConfigData.DefaultRoot = raw.DefaultRoot
	ConfigData.APIRoots = make([]model.APIRoot, 0)
	for name, root := range raw.APIRoots {
		apiRoot := model.APIRoot{Name: name}
		apiRoot.Title = root.Title
		apiRoot.Description = root.Description
		if root.MaxContentLength != 0 {
			apiRoot.MaxContentLength = DefaultMaxContentLength
		} else {
			apiRoot.MaxContentLength = root.MaxContentLength
		}
		apiRoot.AuthMethods = root.AuthMethods
		ConfigData.APIRoots = append(ConfigData.APIRoots, apiRoot)
	}

	return nil
}


text:
import * as assert from 'assert';
import { Position, window } from 'vscode';
import { getCurrentParagraphBeginning, getCurrentParagraphEnd } from '../src/textobject/paragraph';
import { WordType } from '../src/textobject/word';
import { TextEditor } from './../src/textEditor';
import { cleanUpWorkspace, setupWorkspace } from './testUtils';

suite('basic motion', () => {
  const text: string[] = ['mary had', 'a', 'little lamb', ' whose fleece was '];

  suiteSetup(async () => {
    await setupWorkspace();
    await TextEditor.insert(window.activeTextEditor!, text.join('\n'));
  });

  suiteTeardown(cleanUpWorkspace);

  test('char right: should move one column right', () => {
    const position = new Position(0, 0);
    assert.strictEqual(position.line, 0);
    assert.strictEqual(position.character, 0);

    const next = position.getRight();
    assert.strictEqual(next.line, 0);
    assert.strictEqual(next.character, 1);
  });

  test('char right', () => {
    const motion = new Position(0, 8).getRight();

    assert.strictEqual(motion.line, 0);
    assert.strictEqual(motion.character, 8);
  });

  test('char left: should move cursor one column left', () => {
    let position = new Position(0, 5);
    assert.strictEqual(position.line, 0);
    assert.strictEqual(position.character, 5);

    position = position.getLeft();
    assert.strictEqual(position.line, 0);
    assert.strictEqual(position.character, 4);
  });

  test('char left: left-most column should stay at the same location', () => {
    let motion = new Position(0, 0);
    assert.strictEqual(motion.line, 0);
    assert.strictEqual(motion.character, 0);

    motion = motion.getLeft();
    assert.strictEqual(motion.line, 0);
    assert.strictEqual(motion.character, 0);
  });

  test('line down: should move cursor one line down', () => {
    let motion = new Position(1, 0);
    assert.strictEqual(motion.line, 1);
    assert.strictEqual(motion.character, 0);

    motion = motion.getDown();
    assert.strictEqual(motion.line, 2);
    assert.strictEqual(motion.character, 0);
  });

  test('line down: bottom-most line should stay at the same location', () => {
    let motion = new Position(3, 0);
    assert.strictEqual(motion.line, 3);
    assert.strictEqual(motion.character, 0);

    motion = motion.getDown();
    assert.strictEqual(motion.line, 3);
    assert.strictEqual(motion.character, 0);
  });

  suite('line up', () => {
    test('should move cursor one line up', () => {
      let position = new Position(1, 0);
      assert.strictEqual(position.line, 1);
      assert.strictEqual(position.character, 0);

      position = position.getUp();
      assert.strictEqual(position.line, 0);
      assert.strictEqual(position.character, 0);
    });

    test('top-most line should stay at the same location', () => {
      let motion = new Position(0, 1);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 1);

      motion = motion.getUp(0);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 1);
    });
  });

  test('line begin', () => {
    const motion = new Position(0, 3).getLineBegin();
    assert.strictEqual(motion.line, 0);
    assert.strictEqual(motion.character, 0);
  });

  test('line end', () => {
    let motion = new Position(0, 0).getLineEnd();
    assert.strictEqual(motion.line, 0);
    assert.strictEqual(motion.character, text[0].length);

    motion = new Position(2, 0).getLineEnd();
    assert.strictEqual(motion.line, 2);
    assert.strictEqual(motion.character, text[2].length);
  });

  test('document begin', () => {
    const motion = TextEditor.getDocumentBegin();
    assert.strictEqual(motion.line, 0);
    assert.strictEqual(motion.character, 0);
  });

  test('document end', () => {
    const motion = TextEditor.getDocumentEnd(window.activeTextEditor!.document);
    assert.strictEqual(motion.line, text.length - 1);
    assert.strictEqual(motion.character, text[text.length - 1].length);
  });

  test('line begin cursor on first non-blank character', () => {
    const motion = TextEditor.getFirstNonWhitespaceCharOnLine(window.activeTextEditor!.document, 0);
    assert.strictEqual(motion.line, 0);
    assert.strictEqual(motion.character, 0);
  });

  test('last line begin cursor on first non-blank character', () => {
    const motion = TextEditor.getFirstNonWhitespaceCharOnLine(window.activeTextEditor!.document, 3);
    assert.strictEqual(motion.line, 3);
    assert.strictEqual(motion.character, 1);
  });
});

suite('word motion', () => {
  const text: string[] = [
    'if (true) {',
    '  return true;',
    '} else {',
    '',
    '  return false;',
    '  ',
    '} // endif',
  ];

  suiteSetup(() => {
    return setupWorkspace().then(() => {
      return TextEditor.insert(window.activeTextEditor!, text.join('\n'));
    });
  });

  suiteTeardown(cleanUpWorkspace);

  suite('word right', () => {
    test('move to word right', () => {
      const motion = new Position(0, 3).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 4);
    });

    test('last word should move to next line', () => {
      const motion = new Position(0, 10).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 1);
      assert.strictEqual(motion.character, 2);
    });

    test('last word should move to next line stops on empty line', () => {
      const motion = new Position(2, 7).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 3);
      assert.strictEqual(motion.character, 0);
    });

    test('last word should move to next line skips whitespace only line', () => {
      const motion = new Position(4, 14).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 6);
      assert.strictEqual(motion.character, 0);
    });

    test('last word on last line should go to end of document (special case!)', () => {
      const motion = new Position(6, 6).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 6);
      assert.strictEqual(motion.character, 10);
    });
  });

  suite('word left', () => {
    test('move cursor word left across spaces', () => {
      const motion = new Position(0, 3).prevWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 0);
    });

    test('move cursor word left within word', () => {
      const motion = new Position(0, 5).prevWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 4);
    });

    test('first word should move to previous line, beginning of last word', () => {
      const motion = new Position(1, 2).prevWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 10);
    });

    test('first word should move to previous line, stops on empty line', () => {
      const motion = new Position(4, 2).prevWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 3);
      assert.strictEqual(motion.character, 0);
    });

    test('first word should move to previous line, skips whitespace only line', () => {
      const motion = new Position(6, 0).prevWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 4);
      assert.strictEqual(motion.character, 14);
    });
  });

  suite('WORD right', () => {
    test('move to WORD right', () => {
      const motion = new Position(0, 3).nextWordStart(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 10);
    });

    test('last WORD should move to next line', () => {
      const motion = new Position(1, 10).nextWordStart(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 2);
      assert.strictEqual(motion.character, 0);
    });

    test('last WORD should move to next line stops on empty line', () => {
      const motion = new Position(2, 7).nextWordStart(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 3);
      assert.strictEqual(motion.character, 0);
    });

    test('last WORD should move to next line skips whitespace only line', () => {
      const motion = new Position(4, 12).nextWordStart(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 6);
      assert.strictEqual(motion.character, 0);
    });
  });

  suite('WORD left', () => {
    test('move cursor WORD left across spaces', () => {
      const motion = new Position(0, 3).prevWordStart(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 0);
    });

    test('move cursor WORD left within WORD', () => {
      const motion = new Position(0, 5).prevWordStart(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 3);
    });

    test('first WORD should move to previous line, beginning of last WORD', () => {
      const motion = new Position(2, 0).prevWordStart(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 1);
      assert.strictEqual(motion.character, 9);
    });

    test('first WORD should move to previous line, stops on empty line', () => {
      const motion = new Position(4, 2).prevWordStart(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 3);
      assert.strictEqual(motion.character, 0);
    });

    test('first WORD should move to previous line, skips whitespace only line', () => {
      const motion = new Position(6, 0).prevWordStart(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 4);
      assert.strictEqual(motion.character, 9);
    });
  });

  suite('end of word right', () => {
    test('move to end of current word right', () => {
      const motion = new Position(0, 4).nextWordEnd(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 7);
    });

    test('move to end of next word right', () => {
      const motion = new Position(0, 7).nextWordEnd(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 8);
    });

    test('end of last word should move to next line', () => {
      const motion = new Position(0, 10).nextWordEnd(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 1);
      assert.strictEqual(motion.character, 7);
    });

    test('end of last word should move to next line skips empty line', () => {
      const motion = new Position(2, 7).nextWordEnd(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 4);
      assert.strictEqual(motion.character, 7);
    });

    test('end of last word should move to next line skips whitespace only line', () => {
      const motion = new Position(4, 14).nextWordEnd(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 6);
      assert.strictEqual(motion.character, 0);
    });
  });

  suite('end of WORD right', () => {
    test('move to end of current WORD right', () => {
      const motion = new Position(0, 4).nextWordEnd(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 8);
    });

    test('move to end of next WORD right', () => {
      const motion = new Position(0, 8).nextWordEnd(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 10);
    });

    test('end of last WORD should move to next line', () => {
      const motion = new Position(0, 10).nextWordEnd(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 1);
      assert.strictEqual(motion.character, 7);
    });

    test('end of last WORD should move to next line skips empty line', () => {
      const motion = new Position(2, 7).nextWordEnd(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 4);
      assert.strictEqual(motion.character, 7);
    });

    test('end of last WORD should move to next line skips whitespace only line', () => {
      const motion = new Position(4, 14).nextWordEnd(window.activeTextEditor!.document, {
        wordType: WordType.Big,
      });
      assert.strictEqual(motion.line, 6);
      assert.strictEqual(motion.character, 0);
    });
  });

  test('line begin cursor on first non-blank character', () => {
    const motion = TextEditor.getFirstNonWhitespaceCharOnLine(window.activeTextEditor!.document, 4);
    assert.strictEqual(motion.line, 4);
    assert.strictEqual(motion.character, 2);
  });

  test('last line begin cursor on first non-blank character', () => {
    const motion = TextEditor.getFirstNonWhitespaceCharOnLine(window.activeTextEditor!.document, 6);
    assert.strictEqual(motion.line, 6);
    assert.strictEqual(motion.character, 0);
  });
});

suite('unicode word motion', () => {
  const text: string[] = [
    '漢字ひらがなカタカナalphabets、いろいろな文字。',
    'Καλημέρα κόσμε',
    'Die früh sich einst dem trüben Blick gezeigt.',
    'Được tiếp đãi ân cần',
    '100£and100$and100¥#♯x',
  ];

  suiteSetup(() => {
    return setupWorkspace().then(() => {
      return TextEditor.insert(window.activeTextEditor!, text.join('\n'));
    });
  });

  suiteTeardown(cleanUpWorkspace);

  suite('word right', () => {
    test('move cursor word right stops at different kind of character (ideograph -> hiragana)', () => {
      const motion = new Position(0, 0).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 2);
    });

    test('move cursor word right stops at different kind of character (katakana -> ascii)', () => {
      const motion = new Position(0, 7).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 10);
    });

    test('move cursor word right stops at different kind of chararacter (ascii -> punctuation)', () => {
      const motion = new Position(0, 10).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 19);
    });

    test('move cursor word right on non-ascii text', () => {
      const motion = new Position(1, 0).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 1);
      assert.strictEqual(motion.character, 9);
    });

    test('move cursor word right recognizes a latin string which has diacritics as a single word', () => {
      const motion = new Position(2, 4).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 2);
      assert.strictEqual(motion.character, 9);
    });

    test('move cursor word right recognizes a latin-1 symbol as punctuation', () => {
      let motion = new Position(4, 3).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 4);
      assert.strictEqual(motion.character, 4);

      motion = motion.nextWordStart(window.activeTextEditor!.document); // issue #3680
      assert.strictEqual(motion.line, 4);
      assert.strictEqual(motion.character, 10);
    });

    test('move cursor word right recognizes a sequence of latin-1 symbols and other symbols as a word', () => {
      const motion = new Position(4, 17).nextWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 4);
      assert.strictEqual(motion.character, 20);
    });
  });

  suite('word left', () => {
    test('move cursor word left across the different char kind', () => {
      const motion = new Position(0, 2).prevWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 0);
    });

    test('move cursor word left within the same char kind', () => {
      const motion = new Position(0, 5).prevWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 2);
    });

    test('move cursor word left across spaces on non-ascii text', () => {
      const motion = new Position(1, 9).prevWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 1);
      assert.strictEqual(motion.character, 0);
    });

    test('move cursor word left within word on non-ascii text', () => {
      const motion = new Position(1, 11).prevWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 1);
      assert.strictEqual(motion.character, 9);
    });

    test('move cursor word left recognizes a latin string which has diacritics as a single word', () => {
      const motion = new Position(3, 10).prevWordStart(window.activeTextEditor!.document);
      assert.strictEqual(motion.line, 3);
      assert.strictEqual(motion.character, 5);
    });
  });
});

suite('sentence motion', () => {
  const text: string[] = [
    'This text has many sections in it. What do you think?',
    '',
    'A paragraph boundary is also a sentence boundry, see',
    '',
    'Weird things happen when there is no appropriate sentence ending',
    '',
    'Next line is just whitespace',
    '   ',
    'Wow!',
    'Another sentence inside one paragraph.',
  ];

  suiteSetup(() => {
    return setupWorkspace().then(() => {
      return TextEditor.insert(window.activeTextEditor!, text.join('\n'));
    });
  });

  suiteTeardown(cleanUpWorkspace);

  suite('sentence forward', () => {
    test('next concrete sentence', () => {
      const motion = new Position(0, 0).getSentenceBegin({ forward: true });
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 35);
    });

    test('next sentence when cursor is at the end of previous paragraph', () => {
      const motion = new Position(3, 0).getSentenceBegin({ forward: true });
      assert.strictEqual(motion.line, 4);
      assert.strictEqual(motion.character, 0);
    });

    test('next sentence when paragraph contains a line of whilte spaces', () => {
      const motion = new Position(6, 2).getSentenceBegin({ forward: true });
      assert.strictEqual(motion.line, 9);
      assert.strictEqual(motion.character, 0);
    });
  });

  suite('sentence backward', () => {
    test('current sentence begin', () => {
      const motion = new Position(0, 37).getSentenceBegin({ forward: false });
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 35);
    });

    test('sentence forward when cursor is at the beginning of the second sentence', () => {
      const motion = new Position(0, 35).getSentenceBegin({ forward: false });
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 0);
    });

    test('current sentence begin with no concrete sentense inside', () => {
      const motion = new Position(3, 0).getSentenceBegin({ forward: false });
      assert.strictEqual(motion.line, 2);
      assert.strictEqual(motion.character, 0);
    });

    test("current sentence begin when it's not the same as current paragraph begin", () => {
      const motion = new Position(2, 0).getSentenceBegin({ forward: false });
      assert.strictEqual(motion.line, 1);
      assert.strictEqual(motion.character, 0);
    });

    test('current sentence begin when previous line ends with a concrete sentence', () => {
      const motion = new Position(9, 5).getSentenceBegin({ forward: false });
      assert.strictEqual(motion.line, 9);
      assert.strictEqual(motion.character, 0);
    });
  });
});

suite('paragraph motion', () => {
  const text: string[] = [
    'this text has', // 0
    '', // 1
    'many', // 2
    'paragraphs', // 3
    '', // 4
    '', // 5
    'in it.', // 6
    '', // 7
    'WOW', // 8
  ];

  suiteSetup(() => {
    return setupWorkspace().then(() => {
      return TextEditor.insert(window.activeTextEditor!, text.join('\n'));
    });
  });

  suiteTeardown(cleanUpWorkspace);

  suite('paragraph down', () => {
    test('move down normally', () => {
      const motion = getCurrentParagraphEnd(new Position(0, 0));
      assert.strictEqual(motion.line, 1);
      assert.strictEqual(motion.character, 0);
    });

    test('move down longer paragraph', () => {
      const motion = getCurrentParagraphEnd(new Position(2, 0));
      assert.strictEqual(motion.line, 4);
      assert.strictEqual(motion.character, 0);
    });

    test('move down starting inside empty line', () => {
      const motion = getCurrentParagraphEnd(new Position(4, 0));
      assert.strictEqual(motion.line, 7);
      assert.strictEqual(motion.character, 0);
    });

    test('paragraph at end of document', () => {
      const motion = getCurrentParagraphEnd(new Position(7, 0));
      assert.strictEqual(motion.line, 8);
      assert.strictEqual(motion.character, 3);
    });
  });

  suite('paragraph up', () => {
    test('move up short paragraph', () => {
      const motion = getCurrentParagraphBeginning(new Position(1, 0));
      assert.strictEqual(motion.line, 0);
      assert.strictEqual(motion.character, 0);
    });

    test('move up longer paragraph', () => {
      const motion = getCurrentParagraphBeginning(new Position(3, 0));
      assert.strictEqual(motion.line, 1);
      assert.strictEqual(motion.character, 0);
    });

    test('move up starting inside empty line', () => {
      const motion = getCurrentParagraphBeginning(new Position(5, 0));
      assert.strictEqual(motion.line, 1);
      assert.strictEqual(motion.character, 0);
    });
  });
});


text:
libxml_set_streams_context()
--SKIPIF--
<?php if (!extension_loaded('dom')) die('skip'); ?>
--FILE--
<?php

$ctxs = array(
	NULL,
	'bogus',
	123,
	new stdclass,
	array('a'),
	stream_context_create(),
	stream_context_create(array('file')),
	stream_context_create(array('file' => array('some_opt' => 'aaa')))
);

foreach ($ctxs as $ctx) {
	var_dump(libxml_set_streams_context($ctx));
	$dom = new DOMDocument();
	var_dump($dom->load(dirname(__FILE__).'/test.xml'));
}

echo "Done\n";

?>
--EXPECTF--
Warning: stream_context_create(): options should have the form ["wrappername"]["optionname"] = $value in %s004.php on line %d

Warning: libxml_set_streams_context() expects parameter 1 to be resource, null given in %s004.php on line %d
NULL
bool(true)

Warning: libxml_set_streams_context() expects parameter 1 to be resource, string given in %s004.php on line %d
NULL
bool(true)

Warning: libxml_set_streams_context() expects parameter 1 to be resource, integer given in %s004.php on line %d
NULL
bool(true)

Warning: libxml_set_streams_context() expects parameter 1 to be resource, object given in %s004.php on line %d
NULL
bool(true)

Warning: libxml_set_streams_context() expects parameter 1 to be resource, array given in %s004.php on line %d
NULL
bool(true)
NULL
bool(true)
NULL
bool(true)
NULL
bool(true)
Done


text:
/*global jQuery*/
/*global fluid*/
/*global jqUnit*/

(function ($) {
    $(document).ready(function () {

        var GeometricManagerTests = new jqUnit.TestCase("GeometricManagerTests");

        function assertOrder(message, parentId, required) {
            var all = $("#" + parentId + " div");
            var str = "";
            for (var i = 0; i < all.length; ++ i) {
                var id = all[i].getAttribute("id");
                var c = id.charAt(id.length - 1);
                str += c;
            }
            jqUnit.assertEquals(message, required, str);
        }

        GeometricManagerTests.test("Original order", function() {
            var orders = $("#permuteTest .orderable");

            expect(2);
            assertOrder("Original order", "permuteTest",  "0123A4567B8");
            assertOrder("Original order", "permuteTest2", "abCc");
        });

        function selfPermuteTest(name, source, target, position, expected) {
            GeometricManagerTests.test(name, function () {
                var orders = $("#permuteTest .orderable");

                fluid.permuteDom(orders[source], orders[target], position, orders, orders);
                expect(1);
                assertOrder(name, "permuteTest", expected);
            });
        }

        function crossPermuteTest(name, source, target, position, expected1, expected2) {
            GeometricManagerTests.test(name, function () {
                var sourceElements = $("#permuteTest .orderable");
                var targetElements = $("#permuteTest2 .orderable");

                fluid.permuteDom(sourceElements[source], targetElements[target],
                       position, sourceElements, targetElements);
                expect(2);
                assertOrder(name, "permuteTest", expected1);
                assertOrder(name, "permuteTest2", expected2);
            });
        }

        // Original order:                                                   "0123A4567B8"
        selfPermuteTest("REPLACE right rend",  2, 8, fluid.position.REPLACE, "0134A5678B2");
        selfPermuteTest("REPLACE right",       2, 6, fluid.position.REPLACE, "0134A5627B8");
        selfPermuteTest("AFTER right",         2, 6, fluid.position.AFTER,   "0134A5627B8");
        selfPermuteTest("REPLACE left",        7, 2, fluid.position.REPLACE, "0172A3456B8");
        selfPermuteTest("BEFORE left",         7, 2, fluid.position.BEFORE,  "0172A3456B8");
        selfPermuteTest("REPLACE right rend",  2, 8, fluid.position.REPLACE, "0134A5678B2");
        selfPermuteTest("AFTER right rend",    2, 8, fluid.position.AFTER,   "0134A5678B2");
        selfPermuteTest("BEFORE right",        2, 6, fluid.position.BEFORE,  "0134A5267B8");
        selfPermuteTest("AFTER left",          7, 2, fluid.position.AFTER,   "0127A3456B8");
        selfPermuteTest("AFTER left shift",    7, 3, fluid.position.AFTER,   "01237A456B8"); // skip failure
        selfPermuteTest("BEFORE right shift",  2, 8, fluid.position.BEFORE,  "0134A567B28"); // skip failure
        selfPermuteTest("REPLACE right lend",  0, 6, fluid.position.REPLACE, "1234A5607B8");
        selfPermuteTest("REPLACE left lend",   6, 0, fluid.position.REPLACE, "6012A3457B8");
        selfPermuteTest("REPLACE right hop",   8, 7, fluid.position.REPLACE, "0123A4568B7");
        selfPermuteTest("REPLACE left hop",    7, 8, fluid.position.REPLACE, "0123A4568B7");
        selfPermuteTest("REPLACE left two",    0, 1, fluid.position.REPLACE, "1023A4567B8");
        selfPermuteTest("REPLACE right two",   1, 0, fluid.position.REPLACE, "1023A4567B8");
        selfPermuteTest("REPLACE left four",   4, 5, fluid.position.REPLACE, "0123A5467B8");

        // Original order:                                            "0123A4567B8", "abCc"
        crossPermuteTest("1->2 BEFORE", 1, 2, fluid.position.BEFORE,  "0234A5678B",  "abC1c");
        crossPermuteTest("1->1 BEFORE", 1, 1, fluid.position.BEFORE,  "0234A5678B",  "a1Cbc");
        crossPermuteTest("1->1 AFTER",  1, 1, fluid.position.AFTER,   "0234A5678B",  "ab1Cc");
        crossPermuteTest("0->0 BEFORE", 0, 0, fluid.position.BEFORE,  "1234A5678B",  "0aCbc");
        crossPermuteTest("0->2 AFTER",  0, 2, fluid.position.AFTER,   "1234A5678B",  "abCc0");

        GeometricManagerTests.test("minPointRectangle", function() {

          expect(6);

          var rect = {left: -1, right: 5, top: -1, bottom : 1};

          jqUnit.assertEquals("Inside", 0,
             fluid.geom.minPointRectangle(0, 0, rect));

          jqUnit.assertEquals("Inside", 0,
             fluid.geom.minPointRectangle(0.5, 0.5, rect));

          jqUnit.assertEquals("InsideEdge", 0,
             fluid.geom.minPointRectangle(0, -1, rect));

          jqUnit.assertEquals("LTDist", 2,
             fluid.geom.minPointRectangle(-2, -2, rect));

          jqUnit.assertEquals("TDist", 4,
             fluid.geom.minPointRectangle(0, -3, rect));

          jqUnit.assertEquals("RDist", 25,
             fluid.geom.minPointRectangle(10, 0, rect));

        });

      GeometricManagerTests.test("minRectRect", function() {

          expect(6);

          var rect1 = {left: -1, top: -1, right: 5, bottom: 1};
          var rect2 = {left: 3, top: 2, right: 10, bottom: 3};
          var rect3 = {left: 7, top: 2, right: 10, bottom: 5};

          jqUnit.assertEquals("Dist12", 1, fluid.geom.minRectRect(rect1, rect2));
          jqUnit.assertEquals("Dist12R", 1, fluid.geom.minRectRect(rect2, rect1));

          jqUnit.assertEquals("Dist13", 5, fluid.geom.minRectRect(rect1, rect3));
          jqUnit.assertEquals("Dist13R", 5, fluid.geom.minRectRect(rect3, rect1));

          jqUnit.assertEquals("Dist23", 0, fluid.geom.minRectRect(rect2, rect3));
          jqUnit.assertEquals("Dist23R", 0, fluid.geom.minRectRect(rect3, rect2));

        });

      GeometricManagerTests.test("projectFrom", function() {
          // column 1, 3x3 squares spaced by 1, middle skew 1 to the right
          var rects = [
              {left: 1, top: 1, right: 4, bottom: 4},
              {left: 2, top: 5, right: 5, bottom: 8},
              {left: 1, top: 9, right: 4, bottom: 12},
          // column 2, same dimensions but offset down by 1
              {left: 6, top: 2, right: 9, bottom: 5},
              {left: 6, top: 6, right: 9, bottom: 9}];

          var elems = fluid.transform(rects, function(rect, i) {
             return {rect: rect, index: i}
          });

          function assertProject(name, fromIndex, direction, toIndex, wrapped) {
              var proj = fluid.geom.projectFrom(rects[fromIndex], fluid.direction[direction], elems);
              jqUnit.assertEquals(name + " index", toIndex, proj.cacheelem.index);
              jqUnit.assertEquals(name + " wrapped", wrapped, proj.wrapped);
          }
          expect(24);
          assertProject("Right0", 0, "RIGHT", 3, false);
          assertProject("Left3",  3, "LEFT",  0, false);
          assertProject("Right3", 3, "RIGHT", 0, true);
          assertProject("Left0",  0, "LEFT",  3, true);
          assertProject("Down0",  0, "DOWN",  1, false);
          assertProject("Up1",    1, "UP",    0, false);

          assertProject("Up0",    0, "UP",    2, true);
          assertProject("Down2",  2, "DOWN",  0, true);
          assertProject("Right2", 2, "RIGHT", 4, false);
          assertProject("Left4",  4, "LEFT",  1, false);
          assertProject("Left1",  1, "LEFT",  4, true);
          assertProject("Right4", 4, "RIGHT", 1, true);

      });
    });
})(jQuery);


text:
package f2j;

import java.lang.annotation.Annotation;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.stream.Collectors;

public class TypeServer {

  private final static Map<Class<?>, Class<?>> map = new HashMap<Class<?>, Class<?>>();
  private final static Map<String, Class<?>> arrayMap = new HashMap<String, Class<?>>();

  static {
    map.put(boolean.class, Boolean.class);
    map.put(byte.class, Byte.class);
    map.put(short.class, Short.class);
    map.put(char.class, Character.class);
    map.put(int.class, Integer.class);
    map.put(long.class, Long.class);
    map.put(float.class, Float.class);
    map.put(double.class, Double.class);
    map.put(void.class, Void.class);
  }

  static {
    arrayMap.put("char[]", char[].class);
    arrayMap.put("int[]", int[].class);
    arrayMap.put("byte[]", byte[].class);
    arrayMap.put("boolean[]", boolean[].class);
    arrayMap.put("long[]", long[].class);
    arrayMap.put("double[]", double[].class);
  }

  public static void main(String[] args) {
    Scanner inp = new Scanner(System.in);
    while (true) {
      if (!inp.hasNextLine()) continue;
      String line = inp.nextLine();
      String[] words = line.split(" ");
      Object result = false;
      switch (words[0]) {
      case "qType":
        result = queryType(words[1]);
        break;
      case "qConstructor":
        result = queryNew(words[1], Arrays.copyOfRange(words, 2, words.length));
        break;
      case "qMethod":
        result = queryMethod(words[1], words[2], Arrays.copyOfRange(words, 3, words.length), false);
        break;
      case "qStaticMethod":
        result = queryMethod(words[1], words[2], Arrays.copyOfRange(words, 3, words.length), true);
        break;
      case "qField":
        result = queryField(words[1], words[2], false);
        break;
      case "qStaticField":
        result = queryField(words[1], words[2], true);
        break;
      case "qModuleInfo":
        result = queryModule(words[1]);
        break;
      default:
        System.err.println("######## BAD QUERY ########");
        break;
      }
      System.out.println(result.toString());
    }
  }

  public static boolean queryType(String classFullName) {
    try {
      Class.forName(classFullName);
    } catch (ClassNotFoundException e) {
      return false;
    }
    return true;
  }

  public static boolean queryNew(String classFullName, String... constructorArgs) {
    try {
      Class<?> c = Class.forName(classFullName);
      Constructor<?>[] cList = c.getConstructors();
      Class<?>[] givenClasses = getClassArray(constructorArgs);

      for (Constructor cs : cList) {
        Class<?>[] actualClasses = cs.getParameterTypes();
        if (isArrayAssignableFrom(actualClasses, givenClasses))
          return true;
      }
      return false;
    } catch (Exception e) {
      return false;
    }
  }

  public static String queryMethod(String classFullName, String methodName, String[] methodArgs, boolean stat) {
    try {
      Class<?> c = Class.forName(classFullName);
      Class<?>[] givenClasses = getClassArray(methodArgs);
      Method[] mList = c.getMethods();

      List<Class<?>> ms = Arrays.stream(mList).filter(m -> {
          Class<?>[] actualClasses = m.getParameterTypes();
          return Modifier.isStatic(m.getModifiers()) == stat
          && m.getName().equals(methodName)
          && isArrayAssignableFrom(actualClasses, givenClasses);
        }).map(Method::getReturnType).sorted((m1, m2) -> m1.isAssignableFrom(m2) ? 1 : -1).collect(Collectors.toList());

      if (ms.size() == 0) return "$";
      else return classFix(ms.get(0)).getCanonicalName();
    } catch (Exception e) {
      return "$";
    }
  }

  public static String queryField(String classFullName, String fieldName, boolean stat) {
    try {
      Class<?> c = Class.forName(classFullName);
      Field f = c.getField(fieldName);
      if (Modifier.isStatic(f.getModifiers()) == stat)
        return classFix(f.getType()).getCanonicalName();
      else
        return "$";
    } catch (Exception e) {
      return "$";
    }
  }

  public static String queryModule(String moduleName) {
    try {
      StringBuffer result = new StringBuffer();
      ClassLoader classLoader = ClassLoader.getSystemClassLoader();
      Class m = classLoader.loadClass(moduleName + "$");
      Field[] fields = m.getDeclaredFields();
      for (Field field : fields) {
        ModuleFunction f = (ModuleFunction) field.getAnnotation(ModuleFunction.class);
        if (f != null) {
          result.append(f.name() + "$" + f.gname() + "$" + f.signature() + "$");
        }
      }
      return result.toString();
    } catch (Exception e) {
      return "$";
    }
  }

  private static Class<?>[] getClassArray(String[] names) throws ClassNotFoundException {

    Class<?>[] classes = new Class<?>[names.length];
    for (int i = 0; i < names.length; i++) {
      classes[i] = arrayMap.containsKey(names[i]) ? arrayMap.get(names[i]) : Class.forName(names[i]);
    }
    return classes;
  }

  // a -> super; b -> sub
  private static boolean isArrayAssignableFrom(Class<?>[] a, Class<?>[] b) {
    if (a.length != b.length) return false;
    for (int i = 0; i < a.length; i++)
      if (!classFix(a[i]).isAssignableFrom(classFix(b[i])))
        return false;
    return true;
  }

  // int -> Integer
  private static Class<?> classFix(Class<?> c) {
    return c.isPrimitive() ? map.get(c) : c;
  }

}


text:
from django.test import TestCase
from github_hook.models import Hook, hook_signal
from rest_framework import status
import json

class GithubHookTestCase(TestCase):
    def setUp(self):
        Hook.objects.create(
            name='test',
            user='user',
            repo='test',
            path='tests/test.sh',
        )
        self.github_payload = json.load(open('tests/github.json'))
        self.github_payload2 = json.load(open('tests/github2.json'))
        self.bitbucket_payload = json.load(open('tests/bitbucket.json'))

    def test_plain_post(self):
        """
        POST without payload or name is invalid
        """
        response = self.client.post('/')
        self.assertFalse(status.is_success(response.status_code))

    def test_named_post(self):
        """
        POST with valid name (url slug) should work.
        """
        self.reset_log()
        response = self.client.post('/test')
        self.assertTrue(status.is_success(response.status_code))
        self.check_log()

    def test_github_post(self):
        """
        POST with valid Github-style form payload should work.
        """
        self.reset_log()
        data = {"payload": json.dumps(self.github_payload)}
        response = self.client.post('/', data)
        self.assertTrue(status.is_success(response.status_code))
        self.check_log()

    def test_github_json(self):
        """
        POST with valid Github-style JSON payload should work.
        """
        self.reset_log()
        data = json.dumps(self.github_payload)
        response = self.client.post('/', data, content_type="application/json")
        self.assertTrue(status.is_success(response.status_code))
        self.check_log()

    def test_github_signal(self):
        """
        POST with valid payload but unknown user/repo should trigger signal.
        """
        def test_fn(sender, **kwargs):
            self.write_log()
        hook_signal.connect(test_fn)

        self.reset_log()
        data = json.dumps(self.github_payload2)
        response = self.client.post('/', data, content_type="application/json")
        self.assertTrue(status.is_success(response.status_code))
        self.check_log()

    def test_bitbucket_post(self):
        """
        POST with valid Bitbucket-style form payload should work.
        """
        self.reset_log()
        data = {"payload": json.dumps(self.bitbucket_payload)}
        response = self.client.post('/', data)
        self.assertTrue(status.is_success(response.status_code))
        self.check_log()

    def test_get(self):
        """
        GET should not work.
        """
        response = self.client.get('/')
        self.assertFalse(status.is_success(response.status_code))
        response = self.client.get('/test')
        self.assertFalse(status.is_success(response.status_code))

    def reset_log(self):
        self.write_log("")

    def write_log(self, value="Hello"):
        f = open('tests/test.log', 'w')
        f.write(value)
        f.close()

    def check_log(self, value="Hello"):
        f = open('tests/test.log')
        data = f.read()
        f.close()
        self.assertEqual(data, value)


text:
package com.helger.as4.model.pmode;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import com.helger.as4.model.EMEP;
import com.helger.as4.model.EMEPBinding;
import com.helger.as4.model.pmode.leg.PModeLeg;
import com.helger.commons.annotation.Nonempty;
import com.helger.commons.equals.EqualsHelper;
import com.helger.commons.string.StringHelper;
import com.helger.tenancy.IBusinessObject;

/**
 * Base read-only interface for a single {@link PMode}.
 *
 * @author Philip Helger
 */
public interface IPMode extends IBusinessObject
{
  @Nullable
  PModeParty getInitiator ();

  default boolean hasInitiator ()
  {
    return getInitiator () != null;
  }

  @Nullable
  default String getInitiatorID ()
  {
    final PModeParty aParty = getInitiator ();
    return aParty == null ? null : aParty.getID ();
  }

  default boolean hasInitiatorID (@Nullable final String sID)
  {
    return EqualsHelper.equals (sID, getInitiatorID ());
  }

  @Nullable
  PModeParty getResponder ();

  default boolean hasResponder ()
  {
    return getResponder () != null;
  }

  @Nullable
  default String getResponderID ()
  {
    final PModeParty aParty = getResponder ();
    return aParty == null ? null : aParty.getID ();
  }

  default boolean hasResponderID (@Nullable final String sID)
  {
    return EqualsHelper.equals (sID, getResponderID ());
  }

  @Nullable
  String getAgreement ();

  default boolean hasAgreement ()
  {
    return StringHelper.hasText (getAgreement ());
  }

  @Nonnull
  EMEP getMEP ();

  @Nonnull
  @Nonempty
  default String getMEPID ()
  {
    return getMEP ().getID ();
  }

  @Nonnull
  EMEPBinding getMEPBinding ();

  @Nonnull
  @Nonempty
  default String getMEPBindingID ()
  {
    return getMEPBinding ().getID ();
  }

  @Nullable
  PModeLeg getLeg1 ();

  default boolean hasLeg1 ()
  {
    return getLeg1 () != null;
  }

  @Nullable
  PModeLeg getLeg2 ();

  default boolean hasLeg2 ()
  {
    return getLeg2 () != null;
  }

  @Nullable
  PModePayloadService getPayloadService ();

  default boolean hasPayloadService ()
  {
    return getPayloadService () != null;
  }

  @Nullable
  PModeReceptionAwareness getReceptionAwareness ();

  default boolean hasReceptionAwareness ()
  {
    return getReceptionAwareness () != null;
  }
}


text:
import struct
import socket
import sys

ERROR = -1

# Encoding structure: CLASS(bit 7,8)+PC(bit 5)+Tag (bit 0-4)

dict_class={'UNIVERSAL':0x00,
            'APPLICATION':0x40,
            'CONTEXT_SPECIFIC':0x80,
            'PRIVATE':0xC0}

dict_pc={'PRIMITIVE':0,
         'CONSTRUCTED':0x20}

dict_tag={'EOC':0,
          'BOOLEAN':1,
          'INTEGER':2,
          'BIT_STRING':3,
          'OCTET_STRING':4,
          'NULL':5,
          'OBJECT_IDENTIFIER':6,
          'OBJECT_DESCRIPTOR':7,
          'EXTERNAL':8,
          'FLOAT':9,
          'ENUMERATED':10,
          'EMBEDDED':11,
          'UTF8':12,
          'RELATIVE_OID':13,
          'SEQUENCE':16,
          'SET':17,
          'NUMERIC_STRING':18,
          'PRINTABLE_STRING':19,
          'T61STRING':20,
          'VIDEOTEXT_STRING':21,
          'IA5STRING':22,
          'UTC_TIME':23,
          'GENERALIZED_TIME':24,
          'GRAPHIC_STRING':25,
          'VISIBLE_STRING':26,
          'GENERAL_STRING':27,
          'UNIVERSAL_STRING':28,
          'CHARACTER_STRING':29,
          'BMP_STRING':30,
          'LONG_FORM':31}

dict_RES={'success':0,
          'operationsError':1,
          'protocolError':2,
          'timeLimitExceeded':3,
          'sizeLimitExceeded':4,
          'compareFalse':5,
          'compareTrue':6,
          'authMethodNotSupported':7,
          'strongerAuthRequired':8,
          'referral':10,
          'adminLimitExceeded':11,
          'unavailableCriticalExtension':12,
          'confidentialityRequired':13,
          'saslBindInProgress':14,
          'noSuchAttribute':16,
          'undefinedAttributeType':17,
          'inappropriateMatching':18,
          'constraintViolation':19,
          'attributeOrValueExists':20,
          'invalidAttributeSyntax':21,
          'noSuchObject':32,
          'aliasProblem':33,
          'invalidDNSyntax':34,
          'aliasDereferencingProblem':36,
          'inappropriateAuthentication':48,
          'invalidCredentials':49,
          'insufficientAccessRights':50,
          'busy':51,
          'unavailable':52,
          'unavailable':52,
          'unwillingToPerform':53,
          'loopDetect':54,
          'namingViolation':64,
          'objectClassViolation':65,
          'notAllowedOnNonLeaf':66,
          'notAllowedOnRDN':67,
          'entryAlreadyExists':68,
          'objectClassModsProhibited':69,
          'affectsMultipleDSAs':71,
          'other':80 }

dict_APP= {'bindRequest': 0,
           'bindResponse':1,
           'unbindRequest':2,
           'searchRequest':3,
           'searchResultEntry':4,
           'searchResultDone':5,
           'modifyRequest':6,
           'modifyResponse':7,
           'addRequest':8,
           'addResponse':9,
           'delRequest':10,
           'delResponse':11,
           'modifyDNRequest':12,
           'modifyDNResponse':13,
           'compareRequest':15,
           'compareResponse':16,
           'abandonRequest':17,
           'extendedRequest':18,
           'extendedResponse':19,
           'intermediateResponse':20 }

class bindReq:
    def __init__(self):
        self.messageId=0
        self.code=0
        self.version=3
        self.name=""
        self.authentication=""

class LDAPResult:
    def __init__(self):
        self.messageId=0
        self.code=0
        self.result=0
        self.matchedDN=""
        self.errorMSG=""

class searchReq:
    def __init__(self):
        self.messageId=0
        self.code=0
        self.objectName=0
        self.scope=3
        self.derefAliases=0
        self.sizeLimit=1
        self.timeLimit=0
        self.typesOnly=False
        self.filter=[]

class searchRes:
    def __init__(self):
        self.messageId=0
        self.code=0
        self.objectName=""
        self.attributes=[]

class modifyReq:
    def __init__(self):
        self.messageId=0
        self.code=0
        self.objectName=""
        self.operation=[]
        self.modification=[]
        self.controls=[]

class addReq:
    def __init__(self):
        self.messageId=0
        self.code=0
        self.objectName=""
        self.attributes=""

class delReq:
    def __init__(self):
        self.messageId=0
        self.code=0
        self.objectName=""

#-----------------------------------------------------------------------------
# From RFC:
#- Only the definite form of length encoding is used.
#- OCTET STRING values are encoded in the primitive form only.
#- If the value of a BOOLEAN type is true, the encoding of the value octet is
#  set to hex "FF".
#- If a value of a type is its default value, it is absent. Only some BOOLEAN
#  and INTEGER types have default values
#- These restrictions do not apply to ASN.1 types encapsulated inside of
#  OCTET STRING values, such as attribute values, unless otherwise stated.

#-----------------------------------------------------------------------------
#Encoding section
#-----------------------------------------------------------------------------

# Pack according to ASN.1  (Abstract Syntax Notation One)
# Basic Encoding Rules to get identifier from Class(cls), Variable-Type(pc) and Data-Type (tag)
# see dict_class, dict_pc, dict_tag for values
def BERencode(cls,pc,tag):
    enc=cls+pc+tag
    return "%02X"%int(enc)

# Encode <value> as int with <op> identifier
# Reduce len if possible
def encodeInt(op,value):
    ilen=4
    r=struct.pack("!I",int(value)).encode("hex")
    while r[:2]=='00':
        r=r[2:]
        ilen-=1
        if ilen==1:
            break
    ret=op+'%02X'%ilen+r
    return ret

# Encode <value> as string with <op> identifier
def encodeStr(op,value):
    ret=op
    if len(value)<128:
        ret=ret+"%02X"%len(value)
    else:
        ret=ret+"82"+"%04X"%len(value)
    ret=ret+value.encode("hex")
    return ret

# Encode Value
def encodeValue(op,value):
    cls,pc,tag=BERdecode(op.decode("hex"))
    if tag in [1,2,10]:
        # Encode integer
        return encodeInt(op,value)
    else:
        return encodeStr(op,value)

# Encode key=value pair (everything is as string from LDIF)
def encodeKeyValue(key,value):
    k=encodeStr('04',key).decode('hex')
    if isinstance(value,list):
        v=''
        for vv in value:
            v=v+encodeStr('04',vv).decode('hex')
    else:
        v=encodeStr('04',value).decode('hex')
    ret=encodeStr('30',k+encodeStr('31',v).decode('hex'))
    return ret

#-----------------------------------------------------------------------------
#Decoding section
#-----------------------------------------------------------------------------

# Decode according to ASN.1
def BERdecode(byte):
    cls=ord(byte)>>6
    pc=(ord(byte)>>5)&1
    tag=ord(byte)&0x1F
    return cls<<6,pc<<5,tag

# Decode Integer value
def decodeToInt(msg):
    while len(msg)<8:
        msg="00"+msg
    ret=struct.unpack("!I",msg.decode("hex"))[0]
    return ret

# Decode msg header of LDAP message till msg specific stuff
def decodeHDR(msg):
    # Remove main envelope #30
    op,msg,x=chop_BER(msg)
    # get msgId
    op,msgId,msg=chop_BER(msg)
    #get appId
    appId,msg,x=chop_BER(msg)
    return msgId,appId,msg,x

# For tuple (t) decode value (default decoding method is as string)
def decodeValue(t):
    if isinstance(t,tuple):
        (op,value)=t
    else:
        return ''
    cls,pc,tag=BERdecode(op.decode("hex"))
    if tag in [1,2,10]:
        # Decode Integer
        return decodeToInt(value)
    else:
        return value.decode("hex")

# Decode application-specific attributes (hex message-undecoded) into tuples
def decodeParams(msg):
    ret=[]
    while msg!='':
        #print "I",msg
        op,value,msg=chop_BER(msg)
        cls,pc,tag=BERdecode(op.decode("hex"))
        #print "D",op,value,msg
        if pc==0:   #PRIMITIVE
            ret.append((op,value))
        else:
            ret.append(decodeParams(value))
        #print "R",ret
    return ret

# Decode key=[multiple values] from list
def decodeList(list):
    vRet=''
    #print "DL",list
    if len(list)==0:
        return ERROR
    key=decodeValue(list[0])
    for v in list[1]:
        if vRet=='':
            vRet=decodeValue(v)
        else:
            vRet+=','+decodeValue(v)
    return key+'='+str(vRet)

# Decode to proper object (match option to attribute)
def decodeFinal(msgId,appId,rest,unknown):
    cls,pc,tag=BERdecode(appId.decode("hex"))
    if tag==0:  # bindReq
        return decode_bindReq(msgId,appId,rest)
    if tag==1:  # bindRes
        return decode_bindRes(msgId,appId,rest)
    if tag==2:  # unbindReq
        return decode_unbindReq(msgId,appId,rest)
    if tag==3:  # searchReq
        return decode_searchReq(msgId,appId,rest)
    if tag==4:  # searchResEntry
        return decode_searchResEntry(msgId,appId,rest)
    if tag in [5,7,9,11]:  # generic LDAP response
        return decode_LDAPResult(msgId,appId,rest)
    if tag==6:  # modifyReq
        return decode_modifyReq(msgId,appId,rest,unknown)
    if tag==8:  # addReq
        return decode_addReq(msgId,appId,rest,unknown)
    if tag==10:  # deleteReq
        return decode_deleteReq(msgId,appId,rest,unknown)
    dbg="Don't know how to process AppId",tag
    bailOut(dbg)

def decode_bindReq(msgId,appId,rest):
    L=bindReq()
    L.messageId=msgId
    L.code=appId
    #split options
    list=decodeParams(rest)
    # And place them into matching variables
    L.version=decodeValue(list.pop(0))
    L.name=decodeValue(list.pop(0))
    L.authentication=decodeValue(list.pop(0))
    return L

def decode_bindRes(msgId,appId,rest):
    L=LDAPResult()
    L.messageId=msgId
    L.code=appId
    #split options
    list=decodeParams(rest)
    # And place them into matching variables
    L.result=decodeValue(list.pop(0))
    L.matchedDN=decodeValue(list.pop(0))
    L.errorMSG=decodeValue(list.pop(0))
    return L

def decode_unbindReq(msgId,appId,rest):
    L=LDAPResult()
    L.messageId=msgId
    L.code=appId
    return L

def decode_searchReq(msgId,appId,rest):
    L=searchReq()
    L.messageId=msgId
    L.code=appId
    #print "R",rest
    # get operation parameters
    op,value,msg=chop_BER(rest)
    L.objectName=decodeValue((op,value))
    op,value,msg=chop_BER(msg)
    L.scope=decodeValue((op,value))
    op,value,msg=chop_BER(msg)
    L.derefAliases=decodeValue((op,value))
    op,value,msg=chop_BER(msg)
    L.sizeLimit=decodeValue((op,value))
    op,value,msg=chop_BER(msg)
    L.timeLimit=decodeValue((op,value))
    op,value,msg=chop_BER(msg)
    L.typesOnly=decodeValue((op,value))
    # Filter is something I never used, so - not implemented/tested
    list=decodeParams(msg)
    #print "FL",len(list),list
    if isinstance(list[0],tuple):
        L.filter.append(decodeList(list))
    else:
        for l in list:
            r=decodeList(l)
            if r!=ERROR:
                L.filter.append(r)
    return L

def decode_searchResEntry(msgId,appId,rest):
    L=searchRes()
    L.messageId=msgId
    L.code=appId
    #get objectName
    op,value,msg=chop_BER(rest)
    L.objectName=decodeValue((op,value))
    #print "I",msg
    # get operation parameters
    op,msg,x=chop_BER(msg)
    #print "M",msg
    #print "X",x
    # Finally split options
    list=decodeParams(msg)
    #print "L",list
    # And place them into matching variables
    for l in list:
        L.attributes.append(decodeList(l))
    return L

def decode_LDAPResult(msgId,appId,rest):
    L=LDAPResult()
    L.messageId=msgId
    L.code=appId
    #split options
    list=decodeParams(rest)
    # And place them into matching variables
    L.result=decodeValue(list.pop(0))
    L.matchedDN=decodeValue(list.pop(0))
    L.errorMSG=decodeValue(list.pop(0))
    return L

def decode_modifyReq(msgId,appId,rest,unknown):
    L=modifyReq()
    L.messageId=msgId
    L.code=appId
    #get objectName
    op,op,msg=chop_BER(rest)
    L.objectName=op.decode("hex")
    # get operation parameters
    op,msg,x=chop_BER(msg)
    # Finally split options
    list=decodeParams(msg)
    #print "L",list
    # And place them into matching variables
    for l in list:
        op=decodeValue(l.pop(0))
        L.operation.append(op)
        L.modification.append(decodeList(l.pop(0)))
    # I have no idea if this controls works as it should
    if len(unknown)>0:
        list=decodeParams(unknown)
        #print "CL",list
        for l in list[0]:
            L.controls.append(decodeValue(l.pop(0)))
    return L

def decode_addReq(msgId,appId,rest,unknown):
    L=addReq()
    L.messageId=msgId
    L.code=appId
    #get objectName
    op,op,msg=chop_BER(rest)
    L.objectName=op.decode("hex")
    # get operation parameters
    op,msg,x=chop_BER(msg)
    # Finally split options
    list=decodeParams(msg)
    print "L",list
    # And place them into matching variables
    return L

def decode_deleteReq(msgId,appId,rest,unknown):
    L=searchReq()
    L.messageId=msgId
    L.code=appId
    #get objectName
    op,op,msg=chop_BER(rest)
    L.objectName=op.decode("hex")
    # get operation parameters
    op,msg,x=chop_BER(msg)
    # Finally split options
    list=decodeParams(msg)
    print "L",list
    return L

#-----------------------------------------------------------------------------
#Misc section
#-----------------------------------------------------------------------------

# Calculate object len (currently supports up to 64K)
def calc_len(len):
    if len<=127:
        #short form
        ret="%02X"%int(len)
    else:
        #long form limited to 2 bytes (64K)
        if len<256:
            ret="0x81"+"%02X"%int(len)
        else:
            ret="0x82"+"%04X"%int(len)
    return ret

# Quit program with error
def bailOut(msg):
    print msg
    sys.exit(1)

# Split message into parts (remove field from remaining body)
def chop_msg(msg,size):
    return (msg[0:size],msg[size:])

# Chop len from message
def chop_len(msg):
    (mlen,msg)=chop_msg(msg,2)
    if mlen>"80":
        # Multibyte
        nlen=ord(mlen.decode("hex"))&0x7f
        (mlen,msg)=chop_msg(msg,2*nlen)
    return (decodeToInt(mlen),msg)

# get BER encoded option from message
def chop_BER(msg):
    (op,msg)=chop_msg(msg,2)
    (oplen,msg)=chop_len(msg)
    (val,msg)=chop_msg(msg,2*oplen)
    return op,val,msg

# Connect to host:port (TCP)
def Connect(host,port):
    # Create a socket (SOCK_STREAM means a TCP socket)
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((host, port))
    return sock

# From dict_* (dictionary) find index for value
def dictCmd2Name(dictionary,value):
    keys=dictionary.keys()
    values=dictionary.values()
    index=[i for i,x in enumerate(values) if x == value]
    return keys[index[0]]

#-----------------------------------------------------------------------------
#Create section
#-----------------------------------------------------------------------------

# Create generic Response message
def create_LDAPResult(msgId,code,result,matchedDN,errorMSG):
    # Adding from end to the beginning
    #    LDAPResult ::= SEQUENCE {
    #         resultCode         ENUMERATED,
    #         matchedDN          LDAPDN,
    #         diagnosticMessage  LDAPString,
    #         referral           [3] Referral OPTIONAL }
    # 04="%02X"%dict_tag['OCTET_STRING']
    # 0A="%02X"%dict_tag['ENUMERATED']
    ret=''
    ret=encodeValue('04',errorMSG)+ret
    ret=encodeValue('04',matchedDN)+ret
    ret=encodeValue('0A',result)+ret
    ret=encodeStr(code,ret.decode("hex"))
    ret=encodeStr('02',msgId.decode("hex"))+ret
    ret=encodeStr('30',ret.decode("hex"))
    return ret

######################################################
# History
# 0.2.9 - Oct 11, 2012 - initial version
# 0.3.0 - Oct 26, 2012 - finally got it working
#       - Oct 29, 2012 - msgId encoding fixed, reuseaddr fixed
#                      - encodeTo<Type> renamed to encode<Type> (more logical)
#                      - multiple values for key now supported
#                      - int len now not fixed
# 0.3.1 - Nov 05, 2012 - comments added, code cleanup
#                      - logging removed because it conflicts with threaded
#                        LDAP simulator
#                      - add/delete/modify support
#         Nov 17, 2012 - decode rewrite


text:
<?php //-->

class Eve_Model_Session_Index_Test extends PHPUnit_Framework_TestCase
{

    public function testAccess()
    {
        $class = eve()->model('session')->access();
        $this->assertInstanceOf('Eve\\Model\\Session\\Access', $class);
    }

    public function testLogin()
    {
        $class = eve()->model('session')->login();
        $this->assertInstanceOf('Eve\\Model\\Session\\Login', $class);
    }

    public function testLogout()
    {
        $class = eve()->model('session')->logout();
        $this->assertInstanceOf('Eve\\Model\\Session\\Logout', $class);
    }

    public function testRequest()
    {
        $class = eve()->model('session')->request();
        $this->assertInstanceOf('Eve\\Model\\Session\\Request', $class);
    }

    public function testGetProfileByToken()
    {
        $session = eve()->registry()->get('test', 'session');
        $profile = eve()->registry()->get('test', 'profile');

        $row = eve()
            ->model('session')
            ->getProfileByToken($session['access_token']);

        $this->assertEquals($profile['profile_name'], $row['profile_name']);
    }

    public function testGetAppByToken()
    {
        $session = eve()->registry()->get('test', 'session');
        $app = eve()->registry()->get('test', 'app');

        $row = eve()
            ->model('session')
            ->getAppByToken($session['access_token']);

        $this->assertEquals($app['app_id'], $row['app_id']);
    }
}


text:
<?php

namespace App\Http\Controllers\Api;

use App\Models\Api\QueueSchema;
use App\Models\Item;
use App\Models\Queue;
use App\Models\User;
use App\Models\Api\ItemSchema;
use App\Models\Api\UserSchema;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Neomerx\JsonApi\Encoder\Encoder;
use Neomerx\JsonApi\Encoder\EncoderOptions;

class JsonApiController extends Controller
{
    protected $modelSchemaMappings = [
        Item::class => ItemSchema::class,
        Queue::class => QueueSchema::class,
        User::class => UserSchema::class,
    ];

    protected $encoderOptions;
    protected $defaultEncoderOptions = [
        'options' => JSON_PRETTY_PRINT,
        'urlPrefix' => '/api',
    ];

    public function __construct()
    {
        $this->encoderOptions = new EncoderOptions(
            $this->defaultEncoderOptions['options'],
            $this->defaultEncoderOptions['urlPrefix']
        );
    }

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //
    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $model = Model::findOrFail($id);

        $encoder = Encoder::instance($this->modelSchemaMappings, $this->encoderOptions);
        $encodedData = $encoder->encodeData($model);

        return response($encoder->encodeData($encodedData))
            ->header('Content-Type', 'application/json');
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}


text:
angular.module('huntEdu.controllers')
    .controller('EmployerProfileCtrl', ['$scope', 'User', '$location',
    function EmployerProfileCtrl($scope, User, $location) {

        $scope.showEmployer = function() {
            return User.isEmployer();
        };

        $scope.updateEmployer = function() {
            $location.path('/updateEmployerProfile');
        };

        $scope.edit = function(jobId) {
            var postId = jobId;
            $location.path('/updateJobPosting' + postId);
        };

        $scope.$on('$viewContentLoaded', function() {
            if(User.isEmployer()){
                var role = User.getUserRole();
                $scope.employerProfileData = User.getProfileData(role);
    	   }
            else {
                $location.path('/');
            }
        });

    }]);


text:
package io.reactivex;

import java.util.concurrent.CountDownLatch;

import org.openjdk.jmh.infra.Blackhole;

import io.reactivex.disposables.Disposable;

public final class PerfObserver implements Observer<Object> {
    final CountDownLatch cdl;
    final Blackhole bh;
    public PerfObserver(Blackhole bh) {
        this.bh = bh;
        this.cdl = new CountDownLatch(1);
    }
    @Override
    public void onSubscribe(Disposable d) {

    }
    @Override
    public void onNext(Object value) {
        bh.consume(value);
    }
    @Override
    public void onError(Throwable e) {
        e.printStackTrace();
        cdl.countDown();
    }
    @Override
    public void onComplete() {
        cdl.countDown();
    }
}


text:
<?php

namespace Org\Schema\Thing\Intangible;

/**
 * Class Permit
 * A permit issued by an organization, e.g. a parking pass.
 * @author      AppBels <app.bels@gmail.com>
 * @name        Permit
 * @namespace   Org\Schema\Thing\Intangible
 * @package     Org\Schema
 * @see         https://schema.org/Permit
 * Date         30/03/2017
 */
class Permit extends \Org\Schema\Thing\Intangible
{

	/**
	 * The organization issuing the ticket or permit.
	 * @access	public
	 * @var		\Org\Schema\Thing\Organization
	 */
	public $issuedBy;

	/**
	 * The service through with the permit was granted.
	 * @access	public
	 * @var		\Org\Schema\Thing\Intangible\Service
	 */
	public $issuedThrough;

	/**
	 * The target audience for this permit.
	 * @access	public
	 * @var		\Org\Schema\Thing\Intangible\Audience
	 */
	public $permitAudience;

	/**
	 * The time validity of the permit.
	 * @access	public
	 * @var		\Org\Schema\Thing\Intangible\Quantity\Duration
	 */
	public $validFor;

	/**
	 * The date when the item becomes valid.
	 * @access	public
	 * @var		string
	 */
	public $validFrom;

	/**
	 * The geographic area where the permit is valid.
	 * @access	public
	 * @var		\Org\Schema\Thing\Place\AdministrativeArea
	 */
	public $validIn;

	/**
	 * The date when the item is no longer valid.
	 * @access	public
	 * @var		string
	 */
	public $validUntil;

	/**
	 * Permit constructor.
	 * @access  public
	 * @see     \Org\Schema\Thing\Intangible::__construct()
	 */
	public function __construct ()
	{
		parent::__construct();
	}

	/**
	 * Permit toString.
	 * @access  public
	 * @see     \Org\Schema\Thing\Intangible::__toString()
	 *
	 * @return  string
	 */
	public function __toString ()
	{
		return parent::__toString();
	}

	/**
	 * Permit destructor.
	 * @access  public
	 * @see     \Org\Schema\Thing\Intangible::__destruct()
	 */
	public function __destruct ()
	{
		parent::__destruct();
	}

}

?>


text:
#include <string.h>
#include <stdarg.h>

#include "hclib.h"
#include "hclib-rt.h"
#include "hclib-task.h"
#include "hclib-async-struct.h"
#include "hclib-finish.h"
#include "hclib-module.h"
#include "hclib-fptr-list.h"

#ifdef __cplusplus
extern "C" {
#endif

static loop_dist_func *registered_dist_funcs = NULL;
static unsigned n_registered_dist_funcs = 0;

unsigned hclib_register_dist_func(loop_dist_func func) {
    registered_dist_funcs = (loop_dist_func *)realloc(registered_dist_funcs,
            (n_registered_dist_funcs + 1) * sizeof(loop_dist_func));
    HASSERT(registered_dist_funcs);
    registered_dist_funcs[n_registered_dist_funcs++] = func;
    return n_registered_dist_funcs - 1;
}

loop_dist_func hclib_lookup_dist_func(unsigned id) {
    HASSERT(id < n_registered_dist_funcs);
    return registered_dist_funcs[id];
}

/*** START ASYNC IMPLEMENTATION ***/

void hclib_async(generic_frame_ptr fp, void *arg, hclib_future_t **futures,
        const int nfutures, hclib_locale_t *locale) {
    hclib_task_t *task = calloc(1, sizeof(*task));
    HASSERT(task);

    task->_fp = fp;
    task->args = arg;

    if (nfutures > 0) {
        // locale may be NULL, in which case this is equivalent to spawn_await
        spawn_await_at(task, futures, nfutures, locale);
    } else {
        // locale may be NULL, in which case this is equivalent to spawn
        spawn_at(task, locale);
    }
}

void hclib_async_nb(generic_frame_ptr fp, void *arg, hclib_locale_t *locale) {
    hclib_task_t *task = calloc(1, sizeof(*task));
    task->_fp = fp;
    task->args = arg;
    task->non_blocking = 1;
    spawn_at(task, locale);
}

typedef struct _future_args_wrapper {
    hclib_promise_t event;
    future_fct_t fp;
    void *actual_in;
} future_args_wrapper;

static void future_caller(void *in) {
    future_args_wrapper *args = in;
    void *user_result = (args->fp)(args->actual_in);
    hclib_promise_put(&args->event, user_result);
}

hclib_future_t *hclib_async_future(future_fct_t fp, void *arg,
                                   hclib_future_t **futures, const int nfutures,
                                   hclib_locale_t *locale) {
    future_args_wrapper *wrapper = malloc(sizeof(future_args_wrapper));
    hclib_promise_init(&wrapper->event);
    wrapper->fp = fp;
    wrapper->actual_in = arg;
    hclib_async(future_caller, wrapper, futures, nfutures, locale);

    return hclib_get_future_for_promise(&wrapper->event);
}

/*** END ASYNC IMPLEMENTATION ***/

/*** START FORASYNC IMPLEMENTATION ***/

#define DEBUG_FORASYNC 0

static inline forasync1D_task_t *allocate_forasync1D_task() {
    forasync1D_task_t *forasync_task = (forasync1D_task_t *)calloc(1,
            sizeof(*forasync_task));
    HASSERT(forasync_task && "malloc failed");
    return forasync_task;
}

static inline forasync2D_task_t *allocate_forasync2D_task() {
    forasync2D_task_t *forasync_task = (forasync2D_task_t *)calloc(1,
            sizeof(*forasync_task));
    HASSERT(forasync_task && "malloc failed");
    return forasync_task;
}

static inline forasync3D_task_t *allocate_forasync3D_task() {
    forasync3D_task_t *forasync_task = (forasync3D_task_t *)calloc(1,
            sizeof(*forasync_task));
    HASSERT(forasync_task && "malloc failed");
    return forasync_task;
}

static void forasync1D_runner(void *forasync_arg) {
    forasync1D_t *forasync = (forasync1D_t *) forasync_arg;
    hclib_task_t *user = forasync->base.user;
    forasync1D_Fct_t user_fct_ptr = (forasync1D_Fct_t) user->_fp;
    void *user_arg = (void *) user->args;
    hclib_loop_domain_t loop0 = forasync->loop;
    int i=0;
    for(i=loop0.low; i<loop0.high; i+=loop0.stride) {
        (*user_fct_ptr)(user_arg, i);
    }
}

static void forasync2D_runner(void *forasync_arg) {
    forasync2D_t *forasync = (forasync2D_t *) forasync_arg;
    hclib_task_t *user = *((hclib_task_t **) forasync_arg);
    forasync2D_Fct_t user_fct_ptr = (forasync2D_Fct_t) user->_fp;
    void *user_arg = (void *) user->args;
    hclib_loop_domain_t loop0 = forasync->loop[0];
    hclib_loop_domain_t loop1 = forasync->loop[1];
    int i=0,j=0;
    for(i=loop0.low; i<loop0.high; i+=loop0.stride) {
        for(j=loop1.low; j<loop1.high; j+=loop1.stride) {
            (*user_fct_ptr)(user_arg, i, j);
        }
    }
}

static void forasync3D_runner(void *forasync_arg) {
    forasync3D_t *forasync = (forasync3D_t *) forasync_arg;
    hclib_task_t *user = *((hclib_task_t **) forasync_arg);
    forasync3D_Fct_t user_fct_ptr = (forasync3D_Fct_t) user->_fp;
    void *user_arg = (void *) user->args;
    hclib_loop_domain_t loop0 = forasync->loop[0];
    hclib_loop_domain_t loop1 = forasync->loop[1];
    hclib_loop_domain_t loop2 = forasync->loop[2];
    int i=0,j=0,k=0;
    for(i=loop0.low; i<loop0.high; i+=loop0.stride) {
        for(j=loop1.low; j<loop1.high; j+=loop1.stride) {
            for(k=loop2.low; k<loop2.high; k+=loop2.stride) {
                (*user_fct_ptr)(user_arg, i, j, k);
            }
        }
    }
#if DEBUG_FORASYNC
    printf("forasync spawned %d\n", nb_spawn);
#endif
}

void forasync1D_recursive(void *forasync_arg) {
    forasync1D_t *forasync = (forasync1D_t *) forasync_arg;
    hclib_loop_domain_t loop0 = forasync->loop;
    int high0 = loop0.high;
    int low0 = loop0.low;
    int stride0 = loop0.stride;
    int tile0 = loop0.tile;

    //split the range into two, spawn a new task for the first half and recurse on the rest
    if((high0-low0) > tile0) {
        int mid = (high0+low0)/2;
        // upper-half
        forasync1D_task_t *new_forasync_task = allocate_forasync1D_task();
        new_forasync_task->forasync_task._fp = forasync1D_recursive;
        new_forasync_task->forasync_task.args = &(new_forasync_task->def);
        new_forasync_task->def.base.user = forasync->base.user;
        new_forasync_task->def.loop.low = mid;
        new_forasync_task->def.loop.high = high0;
        new_forasync_task->def.loop.stride = stride0;
        new_forasync_task->def.loop.tile = tile0;

        // update lower-half
        forasync->loop.high = mid;
        // delegate scheduling to the underlying runtime

        spawn((hclib_task_t *)new_forasync_task);
        //continue to work on the half task
        forasync1D_recursive(forasync_arg);
    } else {
        //compute the tile
        forasync1D_runner(forasync_arg);
    }
}

void forasync2D_recursive(void *forasync_arg) {
    forasync2D_t *forasync = (forasync2D_t *) forasync_arg;
    hclib_loop_domain_t loop0 = forasync->loop[0];
    int high0 = loop0.high;
    int low0 = loop0.low;
    int stride0 = loop0.stride;
    int tile0 = loop0.tile;
    hclib_loop_domain_t loop1 = forasync->loop[1];
    int high1 = loop1.high;
    int low1 = loop1.low;
    int stride1 = loop1.stride;
    int tile1 = loop1.tile;

    //split the range into two, spawn a new task for the first half and recurse on the rest
    forasync2D_task_t *new_forasync_task = NULL;
    if((high0-low0) > tile0) {
        int mid = (high0+low0)/2;
        // upper-half
        new_forasync_task = allocate_forasync2D_task();
        new_forasync_task->forasync_task._fp = forasync2D_recursive;
        new_forasync_task->forasync_task.args = &(new_forasync_task->def);
        new_forasync_task->def.base.user = forasync->base.user;
        hclib_loop_domain_t new_loop0 = {mid, high0, stride0, tile0};;
        new_forasync_task->def.loop[0] = new_loop0;
        new_forasync_task->def.loop[1] = loop1;
        // update lower-half
        forasync->loop[0].high = mid;
    } else if((high1-low1) > tile1) {
        int mid = (high1+low1)/2;
        // upper-half
        new_forasync_task = allocate_forasync2D_task();
        new_forasync_task->forasync_task._fp = forasync2D_recursive;
        new_forasync_task->forasync_task.args = &(new_forasync_task->def);
        new_forasync_task->def.base.user = forasync->base.user;
        new_forasync_task->def.loop[0] = loop0;
        hclib_loop_domain_t new_loop1 = {mid, high1, stride1, tile1};
        new_forasync_task->def.loop[1] = new_loop1;
        // update lower-half
        forasync->loop[1].high = mid;
    }
    // recurse
    if(new_forasync_task != NULL) {
        // delegate scheduling to the underlying runtime
        //TODO can we make this a special async to avoid a get_current_async ?
        spawn((hclib_task_t *)new_forasync_task);
        //continue to work on the half task
        forasync2D_recursive(forasync_arg);
    } else { //compute the tile
        forasync2D_runner(forasync_arg);
    }
}

void forasync3D_recursive(void *forasync_arg) {
    forasync3D_t *forasync = (forasync3D_t *) forasync_arg;
    hclib_loop_domain_t loop0 = forasync->loop[0];
    int high0 = loop0.high;
    int low0 = loop0.low;
    int stride0 = loop0.stride;
    int tile0 = loop0.tile;
    hclib_loop_domain_t loop1 = forasync->loop[1];
    int high1 = loop1.high;
    int low1 = loop1.low;
    int stride1 = loop1.stride;
    int tile1 = loop1.tile;
    hclib_loop_domain_t loop2 = forasync->loop[2];
    int high2 = loop2.high;
    int low2 = loop2.low;
    int stride2 = loop2.stride;
    int tile2 = loop2.tile;

    //split the range into two, spawn a new task for the first half and recurse on the rest
    forasync3D_task_t *new_forasync_task = NULL;
    if((high0-low0) > tile0) {
        int mid = (high0+low0)/2;
        // upper-half
        new_forasync_task = allocate_forasync3D_task();
        new_forasync_task->forasync_task._fp = forasync3D_recursive;
        new_forasync_task->forasync_task.args = &(new_forasync_task->def);
        new_forasync_task->def.base.user = forasync->base.user;
        hclib_loop_domain_t new_loop0 = {mid, high0, stride0, tile0};
        new_forasync_task->def.loop[0] = new_loop0;
        new_forasync_task->def.loop[1] = loop1;
        new_forasync_task->def.loop[2] = loop2;
        // update lower-half
        forasync->loop[0].high = mid;
    } else if((high1-low1) > tile1) {
        int mid = (high1+low1)/2;
        // upper-half
        new_forasync_task = allocate_forasync3D_task();
        new_forasync_task->forasync_task._fp = forasync3D_recursive;
        new_forasync_task->forasync_task.args = &(new_forasync_task->def);
        new_forasync_task->def.base.user = forasync->base.user;
        new_forasync_task->def.loop[0] = loop0;
        hclib_loop_domain_t new_loop1 = {mid, high1, stride1, tile1};
        new_forasync_task->def.loop[1] = new_loop1;
        new_forasync_task->def.loop[2] = loop2;
        // update lower-half
        forasync->loop[1].high = mid;
    } else if((high2-low2) > tile2) {
        int mid = (high2+low2)/2;
        // upper-half
        new_forasync_task = allocate_forasync3D_task();
        new_forasync_task->forasync_task._fp = forasync3D_recursive;
        new_forasync_task->forasync_task.args = &(new_forasync_task->def);
        new_forasync_task->def.base.user = forasync->base.user;
        new_forasync_task->def.loop[0] = loop0;
        new_forasync_task->def.loop[1] = loop1;
        hclib_loop_domain_t new_loop2 = {mid, high2, stride2, tile2};
        new_forasync_task->def.loop[2] = new_loop2;
        // update lower-half
        forasync->loop[2].high = mid;
    }
    // recurse
    if(new_forasync_task != NULL) {
        // delegate scheduling to the underlying runtime
        //TODO can we make this a special async to avoid a get_current_async ?
        spawn((hclib_task_t *)new_forasync_task);
        //continue to work on the half task
        forasync3D_recursive(forasync_arg);
    } else { //compute the tile
        forasync3D_runner(forasync_arg);
    }
}

void forasync1D_flat(void *forasync_arg) {
    forasync1D_t *forasync = (forasync1D_t *) forasync_arg;
    hclib_loop_domain_t loop0 = forasync->loop;
    int high0 = loop0.high;
    int stride0 = loop0.stride;
    int tile0 = loop0.tile;
    int nb_chunks = (int) (high0/tile0);
    int size = tile0*nb_chunks;
    int low0;
    for(low0 = loop0.low; low0<size; low0+=tile0) {
#if DEBUG_FORASYNC
        printf("Scheduling Task %d %d\n",low0,(low0+tile0));
#endif
        //TODO block allocation ?
        forasync1D_task_t *new_forasync_task = allocate_forasync1D_task();
        new_forasync_task->forasync_task._fp = forasync1D_runner;
        new_forasync_task->forasync_task.args = &(new_forasync_task->def);
        new_forasync_task->def.base.user = forasync->base.user;
        hclib_loop_domain_t new_loop0 = {low0, low0+tile0, stride0, tile0};
        new_forasync_task->def.loop = new_loop0;
        spawn((hclib_task_t *)new_forasync_task);
    }
    // handling leftover
    if (size < high0) {
#if DEBUG_FORASYNC
        printf("Scheduling Task %d %d\n",low0,high0);
#endif
        forasync1D_task_t *new_forasync_task = allocate_forasync1D_task();
        new_forasync_task->forasync_task._fp = forasync1D_runner;
        new_forasync_task->forasync_task.args = &(new_forasync_task->def);
        new_forasync_task->def.base.user = forasync->base.user;
        hclib_loop_domain_t new_loop0 = {low0, high0, loop0.stride, loop0.tile};
        new_forasync_task->def.loop = new_loop0;
        spawn((hclib_task_t *)new_forasync_task);
    }
}

void forasync2D_flat(void *forasync_arg) {
    forasync2D_t *forasync = (forasync2D_t *) forasync_arg;
    hclib_loop_domain_t loop0 = forasync->loop[0];
    hclib_loop_domain_t loop1 = forasync->loop[1];
    int low0, low1;
    for(low0=loop0.low; low0<loop0.high; low0+=loop0.tile) {
        int high0 = (low0+loop0.tile)>loop0.high?loop0.high:(low0+loop0.tile);
#if DEBUG_FORASYNC
        printf("Scheduling Task Loop1 %d %d\n",low0,high0);
#endif
        for(low1=loop1.low; low1<loop1.high; low1+=loop1.tile) {
            int high1 = (low1+loop1.tile)>loop1.high?loop1.high:(low1+loop1.tile);
#if DEBUG_FORASYNC
            printf("Scheduling Task %d %d\n",low1,high1);
#endif
            forasync2D_task_t *new_forasync_task = allocate_forasync2D_task();
            new_forasync_task->forasync_task._fp = forasync2D_runner;
            new_forasync_task->forasync_task.args = &(new_forasync_task->def);
            new_forasync_task->def.base.user = forasync->base.user;
            hclib_loop_domain_t new_loop0 = {low0, high0, loop0.stride, loop0.tile};
            new_forasync_task->def.loop[0] = new_loop0;
            hclib_loop_domain_t new_loop1 = {low1, high1, loop1.stride, loop1.tile};
            new_forasync_task->def.loop[1] = new_loop1;
            spawn((hclib_task_t *)new_forasync_task);
        }
    }
}

void forasync3D_flat(void *forasync_arg) {
    forasync3D_t *forasync = (forasync3D_t *) forasync_arg;
    hclib_loop_domain_t loop0 = forasync->loop[0];
    hclib_loop_domain_t loop1 = forasync->loop[1];
    hclib_loop_domain_t loop2 = forasync->loop[2];
    int low0, low1, low2;
    for(low0=loop0.low; low0<loop0.high; low0+=loop0.tile) {
        int high0 = (low0+loop0.tile)>loop0.high?loop0.high:(low0+loop0.tile);
#if DEBUG_FORASYNC
        printf("Scheduling Task Loop1 %d %d\n",low0,high0);
#endif
        for(low1=loop1.low; low1<loop1.high; low1+=loop1.tile) {
            int high1 = (low1+loop1.tile)>loop1.high?loop1.high:(low1+loop1.tile);
#if DEBUG_FORASYNC
            printf("Scheduling Task Loop2 %d %d\n",low1,high1);
#endif
            for(low2=loop2.low; low2<loop2.high; low2+=loop2.tile) {
                int high2 = (low2+loop2.tile)>loop2.high?loop2.high:(low2+loop2.tile);
#if DEBUG_FORASYNC
                printf("Scheduling Task %d %d\n",low2,high2);
#endif
                forasync3D_task_t *new_forasync_task = allocate_forasync3D_task();
                new_forasync_task->forasync_task._fp = forasync3D_runner;
                new_forasync_task->forasync_task.args = &(new_forasync_task->def);
                new_forasync_task->def.base.user = forasync->base.user;
                hclib_loop_domain_t new_loop0 = {low0, high0, loop0.stride, loop0.tile};
                new_forasync_task->def.loop[0] = new_loop0;
                hclib_loop_domain_t new_loop1 = {low1, high1, loop1.stride, loop1.tile};
                new_forasync_task->def.loop[1] = new_loop1;
                hclib_loop_domain_t new_loop2 = {low2, high2, loop2.stride, loop2.tile};
                new_forasync_task->def.loop[2] = new_loop2;
                spawn((hclib_task_t *)new_forasync_task);
            }
        }
    }
}

static void forasync_internal(void *user_fct_ptr, void *user_arg,
                              int dim, const hclib_loop_domain_t *loop_domain,
                              forasync_mode_t mode) {
    // All the sub-asyncs share async_def

    // The user loop code to execute
    hclib_task_t *user_def = (hclib_task_t *)calloc(1, sizeof(*user_def));
    HASSERT(user_def);
    user_def->_fp = user_fct_ptr;
    user_def->args = user_arg;

    HASSERT(dim>0 && dim<4);
    // TODO put those somewhere as static
    async_fct_t fct_ptr_rec[3] = { forasync1D_recursive, forasync2D_recursive,
                                  forasync3D_recursive
                                };
    async_fct_t fct_ptr_flat[3] = { forasync1D_flat, forasync2D_flat,
                                   forasync3D_flat
                                 };
    async_fct_t *fct_ptr = (mode == FORASYNC_MODE_RECURSIVE) ? fct_ptr_rec :
                          fct_ptr_flat;
    if (dim == 1) {
        forasync1D_t forasync = {{user_def}, loop_domain[0]};
        (fct_ptr[dim-1])((void *) &forasync);
    } else if (dim == 2) {
        forasync2D_t forasync = {{user_def}, {loop_domain[0], loop_domain[1]}};
        (fct_ptr[dim-1])((void *) &forasync);
    } else if (dim == 3) {
        forasync3D_t forasync = {{user_def}, {loop_domain[0], loop_domain[1],
            loop_domain[2]}};
        (fct_ptr[dim-1])((void *) &forasync);
    }
}

void hclib_forasync(void *forasync_fct, void *argv, int dim,
                    hclib_loop_domain_t *domain, forasync_mode_t mode) {
    const int nworkers = hclib_get_num_workers();
    int i;
    for (i = 0; i < dim; i++) {
        if (domain[i].tile == -1) {
            domain[i].tile = ((domain[i].high - domain[i].low) + nworkers - 1) /
                nworkers;
        }
    }

    forasync_internal(forasync_fct, argv, dim, domain, mode);
}

hclib_future_t *hclib_forasync_future(void *forasync_fct, void *argv,
                                      int dim, hclib_loop_domain_t *domain,
                                      forasync_mode_t mode) {

    hclib_start_finish();
    hclib_forasync(forasync_fct, argv, dim, domain, mode);
    return hclib_end_finish_nonblocking();
}

void hclib_get_curr_task_info(void (**fp_out)(void *), void **args_out) {
    hclib_worker_state *ws = CURRENT_WS_INTERNAL;
    hclib_task_t *curr_task = (hclib_task_t *)ws->curr_task;
    *fp_out = curr_task->_fp;
    *args_out = curr_task->args;
}

/*** END FORASYNC IMPLEMENTATION ***/

#ifdef __cplusplus
}
#endif


text:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.flowable</groupId>
        <artifactId>flowable-spring-boot-samples</artifactId>
        <version>6.0.0.RC1-SNAPSHOT</version>
    </parent>

    <artifactId>flowable-spring-boot-sample-rest-api</artifactId>

    <dependencies>
        <dependency>
            <groupId>org.flowable</groupId>
            <artifactId>flowable-spring-boot-starter-rest-api</artifactId>
            <version>6.0.0.RC1-SNAPSHOT</version>
        </dependency>
        <dependency>
			<groupId>junit</groupId>
			<artifactId>junit</artifactId>
			<scope>test</scope>
		</dependency>
    </dependencies>

</project>