當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。