/*module("基础知识测试-Math函数用法", {
setup : function() {
ok(true, "基础知识测试-Math函数用法-开始");
//with(this){n1=1.365};不能用with
this.n1 = 1.4637, this.n2 = 1.5073, this.n3 = 1.6537, this.n4 = 1.373,
this.n5 = -2.4037, this.n6 = -2.50, this.n7 = -2.5037, this.n8 = -2.602;
this.varstr = "n1=" + this.n1 + ",n2=" + this.n2 + ",n3=" + this.n3 + ",n4=" + this.n4 + ",n5=" + this.n5 + ",n6=" + this.n6 + ",n7=" + this.n7 + ",n8=" + this.n8
},
teardown : function() {
ok(true, "基础知识测试-Math函数用法-结束")
}
});
test("Math.round(number)测试", 10, function() {
equals(Math.round(this.n1), 1, 'n1:' + this.varstr);
equals(Math.round(this.n2), 2, 'n2:' + this.varstr);
equals(Math.round(this.n3), 2, 'n3:' + this.varstr);
equals(Math.round(this.n4), 1, 'n4:' + this.varstr);
equals(Math.round(this.n5), -2, 'n5:' + this.varstr);
equals(Math.round(this.n6), -2, 'n6:' + this.varstr);
equals(Math.round(this.n7), -3, 'n7:' + this.varstr);
equals(Math.round(this.n8), -3, 'n:8' + this.varstr);
});
*/
module("贷款等额本息月还金额相关函数的测试", {
setup : function() {
ok(true, "基础知识测试-rRound函数用法-开始");
//with(this){n1=1.365};不能用with
this.n1 = 654321.4637, this.n2 = 654321.5073, this.n3 = 654321.6537, this.n4 = 654324.373,
this.n5 =654345.373, this.n6 = 654356.373,this.n7 = -654321.6037, this.n8 = 654321.36573;
this.varstr = "n1=" + this.n1 + ",n2=" + this.n2 + ",n3=" + this.n3 + ",n4=" + this.n4 + ",n5=" + this.n5 + ",n6=" + this.n6 + ",n7=" + this.n7 + ",n8=" + this.n8
},
teardown : function() {
ok(true, "基础知识测试-rRound函数用法-结束")
}
});
test("rRound(number)测试", 14, function() {
equals(rRound(this.n4,-1), 654320, 'n4- -1:' + this.varstr);
equals(rRound(this.n5,-1), 654350, 'n5- -1:' + this.varstr);
equals(rRound(this.n6,-1), 654360, 'n6- -1:' + this.varstr);
equals(rRound(this.n4,-2), 654300, 'n4- -2:' + this.varstr);
equals(rRound(this.n5,-2), 654300, 'n5- -2:' + this.varstr);
equals(rRound(this.n6,-2), 654400, 'n6- -2:' + this.varstr);
equals(rRound(this.n1,0), 654321, 'n1-0:' + this.varstr);
equals(rRound(this.n2,0), 654322, 'n2-0:' + this.varstr);
equals(rRound(this.n3,0), 654322, 'n3-0:' + this.varstr);
equals(rRound(this.n1,1), 654321.5, 'n1-1:' + this.varstr);
equals(rRound(this.n2,1), 654321.5, 'n2-1:' + this.varstr);
equals(rRound(this.n3,1), 654321.7, 'n3-1:' + this.varstr);
});
test("给yhje(je,cs,nll)传入金额、应还月数、利率,返回月还金额",5, function() {
equals(computeqt(150000, 108, 4.9), 1720.36, "说明:这里的次数用年数*12");
equals(computeqt(150000, 36, 4.45), 4458.68, "说明:这里的次数用年数*12");
});
test("给yhje(je,cs,nll)传入金额、应还月数、利率,返回月还金额",4, function() {
equals(yhje(150000, 108, 4.9), 1720.36, "说明:这里的次数用年数*12");
ok(Math.abs(yhje(150000, 36, 4.45) - 4458.68) < 0.02, "说明:这里的次数用年数*12");
equals(computeqt(150000, 36, 4.45), 4458.68, "说明:这里的次数用年数*12");
});
转载于:https://blog.51cto.com/ywb422/809644