Exemplo n.º 1
0
        public void TestFunctionAssignment()
        {
            string code = "Backbone.View = function(options) {}";
            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            Assert.IsTrue(parser.NextIsFunction());
            Assert.AreEqual("Backbone.View(options)", parser.GetFunctionName());
        }
Exemplo n.º 2
0
        public void TestAdvanceAndReturnThrowsIfNextIsNotFunction()
        {
            string code = "class X { function BFunction() {}";

            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            parser.GetFunctionName();
        }
Exemplo n.º 3
0
        public void TestFunctionNameWithColon()
        {
            string code = "bind: function(ev, callback) { ... }";

            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            Assert.AreEqual("bind(ev,callback)", parser.GetFunctionName());
        }
Exemplo n.º 4
0
        public void TestCanExtractNameOfFunctionWithTwoParams()
        {
            string code = "function Test(segmentA, segmentB) { }";

            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            Assert.AreEqual("Test(segmentA,segmentB)", parser.GetFunctionName());
            Assert.AreEqual("{", textParser.NextKeyword());
        }
Exemplo n.º 5
0
        public void TestAnonymousFunctionIsNameAnonymous()
        {
            string code = "function (par1,par2) { }";
            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            Assert.IsTrue(parser.NextIsFunction());

            Assert.AreEqual("function(par1,par2)", parser.GetFunctionName());
        }
Exemplo n.º 6
0
        public void TestCanFindTypeScriptFunctionWithReturnType()
        {
            string code = "function greet(): int { }";

            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            Assert.IsTrue(parser.NextIsFunction());
            Assert.AreEqual("greet()", parser.GetFunctionName());
            Assert.AreEqual("{", textParser.NextKeyword());
        }
Exemplo n.º 7
0
        public void TestAnonFunctionWithoutParametersRecognizedAsFunction()
        {
            string code = "greet() { }";

            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            Assert.IsTrue(parser.NextIsFunction());
            Assert.AreEqual("greet()", parser.GetFunctionName());
            Assert.AreEqual("{", textParser.PeekNextKeyword());
        }
Exemplo n.º 8
0
        public void TestMethodNamesWithDoubleNamesAreRecognized()
        {
            string code = "AFunction: function BFunction() {}";

            LookAheadLangParser textParser = LookAheadLangParser.CreateJavascriptParser(TestUtil.GetTextStream(code));
            var parser = new JSParser(textParser);

            Assert.IsTrue(parser.NextIsFunction());
            Assert.AreEqual("BFunction()", parser.GetFunctionName());
            Assert.AreEqual("{", textParser.PeekNextKeyword());
        }