gpt4 book ai didi

org.mozilla.zest.core.v1.ZestLoopInteger.addStatement()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 09:36:24 25 4
gpt4 key购买 nike

本文整理了Java中org.mozilla.zest.core.v1.ZestLoopInteger.addStatement()方法的一些代码示例,展示了ZestLoopInteger.addStatement()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestLoopInteger.addStatement()方法的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestLoopInteger
类名称:ZestLoopInteger
方法名:addStatement

ZestLoopInteger.addStatement介绍

暂无

代码示例

代码示例来源:origin: mozilla/zest

@Test
public void testHasMoreElements() {
  int numOfToken = 10;
  ZestLoopInteger loop = new ZestLoopInteger(0, numOfToken);
  for (ZestStatement stmt : statements) {
    loop.addStatement(stmt);
  }
  int counter = 0;
  while (loop.hasMoreElements()) {
    ZestStatement stmt = loop.nextElement();
    assertTrue(
        "statement " + counter,
        stmt.getClass()
            .equals(
                statements
                    .get(counter % statements.size())
                    .getClass())); // check if the classes of the
    // statements are equals
    counter++;
  }
  assertTrue(
      "right number of iteration ",
      counter == (numOfToken) * statements.size()); // include start, exclude end!
}

代码示例来源:origin: mozilla/zest

@Test
public void testZestLoopBreak() {
  statements.clear();
  for (int i = 0; i < 10; i++) {
    statements.add(new ZestActionPrint("" + i));
  }
  List<ZestStatement> statements2 = new LinkedList<>(statements);
  statements2.add(new ZestControlLoopBreak());
  ZestLoopInteger loop = new ZestLoopInteger(0, 1000000);
  for (ZestStatement stmt : statements2) {
    loop.addStatement(stmt);
  }
  int counterIteration = 0;
  while (loop.hasMoreElements()) {
    loop.nextElement().getElementType();
    counterIteration++;
  }
  assertTrue(counterIteration == statements2.size() - 1);
}

代码示例来源:origin: mozilla/zest

@Test
public void testZestLoopNext() {
  LinkedList<ZestStatement> statements2 = new LinkedList<>(statements);
  statements2.add(0, new ZestControlLoopNext());
  ZestLoopInteger loop = new ZestLoopInteger(0, 10);
  for (ZestStatement stmt : statements2) {
    loop.addStatement(stmt);
  }
  int counter = 0;
  while (loop.hasMoreElements()) {
    ZestStatement tmp = loop.nextElement();
    assertTrue("iteration " + counter, tmp instanceof ZestControlLoopNext);
    counter++;
  }
}

代码示例来源:origin: mozilla/zest

@Test
public void testSerializationLoopInteger() {
  ZestLoopInteger loop = new ZestLoopInteger(0, 1235);
  for (ZestStatement stmt : statements) {
    loop.addStatement(stmt);
  }
  String loopString = ZestJSON.toString(loop);
  ZestLoopInteger copy = (ZestLoopInteger) ZestJSON.fromString(loopString);
  String copyString = ZestJSON.toString(copy);
  // System.out.println("===============================");
  // System.out.println("          LOOP INTEGER");
  // System.out.println("===============================");
  // System.out.println(copyString);
  assertTrue(copyString.equals(loopString));
}

代码示例来源:origin: mozilla/zest

@Override
public ZestLoopInteger deepCopy() {
  ZestLoopStateInteger state = this.getCurrentState().deepCopy();
  ZestLoopTokenIntegerSet set = this.getSet();
  ZestLoopInteger copy = new ZestLoopInteger(set.getStart(), set.getEnd());
  copy.setVariableName(this.getVariableName());
  for (ZestStatement stmt : this.getStatements()) {
    copy.addStatement(stmt.deepCopy());
  }
  copy.setCurrentState(state);
  copy.setEnabled(this.isEnabled());
  return copy;
}

代码示例来源:origin: mozilla/zest

ZestLoopInteger loopInteger = new ZestLoopInteger(0, 1458);
for (ZestStatement stmt : statements) {
  loopInteger.addStatement(stmt);

代码示例来源:origin: mozilla/zest

@Test
public void testDeepCopy() {
  ZestLoopInteger loop = new ZestLoopInteger(0, 10);
  for (ZestStatement stmt : statements) {
    loop.addStatement(stmt);
  }
  loop.loop();
  ZestLoopInteger copy = loop.deepCopy();
  assertTrue(loop.getCurrentState().equals(copy.getCurrentState()));
}

代码示例来源:origin: mozilla/zest

loopInt.addStatement(request);
script.add(loopInt);

代码示例来源:origin: mozilla/zest

@Test
public void testLoop() {
  int maxIt = 10;
  ZestLoopInteger loop = new ZestLoopInteger(0, maxIt);
  for (ZestStatement stmt : statements) {
    loop.addStatement(stmt);
  }
  int iteration = loop.getCurrentToken();
  while (loop.loop()) {
    ++iteration;
    assertTrue("right iteration index", iteration == loop.getCurrentToken());
  }
  assertTrue(
      "right number of iterations",
      loop.getCurrentToken() == maxIt - 1); // start is inclusive, end
  // is exclusive!
}

代码示例来源:origin: mozilla/zest

@Test
public void testEndLoop() {
  ZestLoopInteger loop = new ZestLoopInteger(0, 10);
  for (ZestStatement stmt : statements) {
    loop.addStatement(stmt);
  }
  loop.endLoop();
  assertTrue(loop.getCurrentState().isLastState(loop.getSet())); // it
  // recognize
  // the
  // last state
  assertFalse(loop.loop()); // it returs false if the method loop is called
  // again
}

代码示例来源:origin: mozilla/zest

@Test
  public void testZestLoopDifferentStep() {
    ZestLoopInteger loop = new ZestLoopInteger("with step = 7", 0, 100);
    for (ZestStatement stmt : statements) {
      loop.addStatement(stmt);
    }
    loop.setStep(7);
    int counter = 0;
    while (loop.hasMoreElements()) {
      if (loop.loop()) {
        ++counter;
        assertTrue("step: " + counter, loop.getCurrentToken() == counter * 7);
      } else {
        assertTrue("Last Step", loop.getCurrentToken() == loop.getEnd() - 1);
      }
    }
  }
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com