@Override protected void setUpEnvironment(PrologEnvironment env) { Change change = new Change( new Change.Key("Ibeef"), new Change.Id(1), new Account.Id(2), new Branch.NameKey(localKey, "refs/heads/master"), TimeUtil.nowTs()); env.set(StoredValues.CHANGE_CONTROL, util.user(local).controlFor(change)); }
@Test public void testReductionLimit() throws CompileException { PrologEnvironment env = envFactory.create(machine); setUpEnvironment(env); String script = "loopy :- b(5).\n" + "b(N) :- N > 0, !, S = N - 1, b(S).\n" + "b(_) :- true.\n"; SymbolTerm nameTerm = SymbolTerm.create("testReductionLimit"); JavaObjectTerm inTerm = new JavaObjectTerm(new PushbackReader(new StringReader(script), Prolog.PUSHBACK_SIZE)); if (!env.execute(Prolog.BUILTIN, "consult_stream", nameTerm, inTerm)) { throw new CompileException("Cannot consult " + nameTerm); } exception.expect(ReductionLimitException.class); exception.expectMessage("exceeded reduction limit of 1300"); env.once( Prolog.BUILTIN, "call", new StructureTerm(":", SymbolTerm.create("user"), SymbolTerm.create("loopy"))); }