public override Failure?CheckCase(IReadOnlyDictionary <string, Value> inputs, IReadOnlyDictionary <string, Value> expectedOutputs, IExecutionState state, SerializedState?debugState)
        {
            // Check that the machine state is exactly correct for every expected output
            foreach (var(key, expected) in expectedOutputs)
            {
                var actual = state.TryGet(new VariableName($":{key}")) ?? (Value)0;

                // Add bonus points averaged across all cases
                switch (expected.Type, actual.Type)
                {
Exemple #2
0
        public virtual Failure?CheckCase(IReadOnlyDictionary <string, Value> inputs, IReadOnlyDictionary <string, Value> expectedOutputs, IExecutionState state)
        {
            // Check that the machine state is exactly correct for every expected output
            foreach (var(key, value) in expectedOutputs)
            {
                var v = state.TryGet($":{key}") ?? 0;
                if (v != value)
                {
                    var ii = string.Join(",", inputs.Select(b => $"`:{b.Key}={b.Value.ToHumanString()}`"));
                    var oo = string.Join(",", expectedOutputs.Select(b => $"`:{b.Key}={b.Value.ToHumanString()}`"));
                    return(new Failure(FailureType.IncorrectResult, $"For inputs {ii} expected outputs {oo}, got `:{key}={v.ToHumanString()}`"));
                }
            }

            // All variables ok, return null to indicate no failure
            return(null);
        }