BindParser extends Parser { boolean match(Member member, Map<Identifier, Command> namespace) { var match = false; for (var entry : namespace.entrySet()) { match(member, entry.getValue().children); if (member.identifier.equals(entry.getKey())) { entry.getValue().members.put(member.site, member); match = true; } } return match; } BindParser(Binder binder, Logger logger, Lexer lexer);   }
@Test void parse() { environment.scopes.get(type).add(environment, token).add(environment, child); when(method.getAnnotation(Bind.class)).thenReturn(new StubBind("token child")); parser.parse(method); verify(parser).match(any(), any()); }
@Test void parse_no_tokens() { when(method.getAnnotation(Bind.class)).thenReturn(new StubBind("<a")); parser.parse(method); verify(parser, times(0)).matchAny(any(), any()); verify(parser, times(0)).match(any(), any()); }
@Test void match() { doNothing().when(parser).resolve(any(), any()); token.add(environment, child).add(environment, grandchild); parser.match(List.of(bindingChild, bindingGrandchild), token); verify(parser).resolve(bindingGrandchild.location, grandchild); }
@Test void match_nothing() { doNothing().when(parser).resolve(any(), any()); token.add(environment, child); parser.match(List.of(bindingChild, bindingGrandchild), token); verify(environment).error(bindingGrandchild.location, "\"child grandchild\" does not exist"); verify(parser, times(0)).resolve(any(), any()); }