Example #1
0
        public static void InterpretTest(Context context, String testName)
        {
            TestMethodDeclaration test = context.getTest(testName);
            Context local = context.newLocalContext();

            test.interpret(local);
        }
Example #2
0
        public bool interpretAssert(Context context, TestMethodDeclaration test)
        {
            IValue lval = left.interpret(context);

            if (!(lval is BooleanValue))
            {
                throw new SyntaxError("Illegal: " + lval.GetType().Name + " and ..., expected a Boolean");
            }
            IValue rval = lval;

            if (((BooleanValue)lval).Value)
            {
                rval = right.interpret(context);
                if (!(rval is BooleanValue))
                {
                    throw new SyntaxError("Illegal: " + lval.GetType().Name + " and " + rval.GetType().Name);
                }
            }
            if (rval == BooleanValue.TRUE)
            {
                return(true);
            }
            CodeWriter writer = new CodeWriter(test.Dialect, context);

            this.ToDialect(writer);
            String expected = writer.ToString();
            String actual   = lval + operatorToDialect(test.Dialect) + rval;

            test.printAssertionFailed(context, expected, actual);
            return(false);
        }
Example #3
0
 public void registerDeclaration(TestMethodDeclaration declaration)
 {
     if (tests.ContainsKey(declaration.GetName()))
     {
         throw new SyntaxError("Duplicate test: \"" + declaration.GetName() + "\"");
     }
     tests[declaration.GetName()] = declaration;
 }
Example #4
0
        public bool interpretAssert(Context context, TestMethodDeclaration testMethodDeclaration)
        {
            IValue value = this.interpret(context);

            if (value is prompto.value.BooleanValue)
            {
                return(((prompto.value.BooleanValue)value).Value);
            }
            else
            {
                CodeWriter writer = new CodeWriter(this.Dialect, context);
                this.ToDialect(writer);
                throw new SyntaxError("Cannot test '" + writer.ToString() + "'");
            }
        }
Example #5
0
 public bool interpretAssert(Context context, TestMethodDeclaration testMethodDeclaration)
 {
     if (resolved == null)
     {
         resolveAndCheck(context);
     }
     if (resolved is IAssertion)
     {
         return(((IAssertion)resolved).interpretAssert(context, testMethodDeclaration));
     }
     else
     {
         CodeWriter writer = new CodeWriter(this.Dialect, context);
         resolved.ToDialect(writer);
         throw new SyntaxError("Cannot test '" + writer.ToString() + "'");
     }
 }
Example #6
0
        public bool interpretAssert(Context context, TestMethodDeclaration test)
        {
            IValue val    = expression.interpret(context);
            IValue result = interpret(val);

            if (result == BooleanValue.TRUE)
            {
                return(true);
            }
            CodeWriter writer = new CodeWriter(test.Dialect, context);

            this.ToDialect(writer);
            String expected = writer.ToString();
            String actual   = operatorToDialect(test.Dialect) + val.ToString();

            test.printAssertionFailed(context, expected, actual);
            return(false);
        }
Example #7
0
        public bool interpretAssert(Context context, TestMethodDeclaration test)
        {
            IValue lval   = left.interpret(context);
            IValue rval   = right.interpret(context);
            IValue result = compare(context, lval, rval);

            if (result == BooleanValue.TRUE)
            {
                return(true);
            }
            CodeWriter writer = new CodeWriter(test.Dialect, context);

            this.ToDialect(writer);
            String expected = writer.ToString();
            String actual   = lval.ToString() + " " + oper.ToString() + " " + rval.ToString();

            test.printAssertionFailed(context, expected, actual);
            return(false);
        }