public void StartsWithEmptyString()
            {
                var result = ScriptProcessorFactory.Run("var str = new String('Hello World'); str.startsWith('');");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(((SBool)result).Value, false);
            }
Beispiel #2
0
            public void PopItem()
            {
                var result = ScriptProcessorFactory.Run("var arr = [32]; arr.pop();");

                Assert.IsTrue(result is SNumber);
                Assert.AreEqual(32, ((SNumber)result).Value);
            }
Beispiel #3
0
            public void IndexerSetOutOfRange()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1, 2, 3]; arr[3] = 4; arr[3];");

                Assert.IsTrue(result is SNumber);
                Assert.AreEqual(4, ((SNumber)result).Value);
            }
Beispiel #4
0
            public void FirstSingleRecord()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1]; arr.first();");

                Assert.IsTrue(result is SNumber);
                Assert.AreEqual(1, ((SNumber)result).Value);
            }
Beispiel #5
0
            public void CountEmpty()
            {
                var result = ScriptProcessorFactory.Run("var arr = []; arr.count();");

                Assert.IsTrue(result is SNumber);
                Assert.AreEqual(0, ((SNumber)result).Value);
            }
Beispiel #6
0
            public void AllUndefined()
            {
                var result = ScriptProcessorFactory.Run("var arr = [undefined,,,undefined]; arr.all(m => m == undefined);");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(true, ((SBool)result).Value);
            }
Beispiel #7
0
            public void Where()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1, 2, 3]; arr.where(m => m > 1);");

                Assert.IsTrue(result is SArray);
                Assert.AreEqual(2, ((SArray)result).ArrayMembers.Length);
            }
            public void CharAtNoArg()
            {
                var result = ScriptProcessorFactory.Run("var str = new String('Hello World'); str.charAt();");

                Assert.IsTrue(result is SString);
                Assert.AreEqual(((SString)result).Value, "H");
            }
            public void ConcatTwoStrings()
            {
                var result = ScriptProcessorFactory.Run("var str = new String('Hello, '); str.concat('Kevin', ' have a nice day.');");

                Assert.IsTrue(result is SString);
                Assert.AreEqual(((SString)result).Value, "Hello, Kevin have a nice day.");
            }
Beispiel #10
0
            public void IncludesNotEqualTypes()
            {
                var result = ScriptProcessorFactory.Run("var str = new String('Hello 42 World'); str.includes(42);");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(((SBool)result).Value, true);
            }
Beispiel #11
0
            public void CharAtEmptyString()
            {
                var result = ScriptProcessorFactory.Run("var str = new String(''); str.charAt(0);");

                Assert.IsTrue(result is SString);
                Assert.AreEqual(((SString)result).Value, "");
            }
Beispiel #12
0
            public void IncludesEmptyString()
            {
                var result = ScriptProcessorFactory.Run("var str = new String(''); str.includes('');");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(((SBool)result).Value, true);
            }
Beispiel #13
0
            public void EndsWithEmptyStringOnEmptyString()
            {
                var result = ScriptProcessorFactory.Run("var str = new String(''); str.endsWith('');");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(((SBool)result).Value, true);
            }
Beispiel #14
0
            public void EndsWithNegative()
            {
                var result = ScriptProcessorFactory.Run("var str = new String('Hello World'); str.endsWith('Hello');");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(((SBool)result).Value, false);
            }
Beispiel #15
0
            public void AllContains()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1, 2, 3]; arr.all(m => m > 0);");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(true, ((SBool)result).Value);
            }
Beispiel #16
0
            public void ConcatNonString()
            {
                var result = ScriptProcessorFactory.Run("var str = new String('Hello, '); str.concat(42, undefined);");

                Assert.IsTrue(result is SString);
                Assert.AreEqual(((SString)result).Value, "Hello, 42undefined");
            }
Beispiel #17
0
            public void AllUndefinedCheck()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1, \"2\", 3]; arr.all(m => m != undefined);");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(true, ((SBool)result).Value);
            }
Beispiel #18
0
            public void RemoveBeginEndNegative()
            {
                var result = ScriptProcessorFactory.Run("var str = new String('Hello World'); str.remove(0, -1);");

                Assert.IsTrue(result is SString);
                Assert.AreEqual("Hello World", ((SString)result).Value);
            }
Beispiel #19
0
            public void ArrayLengthInitializer()
            {
                var result = ScriptProcessorFactory.Run("var arr = new Array(2); arr;");

                Assert.IsTrue(result is SArray);
                Assert.AreEqual(2, ((SArray)result).ArrayMembers.Length);
            }
Beispiel #20
0
            public void IncludesContains()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1, 2, 3]; arr.includes(1);");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(true, ((SBool)result).Value);
            }
Beispiel #21
0
            public void SingleMultipleRecordsWithFilter()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1, 2, 3]; arr.single(m => m == 1);");

                Assert.IsTrue(result is SNumber);
                Assert.AreEqual(1, ((SNumber)result).Value);
            }
Beispiel #22
0
            public void IncludesNotEqualType()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1, \"2\", 3]; arr.includes(2);");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(true, ((SBool)result).Value);
            }
Beispiel #23
0
            public void Last()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1, 2, 3]; arr.last();");

                Assert.IsTrue(result is SNumber);
                Assert.AreEqual(3, ((SNumber)result).Value);
            }
Beispiel #24
0
            public void IncludesCustomComparer()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1, \"2\", 3]; arr.includes(2, (m, o => m === o));");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(false, ((SBool)result).Value);
            }
Beispiel #25
0
            public void CountWithFilter()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1, 2, 3]; arr.count(m => m > 1);");

                Assert.IsTrue(result is SNumber);
                Assert.AreEqual(2, ((SNumber)result).Value);
            }
Beispiel #26
0
            public void EmptyArrayInitialize()
            {
                var result = ScriptProcessorFactory.Run("var arr = []; arr;");

                Assert.IsTrue(result is SArray);
                Assert.AreEqual(0, ((SArray)result).ArrayMembers.Length);
            }
Beispiel #27
0
            public void IndexerSet()
            {
                var result = ScriptProcessorFactory.Run("var arr = [1, 0, 3]; arr[1] = 2; arr[1];");

                Assert.IsTrue(result is SNumber);
                Assert.AreEqual(2, ((SNumber)result).Value);
            }
Beispiel #28
0
            public void AnyNoConditionEmptyArray()
            {
                var result = ScriptProcessorFactory.Run("var arr = []; arr.any();");

                Assert.IsTrue(result is SBool);
                Assert.AreEqual(false, ((SBool)result).Value);
            }
Beispiel #29
0
            public void LengthEmptyArray()
            {
                var result = ScriptProcessorFactory.Run("var arr = []; arr.length;");

                Assert.IsTrue(result is SNumber);
                Assert.AreEqual(0, ((SNumber)result).Value);
            }
Beispiel #30
0
            public void LastIndexOfOnEmptyString()
            {
                var result = ScriptProcessorFactory.Run("var str = new String(''); str.lastIndexOf('Hello');");

                Assert.IsTrue(result is SNumber);
                Assert.AreEqual(((SNumber)result).Value, -1);
            }