コード例 #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
コード例 #2
0
ファイル: test_interp.py プロジェクト: griels/pypy-sc
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
コード例 #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)))
コード例 #4
0
ファイル: test_interp.py プロジェクト: griels/pypy-sc
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)))
コード例 #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
コード例 #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