@Test public void shouldSetSlotInFunctionsContext() { context.setSlot(local, environment.getUndefined()); FunctionWithContext function = createFunctionWithContextThatSetsLocalToValue(context); function.execute(interpreter, object, new ArrayList<ObjectDOS>()); assertThat(((ValueObject) context.getSlot(local)).getValue(), is(1234)); }
@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())); }