當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript assert類代碼示例

本文整理匯總了TypeScript中assert的典型用法代碼示例。如果您正苦於以下問題:TypeScript assert類的具體用法?TypeScript assert怎麽用?TypeScript assert使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了assert類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: assert

				promises.push(delayer.trigger(factory).then(() => { assert.equal(result, 1); assert(!delayer.isTriggered()); }));
開發者ID:VishalMadhvani,項目名稱:vscode,代碼行數:1,代碼來源:async.test.ts

示例2: assert

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*");
開發者ID:Akylas,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:node-tests.ts

示例3: it

 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");
 });
開發者ID:bespoken,項目名稱:bst,代碼行數:6,代碼來源:bst-virtual-alexa-test.ts

示例4: setTimeout

 setTimeout(() => {
   assert(!debuglet.activeBreakpointMap.test);
   debuglet.stop();
   scope.done();
   done();
 }, 1100);
開發者ID:GoogleCloudPlatform,項目名稱:cloud-debug-nodejs,代碼行數:6,代碼來源:test-debuglet.ts

示例5: assert

 next: (location: Location) => {
   assert(location.pathname);
   done();
 },
開發者ID:ntilwalli,項目名稱:cyclejs,代碼行數:4,代碼來源:common.ts

示例6: function

	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);
	}
開發者ID:openfl,項目名稱:openfl,代碼行數:66,代碼來源:BitmapDataTest.ts

示例7: function

 stats.record("", AccessType.REQUEST_DROPPED, function (error: Error) {
     assert(!error);
     done();
 });
開發者ID:bespoken,項目名稱:bst,代碼行數:4,代碼來源:statistics-test.ts

示例8: it

 it("#isRuleModule", function() {
     assert(isRuleModule(FixerRule));
     assert(isRuleModule(LinterRule));
     assert(!isRuleModule(FixerOnlyRule));
     assert(!isRuleModule(SimpleModule));
 });
開發者ID:textlint,項目名稱:textlint,代碼行數:6,代碼來源:rule-creator-helper-test.ts

示例9: testContentType

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);
}
開發者ID:dmytrobanasko,項目名稱:google-api-nodejs-client,代碼行數:6,代碼來源:test.transporters.ts

示例10: assert

		walker.readStdout(cmd1, 'utf8', /*isRipgrep=*/false, (err1, stdout1) => {
			assert.equal(err1, null);
			assert(outputContains(stdout1, file0), stdout1);
			assert(!outputContains(stdout1, file1), stdout1);
			done();
		});
開發者ID:jumpinjackie,項目名稱:sqlopsstudio,代碼行數:6,代碼來源:search.test.ts


注:本文中的assert類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。