Search in sources :

Example 1 with InMemoryState

use of com.walmartlabs.concord.svm.InMemoryState in project concord by walmartlabs.

the class VMUtilsTest method testLocals.

@Test
public void testLocals() {
    Frame rootFrame = Frame.builder().root().locals(Collections.singletonMap("x", 123)).build();
    State state = new InMemoryState(rootFrame);
    ThreadId threadId = state.getRootThreadId();
    Frame levelOneFrame = Frame.builder().nonRoot().locals(Collections.singletonMap("y", 234)).build();
    state.pushFrame(threadId, levelOneFrame);
    Frame levelTwoFrame = Frame.builder().nonRoot().locals(Collections.singletonMap("x", 345)).build();
    state.pushFrame(threadId, levelTwoFrame);
    Map<String, Object> locals = VMUtils.getCombinedLocals(state, threadId);
    assertEquals(2, locals.size());
    assertEquals(345, locals.get("x"));
    assertEquals(234, locals.get("y"));
}
Also used : Frame(com.walmartlabs.concord.svm.Frame) ThreadId(com.walmartlabs.concord.svm.ThreadId) State(com.walmartlabs.concord.svm.State) InMemoryState(com.walmartlabs.concord.svm.InMemoryState) InMemoryState(com.walmartlabs.concord.svm.InMemoryState) Test(org.junit.jupiter.api.Test)

Aggregations

Frame (com.walmartlabs.concord.svm.Frame)1 InMemoryState (com.walmartlabs.concord.svm.InMemoryState)1 State (com.walmartlabs.concord.svm.State)1 ThreadId (com.walmartlabs.concord.svm.ThreadId)1 Test (org.junit.jupiter.api.Test)1