public boolean waitForLambda(long waitMs, Lambda expression) { try { boolean ret = expression.func(); long endMs = System.currentTimeMillis() + waitMs; while (!failure && !ret && (System.currentTimeMillis() <= endMs)) { Thread.sleep(5); ret = expression.func(); } assertFalse(failure); return ret; } catch (Exception e) { fail("exception during lambda evaluation"); return false; } }
protected Lambda substitute(IDContext context, String name, Lambda lambda) { return name.equals(this.name) ? lambda.deepCopy() : this; }
Lambda(Lambda l) { this.id = l.getId(); this.exp = copy(l.getExpression()); copyEnvironment(l); }
@Override public void calc(Env env) { if (cond == null || cond.test(env)) env.value += env.baseValue * _lambda.calc(env); }
@Test public void testIdentity() { Lambda<Object, Object> id = identity(); assert id == id.map(id); }