[Monodevelop-patches-list] r2394 - in trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory: . errors src tests

John Luke <jluke@cfl.rr.com> jluke at mono-cvs.ximian.com
Sat Mar 26 15:01:04 EST 2005


Author: jluke
Date: 2005-03-26 15:01:04 -0500 (Sat, 26 Mar 2005)
New Revision: 2394

Added:
   trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/errors/
   trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/errors/test-1.cs
   trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/
   trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/static-class-1.cs
   trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/static-class-2.cs
   trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/test-1.cs
Removed:
   trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/a.cs
Modified:
   trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog
   trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am
   trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Main.cs
Log:
some better testing stuff for the parser


Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog	2005-03-26 18:52:28 UTC (rev 2393)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/ChangeLog	2005-03-26 20:01:04 UTC (rev 2394)
@@ -1,5 +1,15 @@
 2005-03-26  John Luke  <john.luke at gmail.com>
 
+	* Makefile.am: clean up test and add errors and tests
+	target to run both positive and negative tests.
+	* src/Main.cs: simplify and dont use PrettyPrintVisitor
+	* README: add
+	* tests: new dir to hold correct cs files
+	* errors: new dir to hold incorrect cs files
+	* a.cs: kill
+
+2005-03-26  John Luke  <john.luke at gmail.com>
+
 	* tests: remove unused stuff
 	* src/Parser/generated/Parser.cs:
 	* src/Parser/generated/cs.ATG: fix comment

Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am	2005-03-26 18:52:28 UTC (rev 2393)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/Makefile.am	2005-03-26 20:01:04 UTC (rev 2394)
@@ -126,9 +126,14 @@
 $(TEST): $(DLL) $(srcdir)/src/Main.cs
 	$(CSC) -out:$@ -r:$(DLL) $(srcdir)/src/Main.cs
 
-run-test: test
-	MONO_PATH=../../../build/bin mono $(TEST) a.cs
+run-test: run-tests run-errors
 
+run-errors: $(TEST)
+	MONO_PATH=../../../build/bin mono $(TEST) ./errors -e
+
+run-tests: $(TEST)
+	MONO_PATH=../../../build/bin mono $(TEST) ./tests
+
 assemblydir = $(libdir)/monodevelop/bin
 assembly_DATA = $(DLL)
 

Deleted: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/a.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/a.cs	2005-03-26 18:52:28 UTC (rev 2393)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/a.cs	2005-03-26 20:01:04 UTC (rev 2394)
@@ -1,104 +0,0 @@
-using System; using System.Reflection;
-using Blah = Gtk.Window;
-
-namespace Foo
-{
-	public interface IFoo
-	{
-		int Dummy { get; set; }
-		void DummyMethod();
-		event EventHandler Fooed;
-	}
-
-		[Flags]
-			[Serializable]
-	public enum FooFlags : int
-	{
-		None = 1,
-	}
-
-	public class Bar : System.Object {
-
-		static string a, b, c;
-
-		static void Moo (out string a, ref string b)
-		{
-		}
-
-		static void Main(string[]  args)
-		{
-			int foo 			= 			5;
-			this.Fooed += new EventHandler (OnFooed);
-
-			this.Moo (out a, ref b);
-
-			foo = sizeof (IntPtr);
-
-			base.GetHashCode ();
-
-			FooFlags |= FakeFlags.None;
-
-			if (this is object)
-			{}
-
-			string[] names = new string[] {""};
-
-			unsafe { /* blah */ a++; }
-
-			checked { }
-
-			//unchecked ((int) 0x80000000) {}
-			unchecked {}
-
-			// this wont compile
-			fixed (byte* buf = &buffer[offset]) {}
-
-			using (StreamReader r = new StreamReader()) {}
-
-			foreach (string s in args)
-			{
-				Console.Write(s);
-			}
-
-			for(;;){}
-
-			while (true){}
-
-			do {
-			}
-			while (true);
-
-			lock (typeof (Bar)) { }
-
-			switch (args[0]) {
-				case "a":
-					break;
-				case "b":
-					goto fancy_label;
-				default:
-					break;
-			}
-
-		fancy_label:
-			throw;
-
-		try {} catch (Exception e) {} finally {}
-
-			return 0;
-		}
-
-		~Bar ()
-		{
-		}
-
-		public Bar () : base ()
-		{
-		}
-
-		public Bar (string foo) : this () {}
-	}
-
-	public struct Baz {
-	}
-
-}

Added: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/errors/test-1.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/errors/test-1.cs	2005-03-26 18:52:28 UTC (rev 2393)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/errors/test-1.cs	2005-03-26 20:01:04 UTC (rev 2394)
@@ -0,0 +1,5 @@
+using System
+
+class T
+{
+}

Modified: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Main.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Main.cs	2005-03-26 18:52:28 UTC (rev 2393)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/src/Main.cs	2005-03-26 20:01:04 UTC (rev 2394)
@@ -11,97 +11,52 @@
 
 class MainClass
 {
-/*
-	public static StringCollection SearchDirectory(string directory, string filemask)
+	static void PrintUsage ()
 	{
-		return SearchDirectory(directory, filemask, true);
+		Console.WriteLine ("usage: test-parser.exe <dir>");
+		Environment.Exit (0);
 	}
-	
-	public static StringCollection SearchDirectory(string directory, string filemask, bool searchSubdirectories)
+
+	static void PrintFile (FileInfo file)
 	{
-		StringCollection collection = new StringCollection();
-		SearchDirectory(directory, filemask, collection, searchSubdirectories);
-		return collection;
-	}
-	
-	/// <summary>
-	/// Finds all files which are valid to the mask <code>filemask</code> in the path
-	/// <code>directory</code> and all subdirectories (if searchSubdirectories
-	/// is true. The found files are added to the StringCollection 
-	/// <code>collection</code>.
-	/// </summary>
-	static void SearchDirectory(string directory, string filemask, StringCollection collection, bool searchSubdirectories)
-	{
-		try {
-			string[] file = Directory.GetFiles(directory, filemask);
-			foreach (string f in file) {
-				collection.Add(f);
-			}
-			
-			if (searchSubdirectories) {
-				string[] dir = Directory.GetDirectories(directory);
-				foreach (string d in dir) {
-					SearchDirectory(d, filemask, collection, searchSubdirectories);
-				}
-			}
-		} catch (Exception) {
+		string fileName = file.FullName;
+		p.Parse (new Lexer (new FileReader (fileName)));
+		if (p.Errors.count == 0) {
+			ErrorVisitor ev = new ErrorVisitor();
+			ev.Visit(p.compilationUnit, null);
+		} else if (!errorMode) {
+			Console.WriteLine ("errors in {0}:", file.Name);
+			foreach (ErrorInfo error in p.Errors.ErrorInformation)
+				Console.WriteLine (error.ToString ());
 		}
 	}
-	
-	static void PrettyPrintDirectories()
+
+	static void PrintDir (DirectoryInfo dir)
 	{
-		StringCollection files = SearchDirectory("C:\\b", "*.cs");
-		foreach (string fileName in files) {
-			Parser p = new Parser();
-			Console.Write("Converting : " + fileName);
-			p.Parse(new Lexer(new FileReader(fileName)));
-			if (p.Errors.count == 0) {
-				StreamReader sr = File.OpenText(fileName);
-				string content = sr.ReadToEnd();
-				sr.Close();
-				PrettyPrintVisitor ppv = new PrettyPrintVisitor(content);
-				ppv.Visit(p.compilationUnit, null);
-				
-				StreamWriter sw = new StreamWriter(fileName);
-				sw.Write(ppv.Text);
-				sw.Close();
-				
-				Console.WriteLine(" done.");
-			} else {
-				Console.Write(" Source code errors:");
-				Console.WriteLine(p.Errors.ErrorOutput);
-			}
-		}
-		Console.ReadLine();
+		foreach (FileInfo fi in dir.GetFiles ())
+			PrintFile (fi);
 	}
-*/
-	static void PrintUsage ()
-	{
-		Console.WriteLine ("usage: test-parser.exe <file>");
-		Environment.Exit (0);
-	}
 
+	static Parser p;
+	static bool errorMode = false;
+
 	public static void Main (string[] args)
 	{
-		if (args.Length != 1)
+		if (args.Length == 0 || !Directory.Exists (args[0]))
 			PrintUsage ();
 
-//		PrettyPrintDirectories();
-		Parser p = new Parser();
-	
-		string fileName = args[0];
-		p.Parse (new Lexer (new FileReader (fileName)));
-		if (p.Errors.count == 0) {
-			StreamReader sr = File.OpenText(fileName);
-			string content = sr.ReadToEnd();
-			sr.Close();
-			PrettyPrintVisitor ppv = new PrettyPrintVisitor(content);
-			ppv.Visit(p.compilationUnit, null);
-			Console.WriteLine(ppv.Text);
-		} else {
-			Console.WriteLine (" Source code errors:");
-			foreach (ErrorInfo error in p.Errors.ErrorInformation)
-				Console.WriteLine (error.ToString ());
-		}
+		if (args.Length == 2 && args[1] == "-e")
+			errorMode = true;
+
+		p = new Parser();
+		PrintDir (new DirectoryInfo (args[0]));
 	}
 }
+
+public class ErrorVisitor : AbstractASTVisitor
+{
+	public ErrorVisitor ()
+	{
+	}
+}
+

Added: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/static-class-1.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/static-class-1.cs	2005-03-26 18:52:28 UTC (rev 2393)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/static-class-1.cs	2005-03-26 20:01:04 UTC (rev 2394)
@@ -0,0 +1,6 @@
+static class Foo
+{
+	static void Main ()
+	{
+	}
+}

Added: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/static-class-2.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/static-class-2.cs	2005-03-26 18:52:28 UTC (rev 2393)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/static-class-2.cs	2005-03-26 20:01:04 UTC (rev 2394)
@@ -0,0 +1,8 @@
+static class Foo
+{
+	static void Main ()
+	{
+	}
+
+	const int Bar = 0;
+}

Added: trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/test-1.cs
===================================================================
--- trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/test-1.cs	2005-03-26 18:52:28 UTC (rev 2393)
+++ trunk/MonoDevelop/Core/src/ICSharpCode.SharpRefactory/tests/test-1.cs	2005-03-26 20:01:04 UTC (rev 2394)
@@ -0,0 +1,13 @@
+using System;
+
+namespace Foo
+{
+	public class Bar
+	{
+		static void Main (string[] args)
+		{
+			Console.WriteLine ("hello");
+		}
+	}
+}
+




More information about the Monodevelop-patches-list mailing list