Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re, subprocess, random, time, os, sys
- def openFile(fname):
- f = open(fname)
- input = f.read()
- f.close()
- return re.sub('[^a-zA-Z .,?!]+', '', input)
- def generateString(input):
- startChar = random.randint(1, len(input)-170)
- return input[startChar:startChar+random.randint(0,160)]
- def testString(str):
- f = open("input.txt", "wb")
- f.write(str)
- f.close()
- print("Testing string:" + str)
- cout = subprocess.check_output("./a.out",shell=True)
- mipsout = subprocess.check_output("java -jar Mars.jar sm nc punctuation_checker.s",shell=True)
- if (mipsout[-1:] == '\n'):
- mipsout = mipsout[:-1] #trailing newline on MARS output
- if mipsout == cout:
- print "Passed."
- print ""
- else:
- print "FAILED"
- sys.exit("stopped due to mismatch between C and MIPS output")
- f = openFile(sys.argv[1])
- while 1:
- str = generateString(f)
- testString(str)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement