Commit 7ed679d2 authored by GoshaZotov's avatar GoshaZotov

add CSC formula

parent 55fff0d2
......@@ -687,6 +687,44 @@ $( function () {
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#VALUE!" );
} );
test( "Test: \"CSC(15)\"", function () {
oParser = new parserFormula( 'CSC(15)', "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue().toFixed(3) - 0, 1.538 );
} );
test( "Test: \"CSC(0)\"", function () {
oParser = new parserFormula( 'CSC(0)', "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#DIV/0!" );
} );
//> Math.pow(2, 27)
test( "Test: \"CSC(1000000000)\"", function () {
oParser = new parserFormula( 'CSC(1000000000)', "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#NUM!" );
} );
//ABS > Math.pow(2, 27)
test( "Test: \"CSC(-1000000000)\"", function () {
oParser = new parserFormula( 'CSC(-1000000000)', "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#NUM!" );
} );
test( "Test: \"CSC(test)\"", function () {
oParser = new parserFormula( 'CSC(test)', "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#NAME?" );
} );
test( "Test: \"CSC('test')\"", function () {
oParser = new parserFormula( 'CSC("test")', "A1", ws );
ok( oParser.parse() );
strictEqual( oParser.calculate().getValue(), "#VALUE!" );
} );
test( "Test: \"ARABIC('LVII')\"", function () {
oParser = new parserFormula( 'ARABIC("LVII")', "A1", ws );
......
......@@ -69,7 +69,7 @@
cFormulaFunctionGroup['Financial'].push(cPDURATION, cRRI);
cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || [];
cFormulaFunctionGroup['Mathematic'].push(cAGGREGATE, cBASE, cCEILING_MATH, cCEILING_PRECISE,
cCOMBINA, cCSC, cCSCH, cDECIMAL, cFLOOR_MATH, cFLOOR_PRECISE, cMUNIT, cSEC, cSECH);
cCOMBINA, cCSCH, cDECIMAL, cFLOOR_MATH, cFLOOR_PRECISE, cMUNIT, cSEC, cSECH);
cFormulaFunctionGroup['LookupAndReference'] = cFormulaFunctionGroup['LookupAndReference'] || [];
cFormulaFunctionGroup['LookupAndReference'].push(cFORMULATEXT);
cFormulaFunctionGroup['Information'] = cFormulaFunctionGroup['Information'] || [];
......@@ -365,18 +365,6 @@
cCOVARIANCE_S.prototype = Object.create(cBaseFunction.prototype);
cCOVARIANCE_S.prototype.constructor = cCOVARIANCE_S;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cCSC() {
cBaseFunction.call(this, "CSC");
this.isXLFN = true;
}
cCSC.prototype = Object.create(cBaseFunction.prototype);
cCSC.prototype.constructor = cCSC;
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
......@@ -57,7 +57,7 @@
cFormulaFunctionGroup['Mathematic'] = cFormulaFunctionGroup['Mathematic'] || [];
cFormulaFunctionGroup['Mathematic'].push(cABS, cACOS, cACOSH, cACOT, cACOTH, cARABIC, cASIN, cASINH, cATAN, cATAN2, cATANH, cCEILING,
cCOMBIN, cCOS, cCOSH, cCOT, cCOTH, cDEGREES, cECMA_CEILING, cEVEN, cEXP, cFACT, cFACTDOUBLE, cFLOOR, cGCD, cINT,
cCOMBIN, cCOS, cCOSH, cCOT, cCOTH, cCSC, cDEGREES, cECMA_CEILING, cEVEN, cEXP, cFACT, cFACTDOUBLE, cFLOOR, cGCD, cINT,
cISO_CEILING, cLCM, cLN, cLOG, cLOG10, cMDETERM, cMINVERSE, cMMULT, cMOD, cMROUND, cMULTINOMIAL, cODD, cPI,
cPOWER, cPRODUCT, cQUOTIENT, cRADIANS, cRAND, cRANDBETWEEN, cROMAN, cROUND, cROUNDDOWN, cROUNDUP, cSERIESSUM,
cSIGN, cSIN, cSINH, cSQRT, cSQRTPI, cSUBTOTAL, cSUM, cSUMIF, cSUMIFS, cSUMPRODUCT, cSUMSQ, cSUMX2MY2, cSUMX2PY2,
......@@ -1005,6 +1005,67 @@
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
*/
function cCSC() {
this.name = "CSC";
this.value = null;
this.argumentsCurrent = 0;
}
cCSC.prototype = Object.create(cBaseFunction.prototype);
cCSC.prototype.constructor = cCSC;
cCSC.prototype.argumentsMin = 1;
cCSC.prototype.argumentsMax = 1;
cCSC.prototype.isXLFN = true;
cCSC.prototype.numFormat = AscCommonExcel.cNumFormatNone;
cCSC.prototype.Calculate = function (arg) {
var arg0 = arg[0];
var maxVal = Math.pow(2, 27);
if (cElementType.cellsRange === arg0.type || cElementType.cellsRange3D === arg0.type) {
arg0 = arg0.cross(arguments[1]);
}
arg0 = arg0.tocNumber();
if (cElementType.error === arg0.type) {
return this.value = arg0;
} else if (cElementType.array === arg0.type) {
arg0.foreach(function (elem, r, c) {
if (cElementType.number === elem.type) {
if(0 === elem.getValue()){
this.array[r][c] = new cError(cErrorType.division_by_zero);
}
else if (Math.abs(elem.getValue()) >= maxVal) {
this.array[r][c] = new cError(cErrorType.not_numeric);
}
else{
var a = 1 / Math.sin(elem.getValue());
this.array[r][c] = isNaN(a) ? new cError(cErrorType.not_numeric) : new cNumber(a);
}
} else {
this.array[r][c] = new cError(cErrorType.wrong_value_type);
}
});
return this.value = arg0;
} else {
if(0 === arg0.getValue()){
return this.value = new cError(cErrorType.division_by_zero);
}
else if (Math.abs(arg0.getValue()) >= maxVal) {
return this.value = new cError(cErrorType.not_numeric);
}
var a = 1 / Math.sin(arg0.getValue());
return this.value = isNaN(a) ? new cError(cErrorType.not_numeric) : new cNumber(a);
}
};
cCSC.prototype.getInfo = function () {
return {
name: this.name, args: "( x )"
};
};
/**
* @constructor
* @extends {AscCommonExcel.cBaseFunction}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment