@Test
  public void shouldSetSlotInObject() {
    object.setSlot(local, environment.getUndefined());

    FunctionWithContext function = createFunctionWithContextThatSetsLocalToValue(context);
    function.execute(interpreter, object, new ArrayList<ObjectDOS>());

    assertThat(context.getSlot(local), is(environment.getUndefined()));
    assertThat(((ValueObject) object.getSlot(local)).getValue(), is(1234));
  }
 @Before
 public void setUp() {
   interpreter = new OpCodeInterpreter();
   environment = interpreter.getEnvironment();
   vm = VMObjectDOS.getVMObject(environment);
   object = environment.createNewObject();
   value = environment.createNewObject();
   context = interpreter.newActivation();
   context.setVictim(environment.createNewObject());
 }
  @Test
  public void shouldSetSlotInCurrentContextualFunction() {

    FunctionWithContext function =
        environment.createFunctionWithContext(
            createFunctionThatSetsAndReturnsValueToLocal(), context);

    ObjectDOS result = function.execute(interpreter, object, new ArrayList<ObjectDOS>());

    assertThat(((ValueObject) result).getValue(), is(1234));
    assertThat(context.getSlot(local), is(environment.getUndefined()));
  }
 private FunctionDOS createFunctionThatSetsAndReturnsValueToLocal() {
   FunctionDOS function =
       environment.createFunction(
           new Symbol[] {},
           new OpCode[] {
             new OpCode.CreateValueObject(1234),
             new OpCode.PushSymbol(local),
             new OpCode.Push(Symbol.RESULT),
             new OpCode.FunctionCall(Symbol.SET_SLOT_$_TO_$),
             new OpCode.PushSymbol(local),
             new OpCode.FunctionCall(Symbol.GET_SLOT_$)
           });
   return function;
 }
 private FunctionWithContext createFunctionWithContextThatSetsLocalToValue(
     Activation localContext) {
   FunctionWithContext function =
       environment.createFunctionWithContext(
           new Symbol[] {},
           new OpCode[] {
             new OpCode.CreateValueObject(1234),
             new OpCode.PushSymbol(local),
             new OpCode.Push(Symbol.RESULT),
             new OpCode.FunctionCall(Symbol.SET_SLOT_$_TO_$)
           },
           localContext);
   return function;
 }