-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtree_test.py
executable file
·69 lines (55 loc) · 1.9 KB
/
tree_test.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env python
import angle
from parser_test_helper import *
import ast_magic
context.use_tree = True
class TreeTest(ParserBaseTest, unittest.TestCase):
def test_num(self):
assert_result_emitted("1", kast.kast.Num(1))
def test_method4(self):
# init('how to integrate a bug\n test\n ok')
init('how to integrate a bug\n test\nok')
assert (parser.method_definition())
def _test_block(self):
init(
'let the initial value of I be x;\n\n step size is the length of the interval,\n divided by the number of steps\n\n var x = 8;')
parser.block()
def _test_while(self):
parse('i=0;y=5;while i is smaller or less then y do\n increase i by 4;\n done')
assert_equals(the.variableValues['i'], 8)
def _test_while2(self):
init(
'while i is smaller or less then y do\n evaluate the function at point I\n add the result to the sum\n increase I by the step size\ndone')
parser.looper()
def _test_setter3(self):
init('step size is the length of the interval, divided by the number of steps')
parser.setter()
def test_looper(self):
skip()
parse('i=1;y=2;')
init('while i is smaller or equal y do\ni++\nend')
parser.loops()
init('while i is smaller or equal than y do\ni++\nend')
parser.loops()
def test_then_typo(self):
skip()
parse('while i is smaller or equal y then do\nyawn\nend')
skip()
parse('while i is smaller or equal then y do\nyawn\nend')
def test_method_call(self):
skip()
init('evaluate the function at point I')
def test_algebra_NOW(self):
# skip('test_algebra_NOW, DONT SKIP!')
assert_result_is('1+3/4.0', 1.75)
assert_result_is('1.0+3/4.0', 1.75)
assert_result_is('1.0+3/4', 1.75)
assert_result_is('1+3/4', 1.75)
def test_fraction(self):
skip()
assert_result_is('1 3/4', 1.75)
def test_algebra(self):
init('2*(3+10)')
ok = parser.algebra()
print(('Parsed input as %s !' % ok))
assert_equals(ok, 26)