Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.

Commit 4a1a6d8

Browse files
committed
add tests for kray util
1 parent 83ae741 commit 4a1a6d8

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

test/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@
7272
<script src="kpoint.js"></script>
7373
<script src="../utils/kline.js"></script>
7474
<script src="kline.js"></script>
75+
<script src="../utils/kray.js"></script>
76+
<script src="kray.js"></script>
7577
<script src="../utils/answer-types.js"></script>
7678
<script src="answer-types.js"></script>
7779
<script src="../utils/rational-expressions.js"></script>

test/kray.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
(function() {
2+
module("kray");
3+
4+
var ray = KhanUtil.kray;
5+
6+
asyncTest('two identical rays should be equal', 1, function() {
7+
var result = ray.equal([[0, 0], [1, 0]], [[0, 0], [2, 0]]);
8+
strictEqual(result, true);
9+
start();
10+
});
11+
12+
asyncTest('two rays with different directions should not be equal', 1, function() {
13+
var result = ray.equal([[0, 0], [1, 0]], [[0, 0], [0, 1]]);
14+
strictEqual(result, false);
15+
start();
16+
});
17+
18+
asyncTest('two parallel rays should not be equal', 1, function() {
19+
var result = ray.equal([[0, 0], [1, 0]], [[0, 1], [1, 1]]);
20+
strictEqual(result, false);
21+
start();
22+
});
23+
24+
asyncTest('two rays with different endpoint should not be equal', 1, function() {
25+
var result = ray.equal([[0, 0], [2, 0]], [[1, 0], [2, 0]]);
26+
strictEqual(result, false);
27+
start();
28+
});
29+
30+
})();

0 commit comments

Comments
 (0)