From e1eb4995d219c8ac9977d78feb89164218855510 Mon Sep 17 00:00:00 2001 From: TonyYang Date: Thu, 8 Sep 2016 00:24:06 +0800 Subject: [PATCH 1/2] Clean up assert module --- node/node-tests.ts | 52 +++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/node/node-tests.ts b/node/node-tests.ts index b250a732dccbd1..40bc6d82f11cc2 100644 --- a/node/node-tests.ts +++ b/node/node-tests.ts @@ -26,22 +26,44 @@ import * as timers from "timers"; // 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 Tests : https://nodejs.org/api/assert.html /// +////////////////////////////////////////////////////////// -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*"); +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 + + assert.notDeepStrictEqual({ x: { y: "3" } }, { x: { y: 3 } }, "uses === comparator"); + + // TODO: assert.notDeepStrictEqual + + // TODO: assert.notEqual + + assert.notStrictEqual(2, "2", "uses === comparator"); + + // TODO: assert.ok + + // TODO: assert.strictEqual + + assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT"); + } +} //////////////////////////////////////////////////// /// Events tests : http://nodejs.org/api/events.html From 97c9fd0050996bf5cbed0eea801477efa12fd289 Mon Sep 17 00:00:00 2001 From: TonyYang Date: Thu, 8 Sep 2016 00:33:38 +0800 Subject: [PATCH 2/2] Clean up assert module --- node/node-4-tests.ts | 54 +++++++++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 16 deletions(-) diff --git a/node/node-4-tests.ts b/node/node-4-tests.ts index 5a25f1fa20b938..3c177bcc7708fd 100644 --- a/node/node-4-tests.ts +++ b/node/node-4-tests.ts @@ -24,22 +24,44 @@ import * as string_decoder from "string_decoder"; // 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*"); +////////////////////////////////////////////////////////// +/// 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 + + assert.notDeepStrictEqual({ x: { y: "3" } }, { x: { y: 3 } }, "uses === comparator"); + + // TODO: assert.notDeepStrictEqual + + // TODO: assert.notEqual + + assert.notStrictEqual(2, "2", "uses === comparator"); + + // TODO: assert.ok + + // TODO: assert.strictEqual + + assert.throws(() => { throw "a hammer at your face"; }, undefined, "DODGED IT"); + } +} //////////////////////////////////////////////////// /// Events tests : http://nodejs.org/api/events.html