-
-
Save hemanth22/27f2f2deb408394679e4a1c2d667452b to your computer and use it in GitHub Desktop.
additionWithAssertionsjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var assert = require('assert'); | |
function addTwoNumbers(x, y) { | |
return x + y; | |
} | |
function testAddTwoNumbers() { | |
var x = 5; | |
var y = 1; | |
var sum1 = x + y; | |
var sum2 = addTwoNumbers(x, y); | |
console.log('addTwoNumbers() should return the sum of its two parameters.'); | |
console.log('Expect ' + sum1 + ' to equal ' + sum2 + '.'); | |
try { | |
assert.equal(sum1, sum2); | |
console.log('Passed.'); | |
} catch (error) { | |
console.error('Failed.'); | |
} | |
} | |
testAddTwoNumbers(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment