-
Notifications
You must be signed in to change notification settings - Fork 0
/
AllTests.py
60 lines (48 loc) · 1.45 KB
/
AllTests.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
import ast
from NoneVisitor import *
def testAssert(assertion, testName):
if assertion:
print testName + '\t\t\t' + 'passed'
else:
print testName + '\t\t\t' + 'FAILED'
def countErrors(fileName):
parsedFile = ast.parse(open(fileName, 'r').read())
x = NoneVisitor()
x.visit(parsedFile)
return x.numErrors()
def setNone():
fileName = './cases/Test3.py'
parsedFile = ast.parse(open(fileName, 'r').read())
x = NoneVisitor()
x.visit(parsedFile)
testAssert(x.numErrors() == 1, 'setNone')
def basicTest():
fileName = './cases/Test1.py'
parsedFile = ast.parse(open(fileName, 'r').read())
x = NoneVisitor()
x.visit(parsedFile)
testAssert(x.numErrors() == 1, 'basicTest')
def twoErrors():
fileName = './cases/Test2.py'
parsedFile = ast.parse(open(fileName, 'r').read())
x = NoneVisitor()
x.visit(parsedFile)
testAssert(x.numErrors() == 2, 'twoErrors')
def noError():
numErrors = countErrors('./cases/Test4.py')
testAssert(numErrors == 0, 'noError')
def noErrorIs():
testAssert(countErrors('./cases/Test5.py') == 0, 'noErrorIs')
def oneFuncallNoError():
testAssert(countErrors('./cases/Test6.py') == 0, 'oneFuncallNoError')
def oneForwardError():
testAssert(countErrors('./cases/Test7.py') == 1, 'oneForwardError')
def allTests():
setNone()
basicTest()
twoErrors()
noError()
noErrorIs()
oneFuncallNoError()
oneForwardError()
allTests()