当前位置: 首页>>代码示例>>C#>>正文


C# Interpreter.DetectIdentifiers方法代码示例

本文整理汇总了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());
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:10,代码来源:DetectIdentifiersTest.cs

示例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());
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:10,代码来源:DetectIdentifiersTest.cs

示例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());
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:10,代码来源:DetectIdentifiersTest.cs

示例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());
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:10,代码来源:DetectIdentifiersTest.cs

示例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());
			}
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:15,代码来源:DetectIdentifiersTest.cs

示例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());
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:11,代码来源:DetectIdentifiersTest.cs

示例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());
			}
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:31,代码来源:DetectIdentifiersTest.cs

示例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);
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:10,代码来源:DetectIdentifiersTest.cs

示例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);
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:12,代码来源:DetectIdentifiersTest.cs

示例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());
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:10,代码来源:DetectIdentifiersTest.cs

示例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());
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:10,代码来源:DetectIdentifiersTest.cs

示例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());
		}
开发者ID:CooperLiu,项目名称:DynamicExpresso,代码行数:11,代码来源:DetectIdentifiersTest.cs


注:本文中的Interpreter.DetectIdentifiers方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。