-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
51 lines (32 loc) · 942 Bytes
/
tests.py
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
49
50
51
import unittest
from loop import Loop
GLOBAL_TEN = 10
class LoopTestCase(unittest.TestCase):
def test_simple_loop(self):
iters = []
class For(Loop):
x = 0; x < 10; ++x
iters.append(x)
self.assertEqual(iters, list(range(10)))
def test_global_access(self):
iters = []
class For(Loop):
x = 0; x < GLOBAL_TEN; ++x
iters.append(x)
self.assertEqual(iters, list(range(10)))
def test_never_enter_loop(self):
iters = []
class For(Loop):
x = 0; x > 100; ++x
iters.append(x)
self.assertEqual(iters, [])
def test_continue(self):
iters = []
class For(Loop):
x = 0; x < 5; ++x
if x == 2:
continue_()
iters.append(x)
self.assertEqual(iters, [0, 1, 3, 4])
if __name__ == '__main__':
unittest.main()