<commit_before>using Boo.Lang.Compiler;
using Boo.Lang.Compiler.IO;
using Boo.Lang.Compiler.Pipelines;
using Boo.Lang.Compiler.TypeSystem;
using Boo.Lang.Compiler.TypeSystem.Core;
using Boo.Lang.Compiler.TypeSystem.Services;
using Boo.Lang.Environments;
using NUnit.Framework;

namespace BooCompiler.Tests.TypeSystem.Services
{
	[TestFixture]
	public class NameResolutionServiceTest
	{
		private IEntity ResolveQualifiedName(string qualifiedName)
		{
			return Subject().ResolveQualifiedName(qualifiedName);
		}

		private NameResolutionService Subject()
		{
			return My<NameResolutionService>.Instance;
		}

		private bool MatchIgnoringCase(IEntity candidate, string name)
		{
			return 0 == string.Compare(candidate.Name, name, true);
		}

		[Test]
		public void NameMatchingCanBeCustomized()
		{
			var parameters = new CompilerParameters();
			string code = @"
l = []
l.ADD(42)
l.add(42)
print JOIN(l, "", "")
";
			parameters.Input.Add(new StringInput("code", code));
			parameters.Pipeline = new ResolveExpressions();
			parameters.Pipeline.Insert(0,
			                           new ActionStep(
			                           	delegate(CompilerContext context) { context.NameResolutionService.EntityNameMatcher = MatchIgnoringCase; }));
			CompilerContext result = new Boo.Lang.Compiler.BooCompiler(parameters).Run();
			Assert.AreEqual(0, result.Errors.Count, result.Errors.ToString());
		}

		[Test]
		public void ResolveQualifiedName()
		{
			new CompilerContext().Run(delegate
				{
					Subject().EnterNamespace(My<GlobalNamespace>.Instance);
					IEntity result = ResolveQualifiedName("Boo.Lang");
					Assert.IsNotNull(result);
					Assert.AreEqual(EntityType.Namespace, result.EntityType);

					var builtinsType = ResolveQualifiedName("Boo.Lang.Builtins") as IType;
					Assert.IsNotNull(builtinsType);
				});<commit_msg>delegate to lambda<commit_after>using Boo.Lang.Compiler;
using Boo.Lang.Compiler.IO;
using Boo.Lang.Compiler.Pipelines;
using Boo.Lang.Compiler.TypeSystem;
using Boo.Lang.Compiler.TypeSystem.Core;
using Boo.Lang.Compiler.TypeSystem.Services;
using Boo.Lang.Environments;
using NUnit.Framework;

namespace BooCompiler.Tests.TypeSystem.Services
{
	[TestFixture]
	public class NameResolutionServiceTest
	{
		private IEntity ResolveQualifiedName(string qualifiedName)
		{
			return Subject().ResolveQualifiedName(qualifiedName);
		}

		private NameResolutionService Subject()
		{
			return My<NameResolutionService>.Instance;
		}

		private bool MatchIgnoringCase(IEntity candidate, string name)
		{
			return 0 == string.Compare(candidate.Name, name, true);
		}

		[Test]
		public void NameMatchingCanBeCustomized()
		{
			var parameters = new CompilerParameters();
			string code = @"
l = []
l.ADD(42)
l.add(42)
print JOIN(l, "", "")
";
			parameters.Input.Add(new StringInput("code", code));
			parameters.Pipeline = new ResolveExpressions();
			parameters.Pipeline.Insert(0, new ActionStep(
			                           	context => context.NameResolutionService.EntityNameMatcher = MatchIgnoringCase));
			CompilerContext result = new Boo.Lang.Compiler.BooCompiler(parameters).Run();
			Assert.AreEqual(0, result.Errors.Count, result.Errors.ToString());
		}

		[Test]
		public void ResolveQualifiedName()
		{
			new CompilerContext().Run(delegate
				{
					Subject().EnterNamespace(My<GlobalNamespace>.Instance);
					IEntity result = ResolveQualifiedName("Boo.Lang");
					Assert.IsNotNull(result);
					Assert.AreEqual(EntityType.Namespace, result.EntityType);

					var builtinsType = ResolveQualifiedName("Boo.Lang.Builtins") as IType;
					Assert.IsNotNull(builtinsType);
				});
{'fraction_non_alphanumeric': 0.11448275862068966, 'fraction_numerical': 0.0038620689655172414, 'mean_word_length': 4.293430656934307, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5833465', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1080, 'n_words': 197}