/** Private helper for {@code testGenNoncollidingBaseNames()}. */ private void assertNoncollidingBaseNamesForExprs(List<String> expected, String exprListText) { List<ExprRootNode<?>> exprRoots = ExprParseUtils.parseExprListElseThrowSoySyntaxException(exprListText, ""); List<String> actual = MsgSubstUnitBaseVarNameUtils.genNoncollidingBaseNamesForExprs(exprRoots, "FALLBACK"); MsgNodeTest.assertEquals(expected, actual); }
/** Private helper for {@code testGenNoncollidingBaseNames()}. */ private void assertErrorMsgWhenGenNoncollidingBaseNamesForExprs( String expectedErrorMsg, String exprListText) { List<ExprRootNode<?>> exprRoots = ExprParseUtils.parseExprListElseThrowSoySyntaxException(exprListText, ""); try { MsgSubstUnitBaseVarNameUtils.genNoncollidingBaseNamesForExprs(exprRoots, "FALLBACK"); MsgNodeTest.fail(); } catch (SoySyntaxException sse) { MsgNodeTest.assertTrue(sse.getMessage().contains(expectedErrorMsg)); } }
/** Private helper for {@code testGenBaseNames()}. */ private void assertShortestBaseNameForExpr(String expected, String exprText) { ExprRootNode<?> exprRoot = ExprParseUtils.parseExprElseThrowSoySyntaxException(exprText, ""); String actual = MsgSubstUnitBaseVarNameUtils.genShortestBaseNameForExpr(exprRoot, "FALLBACK"); MsgNodeTest.assertEquals(expected, actual); }
/** Private helper for {@code testGenBaseNames()}. */ private void assertCandidateBaseNamesForExpr(List<String> expected, String exprText) { ExprRootNode<?> exprRoot = ExprParseUtils.parseExprElseThrowSoySyntaxException(exprText, ""); List<String> actual = MsgSubstUnitBaseVarNameUtils.genCandidateBaseNamesForExpr(exprRoot); MsgNodeTest.assertEquals(expected, actual); }