hasNodes() public method

public hasNodes ( ) : bool
return bool
        public void test()
        {
            loadInParser("large_body_text_without_pipes.jade");
            tagNode = (TagNode) root.pollNode();
            Assert.AreEqual(tagNode.getName(), ("p"));

            textNode = (TextNode) tagNode.getTextNode();
            Assert.IsNotNull(textNode.getValue());
            Assert.AreEqual(textNode.getValue(), ("Hello World!\nHere comes the Message!"));
            Assert.AreEqual(textNode.hasNodes(), (false));

            tagNode = (TagNode) root.pollNode();
            Assert.AreEqual(tagNode.getName(), ("div"));
            block = tagNode.getBlock();
            Assert.IsNotNull(block);

            tagNode = (TagNode) block.pollNode();
            Assert.AreEqual(tagNode.getName(), ("h1"));

            textNode = (TextNode) tagNode.getTextNode();
            Assert.IsNotNull(textNode.getValue());
            Assert.AreEqual(textNode.getValue(), ("Hello World!\nHere comes the second Message!"));
            Assert.AreEqual(textNode.hasNodes(), (false));

            tagNode = (TagNode) block.pollNode();
            Assert.AreEqual(tagNode.getName(), ("h2"));

            textNode = (TextNode) tagNode.getTextNode();
            Assert.IsNotNull(textNode.getValue());
            Assert.AreEqual(textNode.getValue(), ("Hello World!\nHere comes the third Message!"));
            Assert.AreEqual(textNode.hasNodes(), (false));

            Assert.AreEqual(block.hasNodes(), (false));
            Assert.AreEqual(root.hasNodes(), (false));
        }
Ejemplo n.º 2
0
        public void shouldReturnABlockWithTokens2()
        {
            loadInParser("tags_with_attributes.jade");
            block = (BlockNode) root;
            Assert.IsNotNull(block.getNodes());

            // .myclass(title="my first div" alt="alt does not fit here")
            tag1 = block.pollNode();
            Assert.AreEqual(((TagNode) tag1).getAttribute("class"), ("myclass"));
            Assert.AreEqual(((TagNode) tag1).getAttribute("title"), ("my first div"));
            Assert.AreEqual(((TagNode) tag1).getAttribute("alt"), ("alt does not fit here"));
            Assert.AreEqual(block.hasNodes(), (true));

            // #myid.c1.c2.c3(title="the third div with attribute")
            tag2 = block.pollNode();
            Assert.AreEqual(((TagNode) tag2).getAttribute("id"), ("myid"));
            Assert.AreEqual(((TagNode) tag2).getAttribute("class"), ("c1 c2 c3"));
            Assert.AreEqual(((TagNode) tag2).getAttribute("title"), ("the third div with attribute"));
            Assert.AreEqual(block.hasNodes(), (false));

            // .c1.c2.c3(title="the second div with attribute")
            block = ((TagNode) tag1).getBlock();
            tag3 = block.pollNode();
            Assert.AreEqual(((TagNode) tag3).getAttribute("class"), ("c1 c2 c3"));
            Assert.AreEqual(((TagNode) tag3).getAttribute("title"), ("the second div with attribute"));
            Assert.AreEqual(block.hasNodes(), (true));

            // #myid
            tag3 = block.pollNode();
            Assert.AreEqual(((TagNode) tag3).getAttribute("id"), ("myid"));
            Assert.AreEqual(block.hasNodes(), (false));

            // div#id1
            block = ((TagNode) tag2).getBlock();
            tag1 = block.pollNode();
            Assert.AreEqual(((TagNode) tag1).getAttribute("id"), ("id1"));
            Assert.AreEqual(block.hasNodes(), (false));

            // span#id2.c1.c2.c3.c4(alt="alt")
            block = ((TagNode) tag1).getBlock();
            tag1 = block.pollNode();
            Assert.AreEqual(((TagNode) tag1).getValue(), ("span"));
            Assert.AreEqual(((TagNode) tag1).getAttribute("id"), ("id2"));
            Assert.AreEqual(((TagNode) tag1).getAttribute("class"), ("c1 c2 c3 c4"));
            Assert.AreEqual(((TagNode) tag1).getAttribute("alt"), ("alt"));
            Assert.AreEqual(block.hasNodes(), (false));
        }
Ejemplo n.º 3
0
        public void shouldReturnABlockWithTokens2()
        {
            loadInParser("css_class_and_id.jade");
            block = (BlockNode) root;
            Assert.IsNotNull(block.getNodes());

            // .myclass
            tag1 = block.pollNode();
            Assert.AreEqual(((TagNode) tag1).getAttribute("class"), ("myclass"));
            Assert.AreEqual(block.hasNodes(), (true));

            // #myid.c1.c2.c3
            tag2 = block.pollNode();
            Assert.AreEqual(((TagNode) tag2).getAttribute("id"), ("myid"));
            Assert.AreEqual(((TagNode) tag2).getAttribute("class"), ("c1 c2 c3"));
            Assert.AreEqual(block.hasNodes(), (false));

            // .c1.c2.c3
            // #myid
            block = ((TagNode) tag1).getBlock();
            tag3 = block.pollNode();
            Assert.AreEqual(((TagNode) tag3).getAttribute("class"), ("c1 c2 c3"));
            Assert.AreEqual(block.hasNodes(), (true));
            tag3 = block.pollNode();
            Assert.AreEqual(((TagNode) tag3).getAttribute("id"), ("myid"));
            Assert.AreEqual(block.hasNodes(), (false));

            // div#id1
            block = ((TagNode) tag2).getBlock();
            tag1 = block.pollNode();
            Assert.AreEqual(((TagNode) tag1).getAttribute("id"), ("id1"));
            Assert.AreEqual(block.hasNodes(), (false));

            // span#id2.c1.c2.c3.c4
            block = ((TagNode) tag1).getBlock();
            tag1 = block.pollNode();
            Assert.AreEqual(((TagNode) tag1).getValue(), ("span"));
            Assert.AreEqual(((TagNode) tag1).getAttribute("id"), ("id2"));
            Assert.AreEqual(((TagNode) tag1).getAttribute("class"), ("c1 c2 c3 c4"));
            Assert.AreEqual(block.hasNodes(), (false));
        }
Ejemplo n.º 4
0
        public void shouldReturnTagsWithTexts()
        {
            loadInParser("tags_with_text.jade");
            block = (BlockNode) root;
            Assert.IsNotNull(block.getNodes());
            Assert.AreEqual(block.getNodes().Count, (2));

            tag1 = (TagNode) block.pollNode();
            Assert.AreEqual(((TagNode) tag1).getAttribute("class"), ("myclass"));
            Assert.IsNotNull(((TagNode) tag1).getTextNode());
            Assert.AreEqual(((TagNode) tag1).getTextNode().getValue(), ("Hello World!"));
            Assert.AreEqual(block.hasNodes(), (true));

            tag2 = block.pollNode();
            Assert.AreEqual(((TagNode) tag2).getAttribute("id"), ("myid2"));
            Assert.AreEqual(((TagNode) tag2).getTextNode().getValue(), ("without words"));
            Assert.AreEqual(block.hasNodes(), (false));

            block = ((TagNode) tag1).getBlock();
            tag = block.pollNode();
            Assert.AreEqual(((TagNode) tag).getAttribute("class"), ("c1"));
            Assert.AreEqual(((TagNode) tag).getTextNode().getValue(), ("The quick brown fox"));
            Assert.AreEqual(block.hasNodes(), (true));

            tag = block.pollNode();
            Assert.AreEqual(((TagNode) tag).getAttribute("class"), ("c2"));
            Assert.AreEqual(((TagNode) tag).getAttribute("id"), ("myid"));
            Assert.AreEqual(((TagNode) tag).getTextNode().getValue(), ("jumpes over the lazy dog"));
            Assert.AreEqual(block.hasNodes(), (false));

            block = ((TagNode) tag2).getBlock();
            tag = block.pollNode();
            Assert.AreEqual(((TagNode) tag).getAttribute("id"), ("id1"));
            Assert.AreEqual(((TagNode) tag).getTextNode().getValue(), ("without music"));
            Assert.AreEqual(block.hasNodes(), (false));
        }
Ejemplo n.º 5
0
        public void test()
        {
            loadInParser("large_body_text_with_pipes.jade");
            pTag = (TagNode) root.pollNode();
            block = pTag.getBlock();
            Assert.IsNotNull(block.getNodes());
            Assert.IsNotNull(pTag);

            block = pTag.getBlock();
            Assert.IsNotNull(block.getNodes());

            Assert.IsNotNull(block.pollNode().getValue(), "Hello World!");
            Assert.IsNotNull(block.pollNode().getValue(), " Here comes the Message!");

            Assert.IsFalse(block.hasNodes());
        }
        public void shouldReturnABlockWithTokens2()
        {
            loadInParser("complex_indent_outdent_file.jade");
            block = (BlockNode) root;
            Assert.IsNotNull(block.getNodes());

            head = block.pollNode();
            body = block.pollNode();
            Assert.AreEqual(head.getValue(), ("head"));
            Assert.AreEqual(body.getValue(), ("body"));
            Assert.AreEqual(block.hasNodes(), (false));

            block = ((TagNode) head).getBlock();
            Assert.AreEqual(block.pollNode().getValue(), ("meta"));
            Assert.AreEqual(block.pollNode().getValue(), ("meta"));
            Assert.AreEqual(block.hasNodes(), (false));

            block = ((TagNode) body).getBlock();
            Assert.AreEqual(block.pollNode().getValue(), ("div0"));

            div1 = block.pollNode();
            Assert.AreEqual(div1.getValue(), ("div1"));

            div2 = block.pollNode();
            Assert.AreEqual(div2.getValue(), ("div2"));

            div3 = block.pollNode();
            Assert.AreEqual(div3.getValue(), ("div3"));

            div4 = block.pollNode();
            Assert.AreEqual(div4.getValue(), ("div4"));

            div5 = block.pollNode();
            Assert.AreEqual(div5.getValue(), ("div5"));

            Assert.AreEqual(block.hasNodes(), (false));

            // ===============================================

            block = ((TagNode) div1).getBlock();
            Assert.AreEqual(block.pollNode().getValue(), ("span"));
            Assert.AreEqual(block.pollNode().getValue(), ("span"));
            Assert.AreEqual(block.hasNodes(), (false));

            // ===============================================

            block = ((TagNode) div2).getBlock();
            ul1 = block.pollNode();
            Assert.AreEqual(ul1.getValue(), ("ul1"));
            ul2 = block.pollNode();
            Assert.AreEqual(ul2.getValue(), ("ul2"));
            Assert.AreEqual(block.hasNodes(), (false));

            // ===============================================

            block = ((TagNode) div3).getBlock();
            Assert.AreEqual(block.pollNode().getValue(), ("span"));
            Assert.AreEqual(block.hasNodes(), (false));

            // ===============================================

            block = ((TagNode) div4).getBlock();
            Assert.AreEqual(block.pollNode().getValue(), ("h1"));
            Assert.AreEqual(block.hasNodes(), (false));

            // ===============================================

            block = ((TagNode) div5).getBlock();
            div6 = block.pollNode();
            Assert.AreEqual(div6.getValue(), ("div6"));
            div7 = block.pollNode();
            Assert.AreEqual(div7.getValue(), ("div7"));
            Assert.AreEqual(block.hasNodes(), (false));

            // ===============================================

            block = ((TagNode) div6).getBlock();
            div8 = block.pollNode();
            Assert.AreEqual(div8.getValue(), ("div8"));
            Assert.AreEqual(block.hasNodes(), (false));

            // ===============================================

            block = ((TagNode) div8).getBlock();
            span = block.pollNode();
            Assert.AreEqual(span.getValue(), ("span"));
            Assert.AreEqual(block.hasNodes(), (false));

            // ===============================================

            block = ((TagNode) span).getBlock();
            em = block.pollNode();
            Assert.AreEqual(em.getValue(), ("em"));
            Assert.AreEqual(block.hasNodes(), (false));

            // ===============================================

            block = ((TagNode) div7).getBlock();
            Assert.AreEqual(block.pollNode().getValue(), ("span"));
            Assert.AreEqual(block.hasNodes(), (false));
        }