Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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)))
Ejemplo n.º 4
0
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)))
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
    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