Example #1
0
				promises.push(delayer.trigger(factory).then(() => { assert.equal(result, 1); assert(!delayer.isTriggered()); }));
Example #2
0
import * as tls from "tls";
import * as http from "http";
import * as net from "net";
import * as tty from "tty";
import * as dgram from "dgram";
import * as querystring from "querystring";
import * as path from "path";
import * as readline from "readline";
import * as childProcess from "child_process";
import * as cluster from "cluster";
import * as os from "os";
import * as vm from "vm";
// Specifically test buffer module regression.
import {Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer} from "buffer";

assert(1 + 1 - 2 === 0, "The universe isn't how it should.");

assert.deepEqual({ x: { y: 3 } }, { x: { y: 3 } }, "DEEP WENT DERP");

assert.equal(3, "3", "uses == comparator");

assert.notStrictEqual(2, "2", "uses === comparator");

assert.notDeepStrictEqual({ x: { y: "3" } }, { x: { y: 3 } }, "uses === comparator");

assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT");

assert.doesNotThrow(() => {
    const b = false;
    if (b) { throw "a hammer at your face"; }
}, undefined, "What the...*crunch*");
Example #3
0
 it("Initializes with specified files", function () {
     const speak = new BSTVirtualAlexa("http://localhost:9000",
         "test/resources/interactionModel/models/en-US.json");
     speak.start();
     assert(true, "Start processed without exceptions");
 });
 setTimeout(() => {
   assert(!debuglet.activeBreakpointMap.test);
   debuglet.stop();
   scope.done();
   done();
 }, 1100);
Example #5
0
 next: (location: Location) => {
   assert(location.pathname);
   done();
 },
Example #6
0
	var testGetSetPixels = function (color : number, sourceAlpha: boolean, destAlpha: boolean) {
		var bitmapData = new BitmapData (TEST_WIDTH, TEST_HEIGHT, sourceAlpha, color);
		var pixels = bitmapData.getPixels (bitmapData.rect);
		
		assert.equal (pixels.length, TEST_WIDTH * TEST_HEIGHT * 4);
		
		var expectedColor = color;
		if (sourceAlpha) {
			
			// TODO: Native behavior is different than the flash target here.
			//	   The flash target premultiplies RGB by the alpha value.
			//	   If the native behavior is changed, this test needs to be
			//	   updated.
			if ((expectedColor & 0xFF000000) == 0) {
				expectedColor = 0;
			}
			
		} else {
			// Surfaces that don't support alpha return FF for the alpha value, so
			// set our expected alpha to FF no matter what the initial value was
			expectedColor |= 0xFF000000;
		}
		
		var i : number;
		var pixel : number;
		pixels.position = 0;
		
		for (i = 0; i < TEST_WIDTH * TEST_HEIGHT; i++) {
			pixel = pixels.readInt();
			assert (Math.abs (((expectedColor >> 24) & 0xFF) - ((pixel >> 24) & 0xFF)) <= 1);
			assert (Math.abs (((expectedColor >> 16) & 0xFF) - ((pixel >> 16) & 0xFF)) <= 1);
			assert (Math.abs (((expectedColor >> 8) & 0xFF) - ((pixel >> 8) & 0xFF)) <= 1);
			assert (Math.abs (((expectedColor) & 0xFF) - ((pixel) & 0xFF)) <= 1);
		}
		
		// Now run the same test again to make sure the source
		// did not get changed by reading the first time.
		pixels = bitmapData.getPixels (bitmapData.rect);
		
		assert.equal (pixels.length, TEST_WIDTH * TEST_HEIGHT * 4);
		
		pixels.position = 0;
		for (i = 0; i < TEST_WIDTH * TEST_HEIGHT; i++) {
			pixel = pixels.readInt();
			assert (Math.abs (((expectedColor >> 24) & 0xFF) - ((pixel >> 24) & 0xFF)) <= 1);
			assert (Math.abs (((expectedColor >> 16) & 0xFF) - ((pixel >> 16) & 0xFF)) <= 1);
			assert (Math.abs (((expectedColor >> 8) & 0xFF) - ((pixel >> 8) & 0xFF)) <= 1);
			assert (Math.abs (((expectedColor) & 0xFF) - ((pixel) & 0xFF)) <= 1);
		}
		
		bitmapData = new BitmapData (TEST_WIDTH, TEST_HEIGHT, destAlpha);
		
		pixels.position = 0;
		bitmapData.setPixels (bitmapData.rect, pixels);
		
		var pixel:number = bitmapData.getPixel32 (1, 1);
		
		if (!destAlpha) {
			expectedColor |= 0xFF000000;
		}
		
		assert (Math.abs (((expectedColor >> 24) & 0xFF) - ((pixel >> 24) & 0xFF)) <= 1);
		assert (Math.abs (((expectedColor >> 16) & 0xFF) - ((pixel >> 16) & 0xFF)) <= 1);
		assert (Math.abs (((expectedColor >> 8) & 0xFF) - ((pixel >> 8) & 0xFF)) <= 1);
		assert (Math.abs (((expectedColor) & 0xFF) - ((pixel) & 0xFF)) <= 1);
	}
Example #7
0
 stats.record("", AccessType.REQUEST_DROPPED, function (error: Error) {
     assert(!error);
     done();
 });
 it("#isRuleModule", function() {
     assert(isRuleModule(FixerRule));
     assert(isRuleModule(LinterRule));
     assert(!isRuleModule(FixerOnlyRule));
     assert(!isRuleModule(SimpleModule));
 });
async function testContentType(drive: APIEndpoint) {
  nock(Utils.baseUrl).post('/drive/v2/files/a/comments').reply(200);
  const res =
      await drive.comments.insert({fileId: 'a', resource: {content: 'hello '}});
  assert(res.request.headers['content-type'].indexOf('application/json') === 0);
}
Example #10
0
		walker.readStdout(cmd1, 'utf8', /*isRipgrep=*/false, (err1, stdout1) => {
			assert.equal(err1, null);
			assert(outputContains(stdout1, file0), stdout1);
			assert(!outputContains(stdout1, file1), stdout1);
			done();
		});
 it("#hasFixer", function() {
     assert(hasFixer(FixerRule));
     assert(!hasFixer(LinterRule));
     assert(!hasFixer(FixerOnlyRule));
     assert(!hasFixer(SimpleModule));
 });
Example #12
0
	test('removeClass', () => {

		let element = document.createElement('div');
		element.className = 'foobar boo far';

		dom.removeClass(element, 'boo');
		assert(dom.hasClass(element, 'far'));
		assert(!dom.hasClass(element, 'boo'));
		assert(dom.hasClass(element, 'foobar'));
		assert.equal(element.className, 'foobar far');

		element = document.createElement('div');
		element.className = 'foobar boo far';

		dom.removeClass(element, 'far');
		assert(!dom.hasClass(element, 'far'));
		assert(dom.hasClass(element, 'boo'));
		assert(dom.hasClass(element, 'foobar'));
		assert.equal(element.className, 'foobar boo');

		dom.removeClass(element, 'boo');
		assert(!dom.hasClass(element, 'far'));
		assert(!dom.hasClass(element, 'boo'));
		assert(dom.hasClass(element, 'foobar'));
		assert.equal(element.className, 'foobar');

		dom.removeClass(element, 'foobar');
		assert(!dom.hasClass(element, 'far'));
		assert(!dom.hasClass(element, 'boo'));
		assert(!dom.hasClass(element, 'foobar'));
		assert.equal(element.className, '');
	});
Example #13
0
		let factoryFactory = (n: number) => () => {
			activePromises++;
			assert(activePromises < 6);
			return async.timeout(0).then(() => { activePromises--; return n; });
		};
Example #14
0
		const p = Promise.all(promises).then(() => {
			assert(!delayer.isTriggered());
		});
Example #15
0
	test('isFunction', () => {
		assert(!types.isFunction(undefined));
		assert(!types.isFunction(null));
		assert(!types.isFunction('foo'));
		assert(!types.isFunction(5));
		assert(!types.isFunction(true));
		assert(!types.isFunction([]));
		assert(!types.isFunction([1, 2, '3']));
		assert(!types.isFunction({}));
		assert(!types.isFunction({ foo: 'bar' }));
		assert(!types.isFunction(/test/));
		assert(!types.isFunction(new RegExp('')));
		assert(!types.isFunction(new Date()));

		assert(types.isFunction(assert));
		assert(types.isFunction(function foo() { /**/ }));
	});
 drive.files.list({q: 'hello'}, (err: NodeJS.ErrnoException) => {
   assert(err instanceof Error);
   assert.strictEqual(err.message, 'Error!');
   assert.strictEqual(err.code, 400);
   cb();
 });
Example #17
0
	test('isArray', () => {
		assert(!types.isArray(undefined));
		assert(!types.isArray(null));
		assert(!types.isArray('foo'));
		assert(!types.isArray(5));
		assert(!types.isArray(true));
		assert(!types.isArray({}));
		assert(!types.isArray(/test/));
		assert(!types.isArray(new RegExp('')));
		assert(!types.isArray(new Date()));
		assert(!types.isArray(assert));
		assert(!types.isArray(function foo() { /**/ }));
		assert(!types.isArray({ foo: 'bar' }));

		assert(types.isArray([]));
		assert(types.isArray([1, 2, '3']));
	});
 oauth2.tokeninfo({access_token: 'hello'}, (err: NodeJS.ErrnoException) => {
   assert(err instanceof Error);
   assert.strictEqual(err.message, 'invalid_grant');
   assert.strictEqual(err.code, '400');
   cb();
 });
Example #19
0
import * as os from "os";
import * as vm from "vm";
import * as string_decoder from "string_decoder";
import * as stream from "stream";
import * as timers from "timers";

// Specifically test buffer module regression.
import {Buffer as ImportedBuffer, SlowBuffer as ImportedSlowBuffer} from "buffer";

//////////////////////////////////////////////////////////
/// Assert Tests : https://nodejs.org/api/assert.html ///
//////////////////////////////////////////////////////////

namespace assert_tests{
    {
        assert(1 + 1 - 2 === 0, "The universe isn't how it should.");
        
        assert.deepEqual({ x: { y: 3 } }, { x: { y: 3 } }, "DEEP WENT DERP");
        
        // TODO: assert.deepStrictEqual
        
        assert.doesNotThrow(() => {
            const b = false;
            if (b) { throw "a hammer at your face"; }
        }, undefined, "What the...*crunch*");
        
        assert.equal(3, "3", "uses == comparator");

        // TODO: assert.fail
        
        // TODO: assert.ifError
Example #20
0
	test('isString', () => {
		assert(!types.isString(undefined));
		assert(!types.isString(null));
		assert(!types.isString(5));
		assert(!types.isString([]));
		assert(!types.isString([1, 2, '3']));
		assert(!types.isString(true));
		assert(!types.isString({}));
		assert(!types.isString(/test/));
		assert(!types.isString(new RegExp('')));
		assert(!types.isString(new Date()));
		assert(!types.isString(assert));
		assert(!types.isString(function foo() { /**/ }));
		assert(!types.isString({ foo: 'bar' }));

		assert(types.isString('foo'));
	});
Example #21
0
 stats.record(undefined, AccessType.REQUEST_DROPPED, function (error: Error) {
     assert(error);
     done();
 });
Example #22
0
	test('isNumber', () => {
		assert(!types.isNumber(undefined));
		assert(!types.isNumber(null));
		assert(!types.isNumber('foo'));
		assert(!types.isNumber([]));
		assert(!types.isNumber([1, 2, '3']));
		assert(!types.isNumber(true));
		assert(!types.isNumber({}));
		assert(!types.isNumber(/test/));
		assert(!types.isNumber(new RegExp('')));
		assert(!types.isNumber(new Date()));
		assert(!types.isNumber(assert));
		assert(!types.isNumber(function foo() { /**/ }));
		assert(!types.isNumber({ foo: 'bar' }));
		assert(!types.isNumber(parseInt('A', 10)));

		assert(types.isNumber(5));
	});
 debuglet.once('initError', (err: Error) => {
   assert(err);
   done();
 });
Example #24
0
	test('isUndefinedOrNull', () => {
		assert(!types.isUndefinedOrNull('foo'));
		assert(!types.isUndefinedOrNull([]));
		assert(!types.isUndefinedOrNull([1, 2, '3']));
		assert(!types.isUndefinedOrNull(true));
		assert(!types.isUndefinedOrNull({}));
		assert(!types.isUndefinedOrNull(/test/));
		assert(!types.isUndefinedOrNull(new RegExp('')));
		assert(!types.isUndefinedOrNull(new Date()));
		assert(!types.isUndefinedOrNull(assert));
		assert(!types.isUndefinedOrNull(function foo() { /**/ }));
		assert(!types.isUndefinedOrNull({ foo: 'bar' }));

		assert(types.isUndefinedOrNull(undefined));
		assert(types.isUndefinedOrNull(null));
	});
Example #25
0
	test('Save and Load', () => {
		let myMemento = new Memento('memento.test');

		// Global
		let memento: any = myMemento.getMemento(storage, context);
		memento.foo = [1, 2, 3];

		// Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE);
		assert(memento);
		memento.foo = 'Hello World';

		myMemento.saveMemento();

		// Global
		memento = myMemento.getMemento(storage, context);
		assert.deepEqual(memento, { foo: [1, 2, 3] });
		let globalMemento = myMemento.getMemento(storage, Scope.GLOBAL);
		assert.deepEqual(globalMemento, memento);

		// Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE);
		assert.deepEqual(memento, { foo: 'Hello World' });

		// Global
		memento = myMemento.getMemento(storage, context);
		memento.foo = [4, 5, 6];

		// Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE);
		assert(memento);
		memento.foo = 'World Hello';

		myMemento.saveMemento();

		// Global
		memento = myMemento.getMemento(storage, context);
		assert.deepEqual(memento, { foo: [4, 5, 6] });
		globalMemento = myMemento.getMemento(storage, Scope.GLOBAL);
		assert.deepEqual(globalMemento, memento);

		// Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE);
		assert.deepEqual(memento, { foo: 'World Hello' });

		// Delete Global
		memento = myMemento.getMemento(storage, context);
		delete memento.foo;

		// Delete Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE);
		delete memento.foo;

		myMemento.saveMemento();

		// Global
		memento = myMemento.getMemento(storage, context);
		assert.deepEqual(memento, {});

		// Workspace
		memento = myMemento.getMemento(storage, Scope.WORKSPACE);
		assert.deepEqual(memento, {});
	});
Example #26
0
	test('areFunctions', () => {
		assert(!types.areFunctions());
		assert(!types.areFunctions(null));
		assert(!types.areFunctions('foo'));
		assert(!types.areFunctions(5));
		assert(!types.areFunctions(true));
		assert(!types.areFunctions([]));
		assert(!types.areFunctions([1, 2, '3']));
		assert(!types.areFunctions({}));
		assert(!types.areFunctions({ foo: 'bar' }));
		assert(!types.areFunctions(/test/));
		assert(!types.areFunctions(new RegExp('')));
		assert(!types.areFunctions(new Date()));
		assert(!types.areFunctions(assert, ''));

		assert(types.areFunctions(assert));
		assert(types.areFunctions(assert, assert));
		assert(types.areFunctions(function foo() { /**/ }));
	});
Example #27
0
 it('should GET /news', async () => {
   const result = await app.httpRequest().get('/news').expect(200);
   const $ = cheerio.load(result.text);
   const listItem = $('.news-view .item');
   assert(listItem.length === app.config.news.pageSize);
 });
Example #28
0
	test('isEmptyObject', () => {
		assert(!types.isEmptyObject(undefined));
		assert(!types.isEmptyObject(null));
		assert(!types.isEmptyObject('foo'));
		assert(!types.isEmptyObject(5));
		assert(!types.isEmptyObject(true));
		assert(!types.isEmptyObject([]));
		assert(!types.isEmptyObject([1, 2, '3']));
		assert(!types.isEmptyObject(/test/));
		assert(!types.isEmptyObject(new RegExp('')));
		assert(!types.isEmptyObject(new Date()));
		assert(!types.isEmptyObject(assert));
		assert(!types.isEmptyObject(function foo() { /**/ }));
		assert(!types.isEmptyObject({ foo: 'bar' }));

		assert(types.isEmptyObject({}));
	});
Example #29
0
 alexa.spoken("Dumb", function (error: any, response: any) {
     assert(error !== undefined);
     assert(error.message, "Unable to match utterance: Dumb to an intent. Try a different utterance, or explicitly set the intent");
     done();
 });
Example #30
0
			promises.push(delayer.trigger(factory).then(undefined, () => { assert(true, 'yes, it was cancelled'); }));