Beispiel #1
0
        public static bool PreAssert(ScriptContext context)
        {
            if (!context.Config.Assertion.Active)
            {
                return(false);
            }

            // disables error reporting if eval should be quite:
            if (context.Config.Assertion.Quiet)
            {
                context.DisableErrorReporting();
            }

            return(true);
        }
Beispiel #2
0
        public static bool Assert(
            object assertion,
            ScriptContext context,
            Dictionary <string, object> definedVariables,
            DObject self,
            DTypeDesc includer,
            string containingSourcePath,
            int line,
            int column,
            int containerId,
            NamingContext namingContext)
        {
            object result;
            string code;

            // skips asserts if not active:
            if (!context.Config.Assertion.Active)
            {
                return(true);
            }

            if ((code = PhpVariable.AsString(assertion)) != null)
            {
                // disables error reporting if eval should be quite:
                if (context.Config.Assertion.Quiet)
                {
                    context.DisableErrorReporting();
                }

                SourceCodeDescriptor descriptor = new SourceCodeDescriptor(containingSourcePath, containerId, line, column);

                // evaluates the expression:
                result = EvalInternal("return ", code, ";", EvalKinds.Assert, context, definedVariables, self, includer, descriptor, false, namingContext);

                // restores error reporting if eval have been quite:
                if (context.Config.Assertion.Quiet)
                {
                    context.EnableErrorReporting();
                }
            }
            else
            {
                result = assertion;
            }

            // checks the result of assertion:
            return(CheckAssertion(result, code, context, containingSourcePath, line, column, namingContext));
        }
Beispiel #3
0
		public static bool PreAssert(ScriptContext context)
		{
			if (!context.Config.Assertion.Active) return false;

			// disables error reporting if eval should be quite:
			if (context.Config.Assertion.Quiet) context.DisableErrorReporting();

			return true;
		}
Beispiel #4
0
		public static bool Assert(
			object assertion,
			ScriptContext context,
			Dictionary<string, object> definedVariables,
			DObject self,
			DTypeDesc includer,
			string containingSourcePath,
			int line,
			int column,
			int containerId,
			NamingContext namingContext)
		{
			object result;
			string code;

			// skips asserts if not active:
			if (!context.Config.Assertion.Active) return true;

			if ((code = PhpVariable.AsString(assertion)) != null)
			{
				// disables error reporting if eval should be quite:
				if (context.Config.Assertion.Quiet) context.DisableErrorReporting();

				SourceCodeDescriptor descriptor = new SourceCodeDescriptor(containingSourcePath, containerId, line, column);

				// evaluates the expression:
				result = EvalInternal("return ", code, ";", EvalKinds.Assert, context, definedVariables, self, includer, descriptor, false, namingContext);

				// restores error reporting if eval have been quite: 
				if (context.Config.Assertion.Quiet) context.EnableErrorReporting();
			}
			else
			{
				result = assertion;
			}

			// checks the result of assertion:
			return CheckAssertion(result, code, context, containingSourcePath, line, column, namingContext);
		}