1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 3 <head> 4 <meta http-equiv="content-type" content="text/html;charset=utf-8" /> 5 <title>t020fuzzy</title> 6 7 <!-- ANTLR includes --> 8 <script type="text/javascript" src="../../lib/antlr3-all.js"></script> 9 <script type="text/javascript" src="t020fuzzy.js"></script> 10 11 <!-- JsUnit include --> 12 <script type="text/javascript" src="../jsunit/app/jsUnitCore.js"></script> 13 14 <!-- Test Code --> 15 <script type="text/javascript"> 16 function testValid() { 17 var xinput = [ 18 "import org.antlr.runtime.*;", 19 "", 20 "public class Main {", 21 " public static void main(String[] args) throws Exception {", 22 " for (int i=0; i<args.length; i++) {", 23 " CharStream input = new ANTLRFileStream(args[i]);", 24 " FuzzyJava lex = new FuzzyJava(input);", 25 " TokenStream tokens = new CommonTokenStream(lex);", 26 " tokens.toString();", 27 " //System.out.println(tokens);", 28 " }", 29 " }", 30 "}" 31 ].join("\n"), 32 xoutput = [ 33 "found class Main", 34 "found method main", 35 "found var i", 36 "found var input", 37 "found call ANTLRFileStream", 38 "found var lex", 39 "found call FuzzyJava", 40 "found var tokens", 41 "found call CommonTokenStream", 42 "found call tokens.toString", 43 "found // comment //System.out.println(tokens);\n" 44 ]; 45 var cstream = new org.antlr.runtime.ANTLRStringStream(xinput), 46 lexer = new t020fuzzy(cstream), 47 tstream = new org.antlr.runtime.CommonTokenStream(lexer), 48 i; 49 50 assertEquals(tstream.getTokens().length, 36); 51 assertEquals(lexer.outbuf.length, xoutput.length); 52 for (i=0; i<xoutput.length; i++) { 53 assertEquals(lexer.outbuf[i], xoutput[i]+"\n"); 54 } 55 } 56 </script> 57 58 </head> 59 <body> 60 <h1>t020fuzzy</h1> 61 </body> 62 </html> 63