Esempio n. 1
0
        public void EvalAssert(RCRunner runner, RCClosure closure, RCBoolean right)
        {
            for (int i = 0; i < right.Count; ++i)
            {
                if (!right[i])
                {
                    RCCube         target = new RCCube(new RCArray <string> ("S"));
                    Stack <object> names  = new Stack <object> ();
                    RCBlock        block  = new RCBlock("", ":", closure.Code);
                    block.Cubify(target, names);
                    ColumnBase column = target.GetColumn("r");

                    string expression;
                    if (column != null)
                    {
                        RCArray <string> refNames = (RCArray <string>)column.Array;
                        // Only display the variables whose values are referenced in the assert
                        // expression
                        RCBlock displayVars = RCBlock.Empty;
                        for (int j = 0; j < refNames.Count; ++j)
                        {
                            RCArray <string> nameParts = RCName.MultipartName(refNames[j], '.');
                            RCValue          val       = Eval.Resolve(null, closure, nameParts, null, returnNull: true);
                            if (val != null)
                            {
                                displayVars = new RCBlock(displayVars, refNames[j], ":", val);
                            }
                        }
                        expression = string.Format("{0}, {1}", closure.Code.ToString(), displayVars);
                    }
                    else
                    {
                        expression = string.Format("{0}", closure.Code.ToString());
                    }
                    throw new RCException(closure, RCErrors.Assert, "Failed: " + expression);
                }
            }
            runner.Yield(closure, new RCBoolean(true));
        }
Esempio n. 2
0
 public RCReference(string name)
 {
     Name  = name;
     Parts = RCName.MultipartName(name, '.');
     Parts.Lock();
 }