diff --git a/Src/IronPythonTest/Cases/CaseGenerator.cs b/Src/IronPythonTest/Cases/CaseGenerator.cs index fea1754ed..b1f39575b 100644 --- a/Src/IronPythonTest/Cases/CaseGenerator.cs +++ b/Src/IronPythonTest/Cases/CaseGenerator.cs @@ -5,6 +5,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Collections.Specialized; using System.Data; using System.IO; using System.Runtime.InteropServices; @@ -105,8 +106,9 @@ protected bool ConditionMatched(string condition) { private bool EvaluateExpression(string expression) { var dummy = new DataTable(); string filter = expression; - var replacements = new Dictionary() { + var replacements = new OrderedDictionary() { // variables + { "$(FRAMEWORK)", IronPython.Runtime.ClrModule.TargetFramework }, { "$(IS_NETCOREAPP)", IronPython.Runtime.ClrModule.IsNetCoreApp.ToString() }, { "$(IS_NETSTANDARD)", IronPython.Runtime.ClrModule.TargetFramework.StartsWith(".NETStandard", StringComparison.Ordinal).ToString() }, { "$(IS_MONO)", IronPython.Runtime.ClrModule.IsMono.ToString() }, @@ -119,20 +121,20 @@ private bool EvaluateExpression(string expression) { // operators { "==", "=" }, { "||", "OR" }, + { "\"", "'" }, // replace double quotes before double-double quotes { "\"\"", "\"" }, - { "\"", "'" }, { "&&", "AND" }, - { "!=", "<>" } + { "!=", "<>" }, }; - foreach (var replacement in replacements) { - expression = expression.Replace(replacement.Key, replacement.Value); + foreach (DictionaryEntry replacement in replacements) { + expression = expression.Replace((string)replacement.Key, replacement.Value?.ToString()); } try { object res = dummy.Compute(expression, null); - if (res is bool) { - return (bool)res; + if (res is bool result) { + return result; } } catch (EvaluateException ex) { if (ex.Message.StartsWith("The expression contains undefined function call", StringComparison.Ordinal))