+2008-09-24 Miguel de Icaza <miguel@novell.com>
+
+ * eval-test.cs: Add an evaluation test, to test the basic
+ primitives of the expression evaluator.
+
2008-09-16 Jb Evain <jbevain@novell.com>
* gtest-278.cs, gtest-278-3-lib.cs, gtest-278-2-lib.cs: complete
test-local: casts-boot.exe
+eval.exe: eval-tests.cs
+
ifeq (net_2_1, $(PROFILE))
COMPILER_NAME = smcs
TEST_PATTERN = '*test-*.cs'
TEST_ILS := $(wildcard *-lib.il)
+ifeq (net_2_0, $(PROFILE))
+eval-test:
+ $(RUNTIME) $(RUNTIME_FLAGS) $(COMPILER) eval-test.cs -r:$(COMPILER)
+ MONO_PATH=$(topdir)/class/lib/$(PROFILE):. $(RUNTIME) eval-test.exe
+else
+eval-test:
+endif
+
check: run-test
-run-test-local: $(TEST_ILS:.il=.dll)
+run-test-local: $(TEST_ILS:.il=.dll) eval-test
$(TESTER) -mode:pos -files:$(TEST_PATTERN) -compiler:$(COMPILER) -issues:known-issues-$(COMPILER_NAME) -log:$(COMPILER_NAME).log $(TOPTIONS)
test-everything:
$(ILASM) /dll property-il.il
$(CSCOMPILE) /r:property-il.dll property-main.cs /out:property-main.exe
$(TEST_RUNTIME) property-main.exe
-
+
$(CSCOMPILE) -t:library dlls/test-679-2/test-679-lib-2.cs
$(CSCOMPILE) -t:library dlls/test-679-1/test-679-lib.cs -r:dlls/test-679-2/test-679-lib-2.dll
endif
--- /dev/null
+using System;
+using Mono.CSharp;
+
+class X {
+ static void Run (string id, string stmt)
+ {
+ try {
+ Evaluator.Run (stmt);
+ } catch {
+ Console.WriteLine ("Failed on test {0}", id);
+ throw;
+ }
+ }
+
+ static void Evaluate (string id, string expr, object expected)
+ {
+ try {
+ object res = Evaluator.Evaluate (expr);
+ if (res == null && expected == null)
+ return;
+
+ if (!expected.Equals (res)){
+ Console.WriteLine ("Failed on test {2} Expecting {0}, got {1}", expected, res, id);
+ throw new Exception ();
+ }
+ } catch {
+ Console.WriteLine ("Failed on test {0}", id);
+ throw;
+ }
+ }
+
+ static void Main ()
+ {
+ Run ("1", "System.Console.WriteLine (100);");
+ Run ("Length", "var a = new int [] {1,2,3}; var b = a.Length");
+
+ Evaluate ("CompareString", "\"foo\" == \"bar\";", false);
+ Evaluate ("CompareInt", "var a = 1; a+2;", 3);
+
+ Evaluator.Run ("using System; using System.Linq;");
+ Run ("LINQ-1", "var a = new int[]{1,2,3};\nfrom x in a select x;");
+ Run ("LINQ-2", "var a = from f in System.IO.Directory.GetFiles (\"/tmp\") where f == \"passwd\" select f;");
+ }
+
+}
\ No newline at end of file