forked from PencilCode/jquery-turtle
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathpause.html
More file actions
48 lines (48 loc) · 1.2 KB
/
pause.html
File metadata and controls
48 lines (48 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<script src="lib/qunit.js"></script>
<link href="lib/qunit.css" rel="stylesheet">
<script src="lib/jquery.js"></script>
<script src="../jquery-turtle.js"></script>
<body>
<div id="qunit"></div>
<script>
eval($.turtle());
module("Pause test.");
asyncTest("Moves a few turtles, having each pause for the other.", function() {
speed(100);
var a = new Turtle(red);
var b = new Turtle(blue);
a.pause(0.1);
a.plan(function() {
equal(a.getxy()[1], 0);
equal(round(b.getxy()[1]), 0);
equal(getxy()[0], 0);
ok(b.direction() != 0); // b should have started turning without pause.
});
a.fd(100);
b.rt(180);
b.pause(a);
b.plan(function() {
equal(round(a.getxy()[1]), 100);
equal(getxy()[0], 0);
});
b.fd(100);
equal(a.getxy()[1], 0);
equal(b.getxy()[1], 0);
equal(getxy()[0], 0);
pause(b);
move(100);
plan(function() {
equal(round(a.getxy()[1]), 100);
equal(round(b.getxy()[1]), -100);
equal(round(getxy()[0]), 100);
a.rt(90);
$('.turtle').bk(50);
$(document).pause($('.turtle')).plan(function() {
equal(round(a.getxy()[0]), -50);
equal(round(b.getxy()[1]), -50);
equal(round(getxy()[1]), -50);
start();
});
});
});
</script>