/*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

javascript的基础知识相关推荐

  1. JavaScript笔记 基础知识总结2

    本文主要概括总结javascript的Object 1.产生Object的方法: 第一种: 1 var obj = {name:"lishan",age:23,email:&quo ...

  2. JavaScript入门基础知识

    JavaScript入门基础学习 1.三种引用JavaScript的方式 1.1行内式 <input type = "button" value="点我试试&quo ...

  3. javascript一些基础知识

    1.javascript的数组API Js代码 //定义数组 var pageIds = new Array(); pageIds.push('A'); 数组长度 pageIds.length; // ...

  4. 【前端】【JavaScript】基础知识

    文章目录 JavaScript 基础阶段 一. 初识 JavaScript (一) JavaScript 的作用 (二) HTML/CSS/JS 的关系 (三) 浏览器执行 JS 简介 (四) JS ...

  5. JavaScript正则表达式基础知识汇总

    一.创建正则对象: 1.构造函数RegExp创建正则对象 1 var pattern = new RegExp('s$'); //pattern匹配以s结尾的字符串 2.使用正则直接量 1 var p ...

  6. JavaScript事件基础知识总结【思维导图】

    var EventUtil = {//注册事件 addHandler: function(element, type, handler){if (element.addEventListener){e ...

  7. JavaScript的基础学习篇

    在学习JavaScript之前,我们应该先认识一下什么是脚本语言(Scripting Language)? 脚本语言就是一种简单的程序.在运行之前不需要先进行编译,所有的代码都是在客户程序中直接被执行 ...

  8. JavaScript语言基础(一)

    1.通过学习JavaScript语言基础,我们应该了解关键字与标识符.掌握JavaScript常用的数据类型.熟悉常量与变量.熟悉运算符和表达式. JavaScript语言基础知识框架如下图所示: 此 ...

  9. Javascript夯实基础01

    今天夯实Javascript的基础知识,并进行记录. Javascript null类型错误bug Javascript中的类型中存在一个bug,当我们使用typeof null表达式时,返回的结果是 ...

最新文章

  1. 小型工作室创业项目_为什么新开发人员应该在小型创业公司工作
  2. 华南理工深度学习与神经网络期末考试_深度学习基础:单层神经网络之线性回归...
  3. 3创建型模式之单例模式
  4. 【PAT乙级】1025 反转链表 (25 分)
  5. Making Sense of Cryptoeconomics
  6. Python实现kNN算法
  7. JDBC Statement PrepareStatement
  8. leetcode 213. House Robber II | 213. 打家劫舍 II(Java)
  9. php ajax files 空,javascript - ajax上传文件后台使用$_files接受为空
  10. 电子学会图形化三级编程题解析含答案:冬天下雪了
  11. AJAX框架大全 (AJAX Frameworks)
  12. C#使用struct直接转换下位机数据的示例代码
  13. 我在名牌大学毕业后的经历
  14. 苹果商店如何申请退款
  15. 微众银行积极参与公益事业 发扬志愿者精神
  16. kubernetes 从入门到实践
  17. 巴西柔术第三课:封闭式防守的降服技术
  18. 福神喜神贵神财神方位查询
  19. 人类的15个欲望与游戏设计
  20. 格式化字符串漏洞利用 一、引言

热门文章

  1. Python工具 | 4个好用的开源 Python 下载器
  2. 好程序员HTML5大前端分享常用开发工具大集合
  3. Flutter学习之Dart语法特性
  4. HttpContext.Current.Session ,出现未将对象引用设置到实例上
  5. IBM整合管理服务:云时代驱动IT服务创新
  6. 【C语言】关于结构体最后的长度为0或1数组的思考
  7. HBA and WWN
  8. gSTM:Ubuntu 上的 SSH Tunneling 图形界面管理工具
  9. VBA:指定なフォルダしたのすべてのファイル名
  10. 【刘文彬】RPC的基础:调研EOS插件http_plugin