5 static void Run (string id, string stmt)
8 Console.WriteLine ("Running {0} -> {1}", id, stmt);
10 Console.WriteLine ("Done");
12 Console.WriteLine ("Failed on test {0}", id);
17 static void Evaluate (string id, string expr, object expected)
20 object res = Evaluator.Evaluate (expr);
21 if (res == null && expected == null)
24 if (!expected.Equals (res)){
25 Console.WriteLine ("Failed on test {2} Expecting {0}, got {1}", expected, res, id);
26 throw new Exception ();
29 Console.WriteLine ("Failed on test {0}", id);
36 Run ("1", "System.Console.WriteLine (100);");
37 Run ("Length", "var a = new int [] {1,2,3}; var b = a.Length");
39 Evaluate ("CompareString", "\"foo\" == \"bar\";", false);
40 Evaluate ("CompareInt", "var a = 1; a+2;", 3);
42 Evaluator.Run ("using System; using System.Linq;");
43 Run ("LINQ-1", "var a = new int[]{1,2,3};\nfrom x in a select x;");
44 Run ("LINQ-2", "var a = from f in System.IO.Directory.GetFiles (\"/tmp\") where f == \"passwd\" select f;");
46 Evaluator.ReferenceAssembly (typeof (MyTest).Assembly);
47 Evaluate ("assembly reference test", "typeof (MyTest) != null;", true);
49 Run ("LINQ-3", "var first_scope = new int [] {1,2,3};");
50 Run ("LINQ-4", "var second_scope = from x in first_scope select x;");