Commit e4c3ee23 authored by GoshaZotov's avatar GoshaZotov

add cISO_CEILING formula

parent be268e1d
...@@ -810,7 +810,7 @@ $( function () { ...@@ -810,7 +810,7 @@ $( function () {
strictEqual( oParser.calculate().getValue(), -4, 'FLOOR.MATH(-5.5, 2, -1)' ); strictEqual( oParser.calculate().getValue(), -4, 'FLOOR.MATH(-5.5, 2, -1)' );
} ); } );
test( "Test: \"CEILING.PRECISE\"", function () { test( "Test: \"CEILING.MATH\"", function () {
oParser = new parserFormula( 'CEILING.MATH(24.3, 5)', "A1", ws ); oParser = new parserFormula( 'CEILING.MATH(24.3, 5)', "A1", ws );
ok( oParser.parse(), 'CEILING.MATH(24.3, 5)' ); ok( oParser.parse(), 'CEILING.MATH(24.3, 5)' );
strictEqual( oParser.calculate().getValue(), 25, 'CEILING.MATH(24.3, 5)' ); strictEqual( oParser.calculate().getValue(), 25, 'CEILING.MATH(24.3, 5)' );
...@@ -858,6 +858,32 @@ $( function () { ...@@ -858,6 +858,32 @@ $( function () {
strictEqual( oParser.calculate().getValue(), "#NAME?", 'CEILING.PRECISE(test)' ); strictEqual( oParser.calculate().getValue(), "#NAME?", 'CEILING.PRECISE(test)' );
} ); } );
test( "Test: \"ISO.CEILING\"", function () {
oParser = new parserFormula( 'ISO.CEILING(4.3)', "A1", ws );
ok( oParser.parse(), 'ISO.CEILING(4.3)' );
strictEqual( oParser.calculate().getValue(), 5, 'ISO.CEILING(4.3)' );
oParser = new parserFormula( 'ISO.CEILING(-4.3)', "A1", ws );
ok( oParser.parse(), 'ISO.CEILING(-4.3)' );
strictEqual( oParser.calculate().getValue(), -4, 'ISO.CEILING(-4.3)' );
oParser = new parserFormula( 'ISO.CEILING(4.3, 2)', "A1", ws );
ok( oParser.parse(), 'ISO.CEILING(4.3, 2)' );
strictEqual( oParser.calculate().getValue(), 6, 'ISO.CEILING(4.3, 2)' );
oParser = new parserFormula( 'ISO.CEILING(4.3,-2)', "A1", ws );
ok( oParser.parse(), 'ISO.CEILING(4.3,-2)' );
strictEqual( oParser.calculate().getValue(), 6, 'ISO.CEILING(4.3,-2)' );
oParser = new parserFormula( 'ISO.CEILING(-4.3,2)', "A1", ws );
ok( oParser.parse(), 'ISO.CEILING(-4.3,2)' );
strictEqual( oParser.calculate().getValue(), -4, 'ISO.CEILING(-4.3,2)' );
oParser = new parserFormula( 'ISO.CEILING(-4.3,-2)', "A1", ws );
ok( oParser.parse(), 'ISO.CEILING(-4.3,-2)' );
strictEqual( oParser.calculate().getValue(), -4, 'ISO.CEILING(-4.3,-2)' );
} );
test( "Test: \"ARABIC('LVII')\"", function () { test( "Test: \"ARABIC('LVII')\"", function () {
oParser = new parserFormula( 'ARABIC("LVII")', "A1", ws ); oParser = new parserFormula( 'ARABIC("LVII")', "A1", ws );
ok( oParser.parse() ); ok( oParser.parse() );
......
...@@ -1875,12 +1875,50 @@ ...@@ -1875,12 +1875,50 @@
* @constructor * @constructor
* @extends {AscCommonExcel.cBaseFunction} * @extends {AscCommonExcel.cBaseFunction}
*/ */
//TODO точная копия функции CEILING.PRECISE. зачем excel две одинаковые функции?
function cISO_CEILING() { function cISO_CEILING() {
cBaseFunction.call(this, "ISO_CEILING"); this.name = "ISO.CEILING";
this.value = null;
this.argumentsCurrent = 0;
} }
cISO_CEILING.prototype = Object.create(cBaseFunction.prototype); cISO_CEILING.prototype = Object.create(cBaseFunction.prototype);
cISO_CEILING.prototype.constructor = cISO_CEILING; cISO_CEILING.prototype.constructor = cISO_CEILING;
cISO_CEILING.prototype.argumentsMin = 1;
cISO_CEILING.prototype.argumentsMax = 2;
//cISO_CEILING.prototype.isXLFN = true;
cISO_CEILING.prototype.Calculate = function (arg) {
var argClone = [];
argClone[0] = this._checkCAreaArg(arg[0], arguments[1]);
argClone[1] = this._checkCAreaArg(arg[1], arguments[1]);
argClone[0] = argClone[0].tocNumber();
argClone[1] = argClone[1] ? argClone[1].tocNumber() : new cNumber(1);
var argError;
if(false !== (argError = this._checkErrorArg(argClone))){
return this.value = argError;
}
function floorHelper(argArray) {
var number = argArray[0];
var significance = argArray[1];
if (significance === 0 || number === 0) {
return new cNumber(0.0);
}
var absSignificance = Math.abs(significance);
var quotient = number / absSignificance;
return new cNumber(Math.ceil(quotient) * absSignificance);
}
return this.value = this._findArrayInNumberArguments(argClone, floorHelper);
};
cISO_CEILING.prototype.getInfo = function () {
return {
name: this.name, args: "( x, significance )"
};
};
/** /**
* @constructor * @constructor
......
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