public void Initialize()
        {
            Application = new Application(ApplicationName);
            Engine = new Engine();
            Loader = new Loader(Engine, Application);

            Dependencies = new List<string>();
            Root = new NullContext(Engine, Application, new string[0]);

            var slnPath = Environment.CurrentDirectory;
            while (Directory.Exists(slnPath) && !File.Exists(Path.Combine(slnPath, "Prexonite.sln")))
                slnPath = Path.Combine(slnPath, @".." + Path.DirectorySeparatorChar);

            if (Directory.Exists(slnPath))
            {
                var psrTestsPath =
                    Path.GetFullPath(Path.Combine(slnPath, @"PrexoniteTests\psr-tests"));
                Console.WriteLine("inferred psr-tests path: " + psrTestsPath, "Engine.Path");
                Engine.Paths.Add(psrTestsPath);

                var prxPath = Path.GetFullPath(Path.Combine(slnPath, @"Prx"));
                Console.WriteLine("inferred prx path: " + prxPath, "Engine.Path");
                Engine.Paths.Add(prxPath);
            }
            else
            {
                Console.WriteLine("CANNOT INFER solution PATH: " + slnPath, "Engine.Path");
            }
        }
Beispiel #2
0
        public void ReturnContinueFormTryFinally()
        {
            Compile(
                @"
function main()
{
    try
    {
        continue;
    } 
    finally
    {

    }
}
");

            var func = target.Functions["main"];

            var emptyArgV = new PValue[0];
            var emptyEnvironment = new PVariable[0];

            if (CompileToCil)
            {
                var nullContext = new NullContext(engine, target, new List<string>());
                Assert.IsTrue(func.HasCilImplementation, "main must have CIL implementation.");
                ReturnMode returnMode;
                PValue value;
                func.CilImplementation(
                    func, nullContext, emptyArgV, emptyEnvironment, out value, out returnMode);
                Assert.AreEqual(value.Type, PType.Null);
                Assert.AreEqual(returnMode, ReturnMode.Continue);
            }

            var fctx = func.CreateFunctionContext(engine, emptyArgV, emptyEnvironment);
            engine.Process(fctx);
            Assert.AreEqual(fctx.ReturnValue.Type, PType.Null);
            Assert.AreEqual(fctx.ReturnMode, ReturnMode.Continue);
        }
Beispiel #3
0
 public void CreateModuleNameCommand()
 {
     var cmd = CreateModuleName.Instance;
     var eng = new Engine();
     var app = new Application("cmnc");
     var sctx = new NullContext(eng, app, Enumerable.Empty<string>());
     var rawMn = cmd.Run(sctx, new[] {sctx.CreateNativePValue(new MetaEntry(new MetaEntry[]{"sys","1.0"}))});
     Assert.That(rawMn.Value,Is.InstanceOf<ModuleName>());
     var mn = (ModuleName) rawMn.Value;
     Assert.That(mn.Id,Is.EqualTo("sys"));
     Assert.That(mn.Version,Is.EqualTo(new Version(1,0)));
 }