Parser { public static Expr parseExpr(String input) { Parser p = newParser(input); Expr expr = p.parseExpr(); p.typecheck(expr); return expr; } private  Parser(Lexer lexer); static Expr parseExpr(String input); static Labels parseMetric(String input); static String typeString(ValueType t); static Duration parseDuration(String ds);  }
@Test public void testParserMatrixSum() { Expr expr1 = Parser.parseExpr("sum(http_requests_total{method=\"get\"})"); System.out.println(expr1.toString()); Expr expr = Parser.parseExpr("sum_over_time(http_requests_total{method=\"get\"}[5m])"); System.out.println(expr.toString()); }
@Test public void testParserVectorSum() { Expr expr = Parser .parseExpr("sum(sum_over_time(http_requests_total{method=\"get\"}[5m])) by (job)"); System.out.println(expr.toString()); }
@Test(expected = IllegalStateException.class) public void testParserSumOperatorWithRangeVector() { Parser.parseExpr("sum(http_requests_total{method=\"get\"}[5m]) by (job)"); }