Run() static private method

static private Run ( string source ) : SObject
source string
return Pokemon3D.Scripting.Types.SObject
示例#1
0
        public void PowerTests()
        {
            var result = ScriptProcessorFactory.Run("2**3");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 8);
        }
示例#2
0
        public void IncrementTests()
        {
            var result = ScriptProcessorFactory.Run("var a = 13; a++; a;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 14);
        }
示例#3
0
        public void DecrementTests()
        {
            var result = ScriptProcessorFactory.Run("var b = 13; b--; b;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 12);
        }
示例#4
0
        public void DivisionTests()
        {
            var result = ScriptProcessorFactory.Run("15/5");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 3);
        }
示例#5
0
        public void MultiplicationTests()
        {
            var result = ScriptProcessorFactory.Run("5*3*-4");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, -60);
        }
示例#6
0
        public void LogicalOrTests()
        {
            var result = ScriptProcessorFactory.Run("true || false");

            Assert.IsTrue(result is SBool);
            Assert.AreEqual(((SBool)result).Value, true);
        }
示例#7
0
        public void ModuloTests()
        {
            var result = ScriptProcessorFactory.Run("5%2");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 1);
        }
示例#8
0
        public void CustomFunctionTests()
        {
            var result = ScriptProcessorFactory.Run("class testClass { var member = 0; function customFunction() { this.member = 3; } } var test = new testClass(); test.customFunction(); test.member;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 3);
        }
示例#9
0
        public void InterpolationTests()
        {
            var result = ScriptProcessorFactory.Run("var insert = \"{{World}}\"; var outer = $\"{{Hello}}, {insert}!\"; outer;");

            Assert.IsTrue(result is SString);
            Assert.AreEqual("{Hello}, {{World}}!", ((SString)result).Value);
        }
示例#10
0
        public void BreakTests()
        {
            var result = ScriptProcessorFactory.Run("var a = 0; for (var i = 0; i < 10; i++) { if (i > 5) { break; } a++; } a;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 6);
        }
示例#11
0
        public void AdditionTests()
        {
            var result = ScriptProcessorFactory.Run("1+4+6");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 11);
        }
示例#12
0
        public void ForLoopTests()
        {
            var result = ScriptProcessorFactory.Run("var a = 0; for (var i = 0; i < 10; i++) { a++; } a;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 10);
        }
示例#13
0
        public void ContinueTests()
        {
            var result = ScriptProcessorFactory.Run("var a = 0; for (var i = 0; i < 10; i++) { if (i % 2 == 0) { a++; } } a;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 5);
        }
示例#14
0
        public void AbstractTests()
        {
            var result = ScriptProcessorFactory.Run("class abstract baseClass { } var test = new baseClass();");

            // cannot instanciate abstract class:
            Assert.IsTrue(result is SError);
        }
示例#15
0
        public void IfElseTests()
        {
            var result = ScriptProcessorFactory.Run("var a = 0; if (a > 0) { a = 5; } else { a = 10; } a;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 10);
        }
示例#16
0
        public void PropertyTests()
        {
            var result = ScriptProcessorFactory.Run("class testClass { var member = 0; function property get Member() { return member; } function property set Member(value) { member = value; } } var test = new testClass(); test.Member = 3; test.Member;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 3);
        }
示例#17
0
        public void IndexerTests()
        {
            var result = ScriptProcessorFactory.Run("class testClass { var member = 0; function indexer get indexerGet(accessor) { return this.member * accessor; } function indexer set indexerSet(accessor, value) { this.member = value / accessor; } } var test = new testClass(); test[3] = 9; test[3];");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 9);
        }
示例#18
0
        public void StaticVarTests()
        {
            var result = ScriptProcessorFactory.Run("class testClass { var static member = 0; } testClass.member = 3; testClass.member;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 3);
        }
示例#19
0
        public void StaticFunctionTests()
        {
            var result = ScriptProcessorFactory.Run("class testClass { var static member = 0; function static testFunction() { member = 3; } } testClass.testFunction(); testClass.member;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 3);
        }
示例#20
0
        public void ReadonlyVarTests()
        {
            var result = ScriptProcessorFactory.Run("class testClass { var readonly member = 0; } var test = new testClass(); test.member = 3; test.member;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 0);
        }
示例#21
0
        public void SubtractionTests()
        {
            var result = ScriptProcessorFactory.Run("12-4-6");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 2);
        }
示例#22
0
        public void VariableDeclarationTests()
        {
            var result = ScriptProcessorFactory.Run("class testClass { var member = 3 } var test = new testClass(); test.member;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 3);
        }
示例#23
0
        public void ExtendsTests()
        {
            var result = ScriptProcessorFactory.Run("class abstract baseClass { var member = 3; function baseFunction() { this.member += 2; } } class extendingClass extends baseClass { function extendsFunction() { baseFunction(); } } var test = new extendingClass(); test.extendsFunction(); test.member;");

            Assert.IsTrue(result is SNumber);
            Assert.AreEqual(((SNumber)result).Value, 5);
        }
示例#24
0
        public void InstanciationTests()
        {
            var result = ScriptProcessorFactory.Run("class testClass { } var test = new testClass(); test;");

            Assert.IsTrue(result is SProtoObject);
            var protoObj = (SProtoObject)result;

            Assert.AreEqual(protoObj.Prototype.Name, "testClass");
        }