Пример #1
0
        public virtual bool run()
        {
            this.result = new global::haxe.unit.TestResult();
            {
                global::_List.ListNode <object> _g_head = this.cases.h;
                while ((_g_head != null))
                {
                    global::haxe.unit.TestCase val = ((global::haxe.unit.TestCase)(_g_head.item));
                    _g_head = _g_head.next;
                    global::haxe.unit.TestCase c = ((global::haxe.unit.TestCase)(val));
                    this.runCase(c);
                }
            }

            global::haxe.unit.TestRunner.print.__hx_invoke1_o(default(double), this.result.toString());
            return(this.result.success);
        }
Пример #2
0
        public virtual void runCase(global::haxe.unit.TestCase t)
        {
            global::haxe.lang.Function old = global::haxe.Log.trace;
            global::haxe.Log.trace = ((global::haxe.lang.Function)(new global::haxe.lang.Closure(typeof(global::haxe.unit.TestRunner), "customTrace", 727446804)));
            global::System.Type    cl     = global::Type.getClass <object>(((object)(t)));
            global::Array <object> fields = global::Type.getInstanceFields(cl);

            global::haxe.unit.TestRunner.print.__hx_invoke1_o(default(double), global::haxe.lang.Runtime.concat(global::haxe.lang.Runtime.concat("Class: ", global::Type.getClassName(cl)), " "));
            {
                int _g = 0;
                while ((_g < fields.length))
                {
                    string f = global::haxe.lang.Runtime.toString(fields[_g]);
                    ++_g;
                    string fname = f;
                    object field = global::Reflect.field(t, f);
                    if ((fname.StartsWith("test") && (field is global::haxe.lang.Function)))
                    {
                        t.currentTest           = new global::haxe.unit.TestStatus();
                        t.currentTest.classname = global::Type.getClassName(cl);
                        t.currentTest.method    = fname;
                        t.setup();
                        try {
                            global::Reflect.callMethod(t, field, new global::Array <object>());
                            if (t.currentTest.done)
                            {
                                t.currentTest.success = true;
                                global::haxe.unit.TestRunner.print.__hx_invoke1_o(default(double), ".");
                            }
                            else
                            {
                                t.currentTest.success = false;
                                t.currentTest.error   = "(warning) no assert";
                                global::haxe.unit.TestRunner.print.__hx_invoke1_o(default(double), "W");
                            }
                        }
                        catch (global::System.Exception __temp_catchallException1) {
                            global::haxe.lang.Exceptions.exception = __temp_catchallException1;
                            object __temp_catchall2 = __temp_catchallException1;
                            if ((__temp_catchall2 is global::haxe.lang.HaxeException))
                            {
                                __temp_catchall2 = ((global::haxe.lang.HaxeException)(__temp_catchallException1)).obj;
                            }

                            if ((__temp_catchall2 is global::haxe.unit.TestStatus))
                            {
                                global::haxe.unit.TestStatus e = ((global::haxe.unit.TestStatus)(__temp_catchall2));
                                {
                                    global::haxe.unit.TestRunner.print.__hx_invoke1_o(default(double), "F");
                                    global::Array <object> tmp = global::haxe.CallStack.exceptionStack();
                                    t.currentTest.backtrace = global::haxe.CallStack.toString(tmp);
                                }
                            }
                            else
                            {
                                object e1 = __temp_catchall2;
                                global::haxe.unit.TestRunner.print.__hx_invoke1_o(default(double), "E");
                                string tmp1 = global::Std.@string(e1);
                                t.currentTest.error = global::haxe.lang.Runtime.concat("exception thrown : ", tmp1);
                                global::Array <object> tmp2 = global::haxe.CallStack.exceptionStack();
                                t.currentTest.backtrace = global::haxe.CallStack.toString(tmp2);
                            }
                        }


                        this.result.@add(t.currentTest);
                        t.tearDown();
                    }
                }
            }

            global::haxe.unit.TestRunner.print.__hx_invoke1_o(default(double), "\n");
            global::haxe.Log.trace = old;
        }
Пример #3
0
 public virtual void @add(global::haxe.unit.TestCase c)
 {
     this.cases.@add(c);
 }
Пример #4
0
 public static void __hx_ctor_haxe_unit_TestCase(global::haxe.unit.TestCase __hx_this)
 {
 }