final String source = "out: table sum[key: string][month: int][day: int] of int;\nstatic keywords: array of string = { \"hitchhiker\", \"benedict\", \"vytorin\", \"itanium\", \"aardvark\" };\nquerywords: array of string = words_from_query();\nmonth: int = month_of_query();\nday: int = day_of_query();\nwhen (i: each int; j: some int; querywords[i] == keywords[j])\n emit out[keywords[j]][month][day] <- 1;\n";
final SymbolTable st = new SymbolTable();
// fake functions for this unit test
st.setFunction("day_of_query", new SizzleFunction(new SizzleInt(), new SizzleType[] {}, "Nonexistant.day_of_query()"));
st.setFunction("month_of_query", new SizzleFunction(new SizzleInt(), new SizzleType[] {}, "Nonexistant.month_of_query()"));
st.setFunction("words_from_query", new SizzleFunction(new SizzleArray(new SizzleString()), new SizzleType[] {}, "Nonexistant.words_from_query()"));
SizzleParser.ReInit(new StringReader(source));
TestTypeCheckingVisitor.typeChecker.visit(SizzleParser.Start(), st);
Assert.assertEquals("out is not an unweighted table of ints indexed by various",
new SizzleTable(new SizzleInt(), Arrays.asList(new SizzleString(), new SizzleInt(), new SizzleInt()), null), st.get("out"));
Assert.assertEquals("keywords is not an array of strings", new SizzleArray(new SizzleString()), st.get("keywords"));
Assert.assertEquals("querywords is not an array of strings", new SizzleArray(new SizzleString()), st.get("querywords"));
Assert.assertEquals("month is not an int", new SizzleInt(), st.get("month"));
Assert.assertEquals("day is not an int", new SizzleInt(), st.get("day"));
}