Assert() public static method

public static Assert ( bool cond, string msg ) : void
cond bool
msg string
return void
Beispiel #1
0
        static void Iterating()
        {
            var  arr  = new IntArray(new [] { 0, 1, 2, 3 });
            bool iter = true;
            int  i    = 0;
            int  c    = 0;

            foreach (var e in arr)
            {
                c++;
                if (e != i++)
                {
                    iter = false;
                }
            }
            Tests.Assert(iter, "Iterating over value array");
            Tests.Assert(c == arr.Length, "Iteration count");
        }
Beispiel #2
0
        public static void Tests_IllegalCalls()
        {
            var module_ = ScriptEngine.GetModule("test", asEGMFlags.asGM_ALWAYS_CREATE);

            module_.AddScriptSection("test", @"
int foo()
{
    return 1;
}
class TestClass
{
    int field;
    int method()
    {
        return field;
    }
}
TestClass Obj();
");
            module_.Build();
            var module = module_ as dynamic;

            try
            {
                module.Foobar();
                Tests.Assert(false, "Calling nonexisting function");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Calling nonexisting function");
            }
            try
            {
                var x = module.Ohmy;
                Tests.Assert(false, "Getting nonexisting global variable");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Getting nonexisting global variable");
            }
            try
            {
                module.Woosh = 5;
                Tests.Assert(false, "Setting nonexisting global variable");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Setting nonexisting global variable");
            }
            try
            {
                module.Obj.Boo();
                Tests.Assert(false, "Calling nonexisting method");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Calling nonexisting method");
            }
            try
            {
                var f = module.Obj.Field;
                Tests.Assert(false, "Getting nonexisting field");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Getting nonexisting field");
            }
            try
            {
                module.Obj.BrtmBrtm = 55;
                Tests.Assert(false, "Setting nonexisting field");
            }
            catch (RuntimeBinderException)
            {
                Tests.Assert(true, "Setting nonexisting field");
            }
        }
Beispiel #3
0
 static void assert(bool cond, string msg)
 {
     Tests.Assert(cond, msg);
 }