From d160837c0a0f137472f119b38a56665c2dad9fdf Mon Sep 17 00:00:00 2001 From: Borys Levytskyi Date: Sat, 11 Apr 2015 22:13:51 +0300 Subject: [PATCH] Improved unit tests --- tests/domain/expressionSpec.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/domain/expressionSpec.js b/tests/domain/expressionSpec.js index 164462b..045f697 100644 --- a/tests/domain/expressionSpec.js +++ b/tests/domain/expressionSpec.js @@ -22,7 +22,7 @@ describe("expression parse", function() { }; it("should parse expressions", function() { - var input, expr; + var input; for(input in expressionCases) { var actual = expression.parse(input); var expected = expressionCases[input]; @@ -42,7 +42,7 @@ describe("expression parse", function() { }; it("should parse hexadecimal expressions", function() { - var input, expr, i; + var input, i; for(input in listCases) { var actual = expression.parse(input); var expected = listCases[input]; @@ -54,17 +54,26 @@ describe("expression parse", function() { }); }); -describe('operands', function() { +describe('parse operands', function() { var hexOperand = expression.parseOperand('0x10'); var decOperand = expression.parseOperand('10'); + rundOperandsTest(hexOperand, decOperand); +}); +describe('create operands', function() { + + var hexOperand = expression.createOperand(0x10, 'hex'); + var decOperand = expression.createOperand(10, 'dec'); + rundOperandsTest(hexOperand, decOperand); +}); + +function rundOperandsTest(hexOperand, decOperand) { it('should remember input form', function() { expect(hexOperand.input).toBe('0x10'); expect(decOperand.input).toBe('10'); }); - it('should return integer value', function () { expect(hexOperand.value).toBe(0x10); expect(decOperand.value).toBe(10); @@ -76,11 +85,12 @@ describe('operands', function() { expect(hexOperand.dec).toBe('16'); expect(hexOperand.bin).toBe('10000'); expect(hexOperand.hex).toBe('0x10'); + expect(hexOperand.other).toBe('16'); expect(decOperand.kind).toBe('dec'); expect(decOperand.dec).toBe('10'); expect(decOperand.bin).toBe('1010'); expect(decOperand.hex).toBe('0xa'); + expect(decOperand.other).toBe('0xa'); }); - -}); \ No newline at end of file +} \ No newline at end of file