1 9 10 package org.netbeans.modules.language.css; 11 12 import java.io.BufferedReader ; 13 import java.io.IOException ; 14 import java.io.InputStream ; 15 import java.io.InputStreamReader ; 16 import java.util.List ; 17 import java.util.Map ; 18 import junit.framework.TestCase; 19 20 import org.netbeans.api.languages.ASTNode; 21 import org.netbeans.api.languages.ParseException; 22 import org.netbeans.api.languages.TokenInput; 23 import org.netbeans.modules.languages.Language; 24 import org.netbeans.modules.languages.NBSLanguageReader; 25 import org.netbeans.modules.languages.parser.AnalyserAnalyser; 26 import org.netbeans.modules.languages.parser.Petra; 27 import org.netbeans.modules.languages.parser.StringInput; 28 29 30 34 public class NBSTest extends TestCase { 35 36 public NBSTest (String testName) { 37 super (testName); 38 } 39 40 public void testFirst () { 41 InputStream is = getClass ().getClassLoader ().getResourceAsStream ("org/netbeans/modules/languages/css/CSS.nbs"); 42 try { 43 Language l = NBSLanguageReader.readLanguage ("test", is, "test/css"); 44 List r = l.getAnalyser ().getRules (); 45 AnalyserAnalyser.printRules (r, null); 46 AnalyserAnalyser.printUndefinedNTs (r, null); 47 Map f = Petra.first2 (r); 48 AnalyserAnalyser.printDepth (f, null); 49 AnalyserAnalyser.printConflicts (f, null); 50 AnalyserAnalyser.printF (f, null); 51 assertFalse (AnalyserAnalyser.hasConflicts (f)); 52 } catch (ParseException ex) { 53 ex.printStackTrace(); 54 } catch (IOException ex) { 55 ex.printStackTrace(); 56 } 57 } 58 59 public void test2 () throws ParseException, IOException { 60 InputStream is = getClass ().getClassLoader ().getResourceAsStream ("org/netbeans/modules/languages/css/CSS.nbs"); 61 Language l = NBSLanguageReader.readLanguage ("test", is, "test/css"); 62 63 is = getClass ().getClassLoader ().getResourceAsStream ("org/netbeans/modules/languages/css/netbeans.css2"); 64 BufferedReader br = new BufferedReader (new InputStreamReader (is)); 65 StringBuilder sb = new StringBuilder (); 66 String ln = br.readLine (); 67 while (ln != null) { 68 sb.append (ln).append ('\n'); 69 ln = br.readLine (); 70 } 71 TokenInput ti = TokenInput.create ( 72 l.getParser (), 73 new StringInput (sb.toString (), "netbeans.css2"), 74 l.getSkipTokenTypes () 75 ); 76 ASTNode n = l.getAnalyser ().read (ti, false); 77 assertNotNull (n); 78 } 79 } 80 | Popular Tags |