@Test public void test_last_exit() { SymbolGenerator s = new SymbolGenerator(); assertThat(s.next(), is("__$$_symbol_0")); s.exit(); assertThat(s.next(), is("__$$_symbol_1")); }
@Test public void test_unnamed_generator() { SymbolGenerator sym = new SymbolGenerator(); assertThat(sym.next(), is("__$$_symbol_0")); assertThat(sym.enter("sub").next(), is("__$$_symbol_sub_1")); sym.exit(); assertThat(sym.next("foo"), is("__$$_symbol_foo_2")); }
@Test public void test_named_generator() { SymbolGenerator sym = new SymbolGenerator("closure"); assertThat(sym.next(), is("__$$_closure_0")); assertThat(sym.next(), is("__$$_closure_1")); sym.enter("scope"); assertThat(sym.next(), is("__$$_closure_scope_2")); sym.enter("subscope"); assertThat(sym.next(), is("__$$_closure_scope_subscope_3")); sym.exit().exit(); assertThat(sym.next(), is("__$$_closure_4")); }