コード例 #1
0
        @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);
        }
コード例 #2
0
 @Override
 protected boolean testCondition(LyteContext context) {
   String expectedError = context.apply().toString();
   try {
     context.apply();
     return false;
   } catch (LyteError e) {
     return expectedError.equals(e.getMessage());
   }
 }
コード例 #3
0
 @Override
 public void invoke(LyteContext context) {
   String message = context.apply().toString();
   if (!testCondition(context)) {
     throw new LyteError(message);
   }
 }
コード例 #4
0
 @Override
 protected boolean testCondition(LyteContext context) {
   return context.apply().equalsStrict(context.apply());
 }
コード例 #5
0
 @Override
 protected boolean testCondition(LyteContext context) {
   return context.apply() != LyteUndefined.UNDEFINED;
 }
コード例 #6
0
 @Override
 protected boolean testCondition(LyteContext context) {
   return context.apply() == LyteUndefined.NULL;
 }
コード例 #7
0
 @Override
 protected boolean testCondition(LyteContext context) {
   return !context.apply().toBoolean();
 }
コード例 #8
0
 @Override
 protected boolean testCondition(LyteContext context) {
   return context.apply() != context.apply();
 }