public void BugInResolveAll() { File.WriteAllText(bxls, @" class A prototype=xxx "); Thread.Sleep(100); var ctx = BscHelper.Execute(dir); var find = ctx.ResolveAll("xxx"); Assert.AreEqual(1, find.Count()); }
private void Compile() { var dir = ResolvedFile; if (!Directory.Exists(ResolvedFile)) { dir = Path.GetDirectoryName(ResolvedFile); } var key = dir + "-" + ProjectName + "-" + Source.Hash; if (!_cache.ContainsKey(key)) { _cache[key] = BscHelper.Execute(dir, ProjectName); } Context = _cache[key]; this.Model = new PersistentModel().Setup(Context); }
public void CanBeUsedAsBasisForPersistentModel() { File.WriteAllText(bxls, @" require data TableBase mytable schema=test import IEntity "); var ctx = BscHelper.Execute(dir); Assert.AreEqual(0, ctx.GetErrors().Count()); var pm = new PersistentModel(); pm.Setup(ctx); var table = pm["test.mytable"]; Assert.NotNull(table); Assert.True(table.Fields["id"].DataType.Code == "long"); }
public void CanCompileClass() { File.WriteAllText(bxls, @" class A prototype=x hello world "); var ctx = BscHelper.Execute(dir); Assert.NotNull(ctx); Assert.AreEqual(0, ctx.GetErrors().Count()); var cls = ctx["A"]; Assert.NotNull(cls); Assert.AreEqual("x", cls.Prototype); Assert.AreEqual(@"<class code=""A"" prototype=""x"" fullcode=""A""> <hello code=""world"" /> </class>".LfOnly(), cls.Compiled.ToString().LfOnly()); }
public void CanCatchError() { File.WriteAllText(bxls, @" my A prototype=x hello world "); var ctx = BscHelper.Execute(dir); Assert.NotNull(ctx); Assert.AreEqual(1, ctx.GetErrors().Count()); var error = ctx.GetErrors().First(); Assert.AreEqual(BSharpErrorType.OrphanClass, error.Type); Assert.AreEqual("test.bxls", Path.GetFileName(error.LexInfo.File)); Assert.AreEqual(3, error.LexInfo.Line); Console.WriteLine(error.Message); Assert.AreEqual(@"OrphanClass:SourceIndexing В коде обнаружен участок, похожий на класс, но который нельзя связать ни с одной из имеющихся базовых классов или ключевым словом class (A,)", error.Message); }
public void CanCompileProject() { File.WriteAllText(mybxls, @" class B prototype=x hello world "); File.WriteAllText(bsproj, @" class myproj InputExtensions mybxls "); var ctx = BscHelper.Execute(dir, "myproj"); Assert.AreEqual(0, ctx.GetErrors().Count()); Assert.AreEqual(1, ctx.Get(BSharpContextDataType.Working).Count()); var cls = ctx["B"]; Assert.NotNull(cls); Assert.AreEqual("x", cls.Prototype); Assert.AreEqual(@"<class code=""B"" prototype=""x"" fullcode=""B""> <hello code=""world"" /> </class>".LfOnly(), cls.Compiled.ToString().LfOnly()); }