def assertv(code, value): jsint = interpreter.Interpreter() ctx = jsint.w_Global try: code_val = jsint.run(interpreter.load_source(code, '')).GetValue() except ThrowException, excpt: code_val = excpt.exception
def assertp(code, prints): l = [] interpreter.writer = l.append jsint = interpreter.Interpreter() ctx = jsint.w_Global try: jsint.run(interpreter.load_source(code, '')) except ThrowException, excpt: l.append("uncaught exception: "+str(excpt.exception.ToString(ctx)))
def assertp(code, prints): l = [] interpreter.writer = l.append jsint = interpreter.Interpreter() ctx = jsint.w_Global try: jsint.run(interpreter.load_source(code, '')) except ThrowException, excpt: l.append("uncaught exception: " + str(excpt.exception.ToString(ctx)))
def runsource(self, source, filename="<input>"): """Parse and run source in the interpreter. One of these cases can happen: 1) The input is incorrect. Prints a nice syntax error message. 2) The input in incomplete. More input is required. Returns None. 3) The input is complete. Executes the source code. """ try: ast = load_source(source, filename) except ParseError, exc: if exc.source_pos.i == len(source): # Case 2 return True # True means that more input is needed else: # Case 1 self.showsyntaxerror(filename, exc) return False