5 static void Run (string id, string stmt)
10 Console.WriteLine ("Failed on test {0}", id);
15 static void Evaluate (string id, string expr, object expected)
18 object res = Evaluator.Evaluate (expr);
19 if (res == null && expected == null)
22 if (!expected.Equals (res)){
23 Console.WriteLine ("Failed on test {2} Expecting {0}, got {1}", expected, res, id);
24 throw new Exception ();
27 Console.WriteLine ("Failed on test {0}", id);
34 Run ("1", "System.Console.WriteLine (100);");
35 Run ("Length", "var a = new int [] {1,2,3}; var b = a.Length");
37 Evaluate ("CompareString", "\"foo\" == \"bar\";", false);
38 Evaluate ("CompareInt", "var a = 1; a+2;", 3);
40 Evaluator.Run ("using System; using System.Linq;");
41 Run ("LINQ-1", "var a = new int[]{1,2,3};\nfrom x in a select x;");
42 Run ("LINQ-2", "var a = from f in System.IO.Directory.GetFiles (\"/tmp\") where f == \"passwd\" select f;");
44 Evaluator.ReferenceAssembly (typeof (MyTest).Assembly);
45 Evaluate ("assembly reference test", "typeof (MyTest) != null;", true);
47 Run ("LINQ-3", "var first_scope = new int [] {1,2,3};");
48 Run ("LINQ-4", "var second_scope = from x in first_scope select x;");