MatchBind { void clean(int size){ while (stack.size()>size){ reset(stack.get(stack.size()-1)); } if (table.size() != stack.size()){ logger.error("Match Bind: Stack and Table have different sizes"); } } MatchBind();   }
@Test public void clean() { MatchBind m = new MatchBind(); IntStream.range( 0, 10 ).forEach( n -> { m.setValue( Pattern.variable( "variable" + n ), Pattern.variable( "variable" + n ) ); assertEquals( n + 1, m.size() ); } ); m.clean(5); assertEquals(5, m.size()); }