From 2f2b518d4a228d59d39b195efbebdf9ec5311c76 Mon Sep 17 00:00:00 2001 From: GoshaZotov <Igor.Zotov@onlyoffice.com> Date: Thu, 25 May 2017 17:22:26 +0300 Subject: [PATCH] add unit-test for cot/coth formula --- cell/.unit-tests/FormulaTests.js | 77 ++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/cell/.unit-tests/FormulaTests.js b/cell/.unit-tests/FormulaTests.js index 03c4aec14..ea5d4c998 100644 --- a/cell/.unit-tests/FormulaTests.js +++ b/cell/.unit-tests/FormulaTests.js @@ -611,6 +611,83 @@ $( function () { ok( oParser.parse() ); strictEqual( oParser.calculate().getValue(), Math.atanh(1 / 6) ); } ); + + test( "Test: \"COT(30)\"", function () { + oParser = new parserFormula( 'COT(30)', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue().toFixed(3) - 0, -0.156 ); + } ); + + test( "Test: \"COT(0)\"", function () { + oParser = new parserFormula( 'COT(0)', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue(), "#DIV/0!" ); + } ); + + //> Math.pow(2, 27) + test( "Test: \"COT(1000000000)\"", function () { + oParser = new parserFormula( 'COT(1000000000)', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue(), "#NUM!" ); + } ); + + //ABS > Math.pow(2, 27) + test( "Test: \"COT(-1000000000)\"", function () { + oParser = new parserFormula( 'COT(-1000000000)', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue(), "#NUM!" ); + } ); + + test( "Test: \"COT(test)\"", function () { + oParser = new parserFormula( 'COT(test)', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue(), "#NAME?" ); + } ); + + test( "Test: \"COT('test')\"", function () { + oParser = new parserFormula( 'COT("test")', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue(), "#VALUE!" ); + } ); + + test( "Test: \"COTH(2)\"", function () { + oParser = new parserFormula( 'COTH(2)', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue().toFixed(3) - 0, 1.037 ); + } ); + + test( "Test: \"COTH(0)\"", function () { + oParser = new parserFormula( 'COTH(0)', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue(), "#DIV/0!" ); + } ); + + //> Math.pow(2, 27) + test( "Test: \"COTH(1000000000)\"", function () { + oParser = new parserFormula( 'COTH(1000000000)', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue(), 1 ); + } ); + + //ABS > Math.pow(2, 27) + test( "Test: \"COTH(-1000000000)\"", function () { + oParser = new parserFormula( 'COTH(-1000000000)', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue(), -1 ); + } ); + + test( "Test: \"COTH(test)\"", function () { + oParser = new parserFormula( 'COTH(test)', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue(), "#NAME?" ); + } ); + + test( "Test: \"COTH('test')\"", function () { + oParser = new parserFormula( 'COTH("test")', "A1", ws ); + ok( oParser.parse() ); + strictEqual( oParser.calculate().getValue(), "#VALUE!" ); + } ); + test( "Test: \"ARABIC('LVII')\"", function () { oParser = new parserFormula( 'ARABIC("LVII")', "A1", ws ); ok( oParser.parse() ); -- 2.30.9