### Question:
GOLDParser extends Parser { public void clearProgramVariables() { for (Scope scope : scopes.values()) { scope.getVariables().clear(); } } GOLDParser();  GOLDParser(GOLDParserBuildContext context);  GOLDParser(File cgtFile, String rulesPackage, boolean trimReductions);  GOLDParser(InputStream cgtFile, String rulesPackage, boolean trimReductions); void clear(); void clearProgramVariables(); void clearProgramVariable(String name); Variable getProgramVariable(String name); void setProgramVariable(String name, Variable value); Map<String, Scope> getScopes(); Scope getCurrentScope(); Scope setCurrentScope(Scope newScope); boolean getGenerateTree(); void setGenerateTree(boolean generateTree); void raiseParserException(String msg); void raiseParserException(String msg, Throwable cause); List<String> getErrorMessages(); String getErrorMessage(); void addErrorMessage(String message); boolean isReady(); boolean isIgnoreCaseOfVariables(); void setIgnoreCaseOfVariables(boolean ignoreCaseOfVariableNames); boolean setup(File grammarFile); boolean parseSourceStatements(String sourceStatements); boolean parseSourceStatements(Reader sourceReader); boolean processInternalError(); String getParseTree(); void loadRuleHandlers(String packageName); void loadRuleHandlers(List<Class> ruleClasses); List<String> validateHandlersExist(); void validateHandlerExists(Production rule); static final String VT_INDENT_DECREASE; static final String VT_INDENT_INCREASE; }### Answer:
@Test public void testClearProgramVariables() throws Exception { GOLDParser parser = new GOLDParser(); parser.setProgramVariable("mode1", new Variable("global")); parser.setCurrentScope(new Scope("Widget", parser.getCurrentScope())); parser.setProgramVariable("mode2", new Variable("widget")); assertEquals("wrong number of variables", 1, parser.getScopes().get("GLOBAL").getVariables().size()); assertEquals("wrong number of variables", 1, parser.getScopes().get("Widget").getVariables().size()); assertEquals("variable1", "global", parser.getProgramVariable("mode1").asString()); assertEquals("variable2", "widget", parser.getProgramVariable("mode2").asString()); parser.clearProgramVariables(); assertEquals("wrong number of variables", 0, parser.getScopes().get("GLOBAL").getVariables().size()); assertEquals("wrong number of variables", 0, parser.getScopes().get("Widget").getVariables().size()); assertNull("variable1", parser.getProgramVariable("mode1")); assertNull("variable2", parser.getProgramVariable("mode2")); }