示例#1
0
        //public SymbolWithScope AssociatedSymbolWithScope { get { return (AssociatedScope is ScopeSymbolChild) ? ((ScopeSymbolChild)AssociatedScope).ParentLanguageSymbolWithScope : null; } }


        /// <summary>
        /// Create a root activation record
        /// </summary>
        /// <param name="interpreter">The controlling evaluator for this activation record</param>
        /// <param name="associatedScope">The associated scope</param>
        public ActivationRecord(ILanguageInterpreter <TSymbolData> interpreter, LanguageScope associatedScope)
        {
            Arid = CreateNewId();
            ParentInterpreter = interpreter;
            UpperStaticAr     = null;
            UpperDynamicAr    = null;
            AssociatedScope   = associatedScope;
        }
示例#2
0
        /// <summary>
        /// Test if a script is a <see cref="ProblemSolution"/>.
        /// </summary>
        /// <param name="script"><see cref="Script"/> to run.</param>
        /// <param name="interpreter"></param>
        /// <returns>bool</returns>
        public async Task <bool> TestScript(Script script, ILanguageInterpreter interpreter)
        {
            var  parameters = new ExecutionParameters(2000, 200000, null);
            var  results    = new List <ScriptEvaluation>();
            bool pass       = true;

            foreach (var testCase in TestCases)
            {
                parameters.Input = testCase.Input;
                var result = await interpreter.ExecuteAsync(script.Body, parameters);

                results.Add(result);
                pass = pass && result.Output.Trim() == testCase.ExpectedOutput;
            }
            return(pass);
        }