-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfuture_test.py
More file actions
executable file
·60 lines (48 loc) · 1.83 KB
/
Copy pathfuture_test.py
File metadata and controls
executable file
·60 lines (48 loc) · 1.83 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
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
import angle
from parser_test_helper import *
class FutureTest:
def dont_yet_test_false_returns(self):
assert_result_is('if 1<2 then false else 4', 'false')
assert_result_is('if 1<2 then false else 4', False)
def test_if_statement(self):
init('if x is smaller than three then everything is fine;')
parser.if_then()
assert_equals(variables['everything'], 'fine')
parse('x=2;if x is smaller than three then everything is good;')
print((variables['everything']))
assert_equals(variables['everything'], 'good')
def test_repeat_until(self):
parse('repeat until x>4: x++')
assert_equals(variables['x'], 5)
def test_try_until(self):
parse('try until x>4: x++')
assert_equals(variables['x'], 5)
parse('try while x<4: x++')
assert_equals(variables['x'], 4)
parse('try x++ until x>4')
assert_equals(variables['x'], 5)
parse('try x++ while x<4')
assert_equals(variables['x'], 4)
parse('increase x until x>4')
assert_equals(variables['x'], 5)
def test_property_setter(self):
parse('new circle;circle.color=green')
assert_equals('circle.color', 'green')
def test_local_variables_changed_by_subblocks(self):
parse('x=2;def test\nx=1\nend\ntest')
init('x=2 or x=1')
assert(parser.condition_tree())
assert('x=2')
parse('x=1;x=2;')
assert('x=2')
parse('x=1;while x<2 do x=2;')
assert('x=2')
def test_loops(self):
parse('beep three times')
parse('repeat three times: beep; okay')
parse('repeat three times: beep')
def test_action_n_times(self):
parse("2 times say 'hello'")
parse("say 'hello' 2 times")
parse("puts 'hello' 2 times")