Qunit Front-end script test Cases

Source: Internet
Author: User

First refer to the Qunit Test framework file

<link rel= "stylesheet" href= "Qunit-1.22.0.css" >
<script src= "Qunit-1.22.0.js" ></script>

<div id= "Qunit" ></div>
<div id= "Qunit-fixture" ></div>

<script>
function Triangle (A, B, c) {
if (a && b && c && a > 0 && B > 0 && C > 0 && a < (b + c) &amp ;& B < (a + c) && C < (A + b)) {
if (! ( This instanceof Triangle)) {
return new Triangle (A, B, c);
}
THIS.A = A;
this.b = b;
THIS.C = C;
This.s=function () {
var p = (THIS.A+THIS.B+THIS.C)/2;
Return Math.sqrt (p* (P-THIS.A) * (p-this.b) * (P-THIS.C));
}
return true;
}
return false;
}
Triangle.prototype.zj=function () {
Return!! ((THIS.A==THIS.B&AMP;&AMP;THIS.A!=THIS.C) | | (this.a==this.c&&this.a!=this.b))
}
Triangle.prototype.qd=function () {
Return!! (THIS.A==THIS.B&AMP;&AMP;THIS.A==THIS.C)
}
Qunit.test ("Test is a triangle", function (assert) {
Assert.equal (MATH.SQRT (8) *math.sqrt (8), 8, "math.sqrt (8)");
Assert.equal (Math.ceil (Triangle (MATH.SQRT (8), 2,2). S ()), 2, "Area 2");
Assert.ok (Triangle ("1", 1, 1), "is a triangle");
Assert.ok (Triangle (MATH.SQRT (8), 2,2), "is a triangle");

});
Qunit.test ("Test triangle Type", function (assert) {
Assert.ok ("1", "Triangle"). ZJ (), "right triangle");
Assert.ok ("1", "Triangle"). QD (), "congruent triangle");
Assert.ok (Triangle (MATH.SQRT (8), 2,2). ZJ (), "right triangle");
Assert.ok (Triangle (MATH.SQRT (8), 2,2). QD (), "congruent triangles");
});
</script>

This is a test case for judging the type of triangle, the following is the result of the operation:

Qunit Front-end script test Cases

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.