MCPcopy Create free account
hub / github.com/antlr/codebuff / test1

Method test1

output/java/1.4.12/STViz.java:455–484  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

453 }
454
455 public static void test1() throws IOException
456 { // test rig
457 String templates = "method(type,name,locals,args,stats) ::= <<\n"+"public <type> <name>(<args:{a| int <a>}; separator=\", \">) {\n"+" <if(locals)>int locals[<locals>];<endif>\n"+" <stats;separator=\"\\n\">\n"+"}\n"+">>\n"+"assign(a,b) ::= \"<a> = <b>;\"\n"+"return(x) ::= <<return <x>;>>\n"+"paren(x) ::= \"(<x>)\"\n";
458 String tmpdir = System.getProperty("java.io.tmpdir");
459 writeFile(tmpdir, "t.stg", templates);
460 STGroup group = new STGroupFile(tmpdir+"/"+"t.stg");
461 ST st = group.getInstanceOf("method");
462 st.impl.dump();
463 st.add("type", "float");
464 st.add("name", "foo");
465 st.add("locals", 3);
466 st.add("args", new String[] {"x",
467 "y",
468 "z"});
469 ST s1 = group.getInstanceOf("assign");
470 ST paren = group.getInstanceOf("paren");
471 paren.add("x", "x");
472 s1.add("a", paren);
473 s1.add("b", "y");
474 ST s2 = group.getInstanceOf("assign");
475 s2.add("a", "y");
476 s2.add("b", "z");
477 ST s3 = group.getInstanceOf("return");
478 s3.add("x", "3.14159");
479 st.add("stats", s1);
480 st.add("stats", s2);
481 st.add("stats", s3);
482 STViz viz = st.inspect();
483 System.out.println(st.render()); // should not mess up ST event lists
484 }
485
486 public static void test2() throws IOException
487 { // test rig

Callers 1

mainMethod · 0.95

Calls 7

writeFileMethod · 0.95
addMethod · 0.95
inspectMethod · 0.95
renderMethod · 0.95
getPropertyMethod · 0.65
getInstanceOfMethod · 0.45
dumpMethod · 0.45

Tested by

no test coverage detected