Пример #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
 public void invoke(LyteObject self, LyteContext context) {
   LyteValue result;
   for (String property : self.getProperties()) {
     if (property.equals(this.fullname)) {
       continue;
     } else if ((result = self.getProperty(property)).equals(SUCCESS)) {
       System.out.println("Test \"" + property + "\" Passed!");
     } else {
       System.out.println("Test \"" + property + "\" Failed Because \"" + result + "\"");
     }
   }
 }