本文整理了Java中org.mozilla.zest.core.v1.ZestLoopInteger
类的一些代码示例,展示了ZestLoopInteger
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZestLoopInteger
类的具体详情如下:
包路径:org.mozilla.zest.core.v1.ZestLoopInteger
类名称:ZestLoopInteger
[英]This class represent a loop through a set of integers.
[中]此类表示通过一组整数的循环。
代码示例来源: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
public void endLoop() {
this.endLoop(getSet());
}
/**
代码示例来源:origin: mozilla/zest
/**
* sets a new start index
*
* @param newStart the new start index
*/
public void setStart(int newStart) {
this.setSet(new ZestLoopTokenIntegerSet(newStart, getEnd()));
}
/**
代码示例来源:origin: mozilla/zest
/**
* sets the new end index
*
* @param newEnd the new end index
*/
public void setEnd(int newEnd) {
this.setSet(new ZestLoopTokenIntegerSet(this.getStart(), newEnd));
}
}
代码示例来源: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);
}
}
}
}
代码示例来源: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 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
@Override
public void increase() {
this.getCurrentState().increase(getSet());
}
代码示例来源: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 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
ZestLoopInteger loopInt = new ZestLoopInteger(-10, 10);
loopInt.setStep(i);
loopInt.addStatement(request);
script.add(loopInt);
代码示例来源:origin: mozilla/zest
/**
* Gets the start index.
*
* @return the start index
*/
public int getStart() {
return this.getSet().getStart();
}
代码示例来源:origin: mozilla/zest
@Override
public Integer getCurrentToken() {
if (super.getCurrentToken() == null) {
super.init(getSet(), getStatements());
}
return super.getCurrentToken();
}
代码示例来源:origin: mozilla/zest
System.out.println(
"FOR tokens FROM "
+ loopInteger.getStart()
+ " TO "
+ loopInteger.getEnd()
+ " DO");
} else {
代码示例来源: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
@Override
public void toLastState() {
this.getCurrentState().toLastState(getSet());
}
代码示例来源:origin: mozilla/zest
System.out.println(" ZestLoopInteger");
System.out.println("---------------------");
ZestLoopInteger loopInteger = new ZestLoopInteger(0, 1458);
for (ZestStatement stmt : statements) {
loopInteger.addStatement(stmt);
代码示例来源:origin: mozilla/zest
/**
* sets the step for the loop
*
* @param step the step for this loop
*/
public void setStep(int step) {
this.getSet().setStep(step);
}
/**
代码示例来源: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);
}
内容来源于网络,如有侵权,请联系作者删除!