### Question:
SystemState { protected boolean advanceCurCg (VM vm){ nAdvancedCGs = 0; ChoiceGenerator<?> cg = curCg; ChoiceGenerator<?> parent = cg.getCascadedParent(); if (cg.hasMoreChoices()){ if (parent != null && parent.getProcessedNumberOfChoices() == 0){ advanceAllCascadedParents(vm,parent); } advance(vm, cg); } else { vm.notifyChoiceGeneratorProcessed(cg); if (parent != null){ if (advanceCascadedParent(vm,parent)){ cg.reset(); advance(vm,cg); } } } return (nAdvancedCGs > 0); } SystemState(Config config, VM vm); protected  SystemState(); void setStartThread(ThreadInfo ti); int getId(); void setId(int newId); void recordSteps(boolean cond); void incAtomic(); void decAtomic(); void clearAtomic(); boolean isAtomic(); boolean isBlockedInAtomicSection(); void setBlockedInAtomicSection(); Transition getTrail(); SchedulerFactory getSchedulerFactory(); KernelState getKernelState(); Heap getHeap(); ChoiceGenerator<?> getChoiceGenerator(); ChoiceGenerator<?> getChoiceGenerator(String id); ChoiceGenerator<?>[] getChoiceGenerators(); T[] getChoiceGeneratorsOfType(Class<T> cgType); T getLastChoiceGeneratorOfType(Class<T> cgType); T getCurrentChoiceGeneratorOfType(Class<T> cgType); T getCurrentChoiceGenerator(String id, Class<T> cgType); ChoiceGenerator<?> getCurrentChoiceGenerator(String id); ChoiceGenerator<?> getCurrentChoiceGenerator(ChoiceGenerator<?> cgPrev); ThreadChoiceGenerator getCurrentSchedulingPoint(); ChoiceGenerator<?>[] getCurrentChoiceGenerators(); T getInsnChoiceGeneratorOfType(Class<T> cgType, Conditional<Instruction> insn, ChoiceGenerator<?> cgPrev); ChoiceGenerator<?> getNextChoiceGenerator(); boolean setNextChoiceGenerator(ChoiceGenerator<?> cg); void setMandatoryNextChoiceGenerator(ChoiceGenerator<?> cg, String failMsg); void removeNextChoiceGenerator(); void removeAllNextChoiceGenerators(); Object getBacktrackData(); void backtrackTo(Object backtrackData); Object getRestoreData(); void restoreTo(Object backtrackData); void retainAttributes(boolean b); boolean getRetainAttributes(); void setIgnored(boolean b); boolean isIgnored(); void setForced(boolean b); boolean isForced(); void setInteresting(boolean b); boolean isInteresting(); void setBoring(boolean b); boolean isBoring(); boolean isInitState(); int getThreadCount(); UncaughtException getUncaughtException(); void activateGC(); boolean hasRestorer(Object key); ClosedMemento getRestorer( Object key); void putRestorer(Object key, ClosedMemento restorer); boolean gcIfNeeded(); void checkGC(); boolean initializeNextTransition(VM vm); void executeNextTransition(VM vm); boolean breakTransition(); public KernelState ks; public Transition trail; public UncaughtException uncaughtException; }### Answer:
@Test public void testCascadedCGadvance() { MyJVM vm = new MyJVM(); MySystemState ss = new MySystemState(); BooleanChoiceGenerator cg1 = new BooleanChoiceGenerator("cg1"); IntChoiceFromSet cg2 = new IntChoiceFromSet( "cg2", 1, 2); DoubleChoiceFromList cg3 = new DoubleChoiceFromList( "cg3", 42.1, 42.2); cg2.isCascaded = true; cg1.isCascaded = true; cg3.prev = cg2; cg2.prev = cg1; ss.curCg = cg3; int n = 0; while (ss.advanceCurCg(vm)){ System.out.println("--"); n++; } assert n == 8; }