Search in sources :

Example 6 with NativeContinuation

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());
}
Also used : BProgram(il.ac.bgu.cs.bp.bpjs.model.BProgram) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) NativeContinuation(org.mozilla.javascript.NativeContinuation) BProgramSyncSnapshot(il.ac.bgu.cs.bp.bpjs.model.BProgramSyncSnapshot) BThreadSyncSnapshot(il.ac.bgu.cs.bp.bpjs.model.BThreadSyncSnapshot) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) Test(org.junit.Test)

Example 7 with NativeContinuation

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"));
}
Also used : BProgram(il.ac.bgu.cs.bp.bpjs.model.BProgram) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) NativeContinuation(org.mozilla.javascript.NativeContinuation) BProgramSyncSnapshot(il.ac.bgu.cs.bp.bpjs.model.BProgramSyncSnapshot) BThreadSyncSnapshot(il.ac.bgu.cs.bp.bpjs.model.BThreadSyncSnapshot) StringBProgram(il.ac.bgu.cs.bp.bpjs.model.StringBProgram) Test(org.junit.Test)

Aggregations

BProgram (il.ac.bgu.cs.bp.bpjs.model.BProgram)7 BProgramSyncSnapshot (il.ac.bgu.cs.bp.bpjs.model.BProgramSyncSnapshot)7 BThreadSyncSnapshot (il.ac.bgu.cs.bp.bpjs.model.BThreadSyncSnapshot)7 StringBProgram (il.ac.bgu.cs.bp.bpjs.model.StringBProgram)7 Test (org.junit.Test)7 NativeContinuation (org.mozilla.javascript.NativeContinuation)7 BEvent (il.ac.bgu.cs.bp.bpjs.model.BEvent)2