@Test public void testExecute() throws Exception { final ByRef<Boolean> matched = ByRef.create(Boolean.FALSE); agent.getRhsFunctions().registerHandler(new StandaloneRhsFunctionHandler("match"){ @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { matched.value = true; return null; }}); agent.getProductions().loadProduction("" + "createStructure\n" + "(state <s> ^superstate nil)\n" + "-->\n" + "(<s> ^to-copy <tc>)" + "(<tc> ^value 1 ^location <loc> ^another <a>)" + "(<loc> ^x 123 ^y 3.14 ^name |hello| ^loop <tc> ^sub <sub>)" + "(<a> ^foo bar ^link <sub>)"); agent.getProductions().loadProduction("" + "copyStructure\n" + "(state <s> ^superstate nil ^to-copy <tc>)\n" + "-->\n" + "(<s> ^copy (deep-copy <tc>))"); agent.getProductions().loadProduction("" + "testStructure\n" + "(state <s> ^superstate nil ^to-copy <tc-old> ^copy <c>)\n" + "(<c> ^value 1 ^location <loc> ^another <a>)" + "(<loc> ^x 123 ^y 3.14 ^name |hello| ^loop <tc> ^sub <sub>)" + "(<a> ^foo bar ^link <sub>)\n" + "-->\n" + "(match)"); agent.getProperties().set(SoarProperties.WAITSNC, true); agent.runFor(2, RunType.DECISIONS); assertTrue(matched.value); }
@Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); Identifier startId = arguments.get(0).asIdentifier(); if(startId == null) { throw new RhsFunctionException("Only argument to '" + getName() + "' RHS function must be an identifier."); } Map<Identifier, Identifier> idMap = new HashMap<Identifier, Identifier>(); return copy(context, startId, idMap); }
DeepCopy extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); Identifier startId = arguments.get(0).asIdentifier(); if(startId == null) { throw new RhsFunctionException("Only argument to '" + getName() + "' RHS function must be an identifier."); } Map<Identifier, Identifier> idMap = new HashMap<Identifier, Identifier>(); return copy(context, startId, idMap); } }
DeepCopy extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); Identifier startId = arguments.get(0).asIdentifier(); if(startId == null) { throw new RhsFunctionException("Only argument to '" + getName() + "' RHS function must be an identifier."); } Map<Identifier, Identifier> idMap = new HashMap<Identifier, Identifier>(); return copy(context, startId, idMap); } DeepCopy(); }
DeepCopy extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); Identifier startId = arguments.get(0).asIdentifier(); if(startId == null) { throw new RhsFunctionException("Only argument to '" + getName() + "' RHS function must be an identifier."); } Map<Identifier, Identifier> idMap = new HashMap<Identifier, Identifier>(); return copy(context, startId, idMap); } DeepCopy(); @Override Symbol execute(RhsFunctionContext context, List<Symbol> arguments); }
DeepCopy extends AbstractRhsFunctionHandler { @Override public Symbol execute(RhsFunctionContext context, List<Symbol> arguments) throws RhsFunctionException { RhsFunctions.checkArgumentCount(this, arguments); Identifier startId = arguments.get(0).asIdentifier(); if(startId == null) { throw new RhsFunctionException("Only argument to '" + getName() + "' RHS function must be an identifier."); } Map<Identifier, Identifier> idMap = new HashMap<Identifier, Identifier>(); return copy(context, startId, idMap); } DeepCopy(); @Override Symbol execute(RhsFunctionContext context, List<Symbol> arguments);  }