本文整理汇总了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()); }));
示例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*");
示例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");
});
示例4: setTimeout
setTimeout(() => {
assert(!debuglet.activeBreakpointMap.test);
debuglet.stop();
scope.done();
done();
}, 1100);
示例5: assert
next: (location: Location) => {
assert(location.pathname);
done();
},
示例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);
}
示例7: function
stats.record("", AccessType.REQUEST_DROPPED, function (error: Error) {
assert(!error);
done();
});
示例8: it
it("#isRuleModule", function() {
assert(isRuleModule(FixerRule));
assert(isRuleModule(LinterRule));
assert(!isRuleModule(FixerOnlyRule));
assert(!isRuleModule(SimpleModule));
});
示例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);
}
示例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();
});