本文整理汇总了C#中Interpreter.DetectIdentifiers方法的典型用法代码示例。如果您正苦于以下问题:C# Interpreter.DetectIdentifiers方法的具体用法?C# Interpreter.DetectIdentifiers怎么用?C# Interpreter.DetectIdentifiers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interpreter
的用法示例。
在下文中一共展示了Interpreter.DetectIdentifiers方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: An_Unknown_Identifier_used_multiple_times_is_detected_only_once
public void An_Unknown_Identifier_used_multiple_times_is_detected_only_once()
{
var target = new Interpreter();
var detectedIdentifiers = target.DetectIdentifiers("x + x");
CollectionAssert.AreEqual(
new[] { "x" },
detectedIdentifiers.UnknownIdentifiers.ToArray());
}
示例2: With_case_insensitive_An_Unknown_Identifier_used_multiple_times_is_detected_only_once
public void With_case_insensitive_An_Unknown_Identifier_used_multiple_times_is_detected_only_once()
{
var target = new Interpreter(InterpreterOptions.DefaultCaseInsensitive);
var detectedIdentifiers = target.DetectIdentifiers("x + X");
CollectionAssert.AreEqual(
new[] { "x" },
detectedIdentifiers.UnknownIdentifiers.ToArray());
}
示例3: Detect_unknown_identifiers
public void Detect_unknown_identifiers()
{
var target = new Interpreter();
var detectedIdentifiers = target.DetectIdentifiers("x + y");
CollectionAssert.AreEqual(
new []{ "x", "y"},
detectedIdentifiers.UnknownIdentifiers.ToArray());
}
示例4: Detect_identifiers_null
public void Detect_identifiers_null()
{
var target = new Interpreter();
var detectedIdentifiers = target.DetectIdentifiers(null);
Assert.AreEqual(0, detectedIdentifiers.UnknownIdentifiers.Count());
Assert.AreEqual(0, detectedIdentifiers.Identifiers.Count());
Assert.AreEqual(0, detectedIdentifiers.Types.Count());
}
示例5: Should_detect_various_format_of_identifiers
public void Should_detect_various_format_of_identifiers()
{
var target = new Interpreter();
var validNames = new[] { "x", "y", "_z", "x23", "asdas_afsdf" };
foreach (var name in validNames)
{
var detectedIdentifiers = target.DetectIdentifiers(name);
CollectionAssert.AreEqual(
new[] { name },
detectedIdentifiers.UnknownIdentifiers.ToArray());
}
}
示例6: A_Known_Identifier_used_multiple_times_is_detected_only_once
public void A_Known_Identifier_used_multiple_times_is_detected_only_once()
{
var target = new Interpreter()
.SetVariable("x", 213);
var detectedIdentifiers = target.DetectIdentifiers("x + x");
CollectionAssert.AreEqual(
new[] { "x" },
detectedIdentifiers.Identifiers.Select(p => p.Name).ToArray());
}
示例7: Detect_identifiers_inside_other_expressions
public void Detect_identifiers_inside_other_expressions()
{
var testCases = new[] {
"x + y",
"x + y + 654",
"x + y + 654.564",
"x.method + y[0]",
"x+y",
"x[y]",
"x.method1.method2(y)",
"x + y + \"z\"",
"x + y + \"lorem ipsum\"",
@"x + y + ""literal \""2""",
"x + y + \"\"",
"x + y + 'z'",
"x + y + '\\a'",
"x + y + '\\''",
"x+y",
};
foreach (var testCase in testCases)
{
var target = new Interpreter();
var detectedIdentifiers = target.DetectIdentifiers(testCase);
Assert.AreEqual("x", detectedIdentifiers.UnknownIdentifiers.ElementAt(0));
Assert.AreEqual("y", detectedIdentifiers.UnknownIdentifiers.ElementAt(1));
Assert.AreEqual(2, detectedIdentifiers.UnknownIdentifiers.Count());
}
}
示例8: Detect_known_identifiers_types
public void Detect_known_identifiers_types()
{
var target = new Interpreter();
var detectedIdentifiers = target.DetectIdentifiers("string.Empty");
Assert.AreEqual(1, detectedIdentifiers.Types.Count());
Assert.AreEqual("string", detectedIdentifiers.Types.ElementAt(0).Name);
Assert.AreEqual(typeof(string), detectedIdentifiers.Types.ElementAt(0).Type);
}
示例9: Detect_known_identifiers_variables
public void Detect_known_identifiers_variables()
{
var target = new Interpreter()
.SetVariable("x", 3)
.SetVariable("y", 4);
var detectedIdentifiers = target.DetectIdentifiers("x + y");
Assert.AreEqual(2, detectedIdentifiers.Identifiers.Count());
Assert.AreEqual("x", detectedIdentifiers.Identifiers.ElementAt(0).Name);
Assert.AreEqual("y", detectedIdentifiers.Identifiers.ElementAt(1).Name);
}
示例10: With_case_insensitive_A_Known_Type_used_multiple_times_is_detected_only_once
public void With_case_insensitive_A_Known_Type_used_multiple_times_is_detected_only_once()
{
var target = new Interpreter(InterpreterOptions.DefaultCaseInsensitive);
var detectedIdentifiers = target.DetectIdentifiers("string.Empty + STRING.Empty");
CollectionAssert.AreEqual(
new[] { "string" },
detectedIdentifiers.Types.Select(p => p.Name).ToArray());
}
示例11: A_Known_Type_used_multiple_times_is_detected_only_once
public void A_Known_Type_used_multiple_times_is_detected_only_once()
{
var target = new Interpreter();
var detectedIdentifiers = target.DetectIdentifiers("string.Empty + string.Empty");
CollectionAssert.AreEqual(
new[] { "string" },
detectedIdentifiers.Types.Select(p => p.Name).ToArray());
}
示例12: With_case_insensitive_A_Known_Identifier_used_multiple_times_is_detected_only_once
public void With_case_insensitive_A_Known_Identifier_used_multiple_times_is_detected_only_once()
{
var target = new Interpreter(InterpreterOptions.DefaultCaseInsensitive)
.SetVariable("x", 213);
var detectedIdentifiers = target.DetectIdentifiers("x + X");
CollectionAssert.AreEqual(
new[] { "x" },
detectedIdentifiers.Identifiers.Select(p => p.Name).ToArray());
}