AnalysisContext { public TypeEnvironment pop() { Objects.requireNonNull(environment, "Fail to pop context due to no environment present"); TypeEnvironment curEnv = environment; environment = curEnv.getParent(); return curEnv; } AnalysisContext();  AnalysisContext(TypeEnvironment environment); void push(); TypeEnvironment peek(); TypeEnvironment pop();  }
@Test public void popRootEnvironmentShouldPass() { context.pop(); }
@Test public void popEmptyEnvironmentStackShouldFail() { context.pop(); NullPointerException exception = assertThrows(NullPointerException.class, () -> context.pop()); assertEquals("Fail to pop context due to no environment present", exception.getMessage()); }