@Override public void invoke(LyteContext context) { LyteValue value = context.apply(); LyteContext testContext = new LyteContext(value, context.scope, new LyteStack()); Set<String> properties = value.getProperties(); LyteObject result = new LyteObject(); if (!value.is("object")) { throw new LyteError("Cannot test an object of type " + value.typeOf() + "!"); } for (String property : properties) { if (property.startsWith("__") || !value.getProperty(property).is("block")) { continue; } try { LyteBlock test = (LyteBlock) value.getProperty(property); test.invoke(testContext); result.setProperty(property, SUCCESS); } catch (Exception e) { result.setProperty(property, new LyteString(e.getMessage())); } } // Inject the print results function result.setProperty(printResults.fullname, printResults); context.push(result); }
@Override protected boolean testCondition(LyteContext context) { String expectedError = context.apply().toString(); try { context.apply(); return false; } catch (LyteError e) { return expectedError.equals(e.getMessage()); } }
@Override public void invoke(LyteContext context) { String message = context.apply().toString(); if (!testCondition(context)) { throw new LyteError(message); } }
@Override protected boolean testCondition(LyteContext context) { return context.apply().equalsStrict(context.apply()); }
@Override protected boolean testCondition(LyteContext context) { return context.apply() != LyteUndefined.UNDEFINED; }
@Override protected boolean testCondition(LyteContext context) { return context.apply() == LyteUndefined.NULL; }
@Override protected boolean testCondition(LyteContext context) { return !context.apply().toBoolean(); }
@Override protected boolean testCondition(LyteContext context) { return context.apply() != context.apply(); }