当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript power-assert.throws函数代码示例

本文整理汇总了TypeScript中power-assert.throws函数的典型用法代码示例。如果您正苦于以下问题:TypeScript throws函数的具体用法?TypeScript throws怎么用?TypeScript throws使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了throws函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: context

 context('number', () => {
   const sample = new SampleNumber(1)
   assert(sample.val === 1)
   assert.throws(() => {
     sample.val = 2
   })
 })
开发者ID:namikingsoft,项目名称:snotido,代码行数:7,代码来源:freeze.spec.ts

示例2: it

 it('should work with exception', function() {
   assert.throws(function() {
     var naughty = new Obs(function() {
       throw "anything"
     })
   })
   assert(caller.callers.length === 1)
 })
开发者ID:HerringtonDarkholme,项目名称:rectangular,代码行数:8,代码来源:ok.ts

示例3: assert

import assert from "power-assert";

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.deepStrictEqual([{a:1}], [{a:1}], "uses === comparator");

assert.notDeepStrictEqual([{a:1}], [{a:1}], "uses === comparator");

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

assert.doesNotThrow(() => {
    if (false) {
        throw "a hammer at your face";
    }
}, undefined, "What the...*crunch*");


var customizedAssert1 = assert.customize({
    output: {
        maxDepth: 2
    }
});
开发者ID:behzad888,项目名称:DefinitelyTyped,代码行数:30,代码来源:power-assert-tests.ts

示例4: it

 it("should throws an error.", () => {
     assert.throws(() => none.get, error => {
         assert(error.message === "No such element.");
         return true;
     });
 });
开发者ID:shogogg,项目名称:ts-option,代码行数:6,代码来源:spec.ts

示例5: it

 it('should throw an Error when the value does not match any cases', () => {
   let f = () => match<number, string>(2, when => when(1, () => 'One'));
   assert.throws(f, 'MatchError: Given value does not match any cases');
 });
开发者ID:shogogg,项目名称:mcz,代码行数:4,代码来源:spec.ts

示例6: it

    it('generator#throw(e: any)', () => {
        const g = Uint32LCG.generator(Uint32LCG.GEN3_ARG, 0x00000000);

        assert.throws(() => g.throw(new Error()), '');
        assert.throws(() => g.throw(new Error('message')), 'message');
    });
开发者ID:mizdra,项目名称:poke-lcg,代码行数:6,代码来源:generator.test.ts

示例7: it

 it('invalid format', () => {
     assert.throws(() => jp.parse('hoge'), /^Error: Invalid JSON-Pointer format:/);
 });
开发者ID:horiuchi,项目名称:dtsgenerator,代码行数:3,代码来源:jsonPointer_test.ts


注:本文中的power-assert.throws函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。