예제 #1
0
        public void DoesntMatchBadVariable()
        {
            var matchDict2 = "a! = { 'Alice': 7, 'Toby': 'Nuts' }";
            var matches    = PythonCodeCompletionProviderCommon.FindVariableStatementWithRegex(matchDict2, PythonCodeCompletionProviderCommon.dictRegex);

            Assert.AreEqual(0, matches.Count);
        }
예제 #2
0
        public void CanMatchIntSingleLine()
        {
            var matchDict = "a = 2";
            var matches   = PythonCodeCompletionProviderCommon.FindVariableStatementWithRegex(matchDict, PythonCodeCompletionProviderCommon.intRegex);

            Assert.AreEqual(1, matches.Count);
            Assert.IsTrue(matches.ContainsKey("a"));
            Assert.AreEqual("2", matches["a"]);
        }
예제 #3
0
        public void CanMatchBasicArrayVarSingleLine()
        {
            var matchArray = "a = []";
            var matches    = PythonCodeCompletionProviderCommon.FindVariableStatementWithRegex(matchArray, PythonCodeCompletionProviderCommon.arrayRegex);

            Assert.AreEqual(1, matches.Count);
            Assert.IsTrue(matches.ContainsKey("a"));
            Assert.AreEqual("[]", matches["a"]);
        }
예제 #4
0
        public void CanMatchBasicNumVarSingleLine()
        {
            var matchNumVar = "a = 5.0";
            var matches     = PythonCodeCompletionProviderCommon.FindVariableStatementWithRegex(matchNumVar, PythonCodeCompletionProviderCommon.doubleRegex);

            Assert.AreEqual(1, matches.Count);
            Assert.IsTrue(matches.ContainsKey("a"));
            Assert.AreEqual("5.0", matches["a"]);
        }
예제 #5
0
        public void CanMatchComplexDictVarMultiLine()
        {
            var matchDict2 = "\n\na = { 'Alice': 7, 'Toby': 'Nuts' }\nb = 5.0";
            var matches    = PythonCodeCompletionProviderCommon.FindVariableStatementWithRegex(matchDict2, PythonCodeCompletionProviderCommon.dictRegex);

            Assert.AreEqual(1, matches.Count);
            Assert.IsTrue(matches.ContainsKey("a"));
            Assert.AreEqual("{ 'Alice': 7, 'Toby': 'Nuts' }", matches["a"]);
        }