Beispiel #1
0
def new_agent(currentAgent, stepInitFn=None, traceFn=None):
    """initialize a new agent. if the step init functions are passed in, the debugger will also be initialized."""
    if currentAgent is not None:
        currentAgent.stop_executor()
        get_step_controller().step() #to break the step lock
    agent = Agent("A")
    # Keep a reference to this agent for ease of debugging
    global _AGENT
    _AGENT = agent
    
    agent.start_executor()
    if stepInitFn and traceFn:
        init_trace(agent, stepInitFn, traceFn)
    else:
        if not (not stepInitFn and not traceFn): raise AssertionError, \
           "new_agent: Either zero or both of stepInitFn and traceFn must be specified"
    return agent
Beispiel #2
0
def new_agent(currentAgent, stepInitFn=None, traceFn=None):
    """initialize a new agent. if the step init functions are passed in, the debugger will also be initialized."""
    if currentAgent is not None:
        currentAgent.stop_executor()
        get_step_controller().step()  # to break the step lock
    agent = Agent("A")
    # Keep a reference to this agent for ease of debugging
    global _AGENT
    _AGENT = agent

    agent.start_executor()
    if stepInitFn and traceFn:
        init_trace(agent, stepInitFn, traceFn)
    else:
        if not (not stepInitFn and not traceFn):
            raise AssertionError, "new_agent: Either zero or both of stepInitFn and traceFn must be specified"
    return agent
Beispiel #3
0
#*****************************************************************************#
#* "$Revision:: 26                                                        $" *#
#* "$HeadURL:: https://svn.ai.sri.com/projects/spark/trunk/spark/src/spar#$" *#
#*****************************************************************************#
import unittest
import sys

import setrootlevel
setrootlevel.setrootlevel(2)

from spark.internal.version import *
from spark.internal.exception import Error, FailFailure, TestFailure

from spark.internal.engine.agent import Agent, SUCCESS

agent = Agent("Test")
agent.start_executor()

class PredExprsTestCase(unittest.TestCase):
    def runTest(self):
        self.testSimple()
        self.testPredClosure()
        self.testTask()

    def eval_eq(self, str1, str2):
        modname = "spark.tests.test_predexprs"
        val1 = agent.eval(str1, modname)
        val2 = agent.eval(str2, modname)
        self.failUnlessEqual(val1, val2)

    def invalid_val(self, valexpr, class_):
Beispiel #4
0
def new_agent():
    """starts up the SPARK agent that we use to parse the modules"""
    global testagent
    testagent = Agent("A")
Beispiel #5
0
#*****************************************************************************#
#* "$Revision:: 26                                                        $" *#
#* "$HeadURL:: https://svn.ai.sri.com/projects/spark/trunk/spark/src/spar#$" *#
#*****************************************************************************#
import unittest
import sys

import setrootlevel
setrootlevel.setrootlevel(2)

from spark.internal.version import *
from spark.internal.exception import Error, FailFailure, TestFailure

from spark.internal.engine.agent import Agent, SUCCESS

agent = Agent("Test")
agent.start_executor()


class PredExprsTestCase(unittest.TestCase):
    def runTest(self):
        self.testSimple()
        self.testPredClosure()
        self.testTask()

    def eval_eq(self, str1, str2):
        modname = "spark.tests.test_predexprs"
        val1 = agent.eval(str1, modname)
        val2 = agent.eval(str2, modname)
        self.failUnlessEqual(val1, val2)