@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 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; }