Exemple #1
0
        private bool Test(int acode, EXPRESSION obj, List <TestFunctionGenerator.Test> tests, bool strict)
        {
            int code = acode - 1;

            // For send constants and terminal symbols are strict
            if (tests[code].type == TestFunctionGenerator.TestType.ConstantTest)
            {
                if (strict) //Strict
                {
                    if ((obj is LITERAL) && (((LITERAL)obj).val == tests[code].literal.val))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {   // There should be a type we can assign
                    return(TYPE.AssignmentCompatibilityS(obj.type, tests[code].literal.type));
                }
            }
            else if (tests[code].type == TestFunctionGenerator.TestType.TypeTest)
            {
                if (strict) //Strict
                {
                    return(TYPE.AssignmentCompatibilityS(tests[code].type_name, obj.type));
                }
                else
                {
                    if (obj.Name == "#unused")
                    {
                        return(true);
                    }
                    return(TYPE.AssignmentCompatibilityS(obj.type, tests[code].type_name));
                }
            }
            else if (tests[code].type == TestFunctionGenerator.TestType.TerminalTest)
            {
                if (strict) //Strict
                {
                    if ((obj is SELECTOR) && (((SELECTOR)obj).member == tests[code].enumerator))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {   // There should be a type we can assign
                    if (obj.Name == "#unused")
                    {
                        return(true);
                    }
                    return(TYPE.AssignmentCompatibilityS(obj.type, tests[code].enumerator.type));
                }
            }

            return(true);
        }