use of org.mozilla.javascript.NativeContinuation in project BPjs by bThink-BGU.
the class ContinuationProgramStateTest method testStackHeight.
@Test
public void testStackHeight() throws Exception {
// Generate a continuation
BProgram bprog = new StringBProgram(SRC_SHORT);
BProgramSyncSnapshot cur = bprog.setup();
cur = cur.start(exSvc);
BThreadSyncSnapshot snapshot = cur.getBThreadSnapshots().iterator().next();
// Read frame data of P1
NativeContinuation nc = (NativeContinuation) snapshot.getContinuation();
ContinuationProgramState sut1 = new ContinuationProgramState(nc);
assertEquals(0, sut1.getFrameIndex());
bprog = new StringBProgram(SRC_MORE_FUNC);
cur = bprog.setup();
cur = cur.start(exSvc);
snapshot = cur.getBThreadSnapshots().iterator().next();
// Read frame data of P1
nc = (NativeContinuation) snapshot.getContinuation();
ContinuationProgramState sut2 = new ContinuationProgramState(nc);
assertEquals(1, sut2.getFrameIndex());
}
use of org.mozilla.javascript.NativeContinuation in project BPjs by bThink-BGU.
the class ContinuationProgramStateTest method testCorrectExtraction.
@Test
public void testCorrectExtraction() throws Exception {
// Generate a continuation
BProgram bprog = new StringBProgram(SRC);
BProgramSyncSnapshot cur = bprog.setup();
cur = cur.start(exSvc);
final BThreadSyncSnapshot snapshot = cur.getBThreadSnapshots().iterator().next();
// Read frame data
NativeContinuation nc = (NativeContinuation) snapshot.getContinuation();
ContinuationProgramState sut = new ContinuationProgramState(nc);
assertEquals(0, sut.getFrameIndex());
assertEquals("gVar content", sut.getVisibleVariables().get("gVar"));
assertEquals("fVar content", sut.getVisibleVariables().get("fVar"));
assertEquals("updated content", sut.getVisibleVariables().get("shadowed"));
assertEquals(2.42, sut.getVisibleVariables().get("fDblVar2"));
}
Aggregations