コード例 #1
0
ファイル: BscHelperTest.cs プロジェクト: Qorpent/qorpent.sys
        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());
        }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: BscHelperTest.cs プロジェクト: Qorpent/qorpent.sys
        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");
        }
コード例 #4
0
ファイル: BscHelperTest.cs プロジェクト: Qorpent/qorpent.sys
        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());
        }
コード例 #5
0
ファイル: BscHelperTest.cs プロジェクト: Qorpent/qorpent.sys
        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);
        }
コード例 #6
0
ファイル: BscHelperTest.cs プロジェクト: Qorpent/qorpent.sys
        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());
        }