Return-Path: X-Original-To: apmail-incubator-flex-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-flex-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 56151D18F for ; Sat, 3 Nov 2012 00:51:58 +0000 (UTC) Received: (qmail 68622 invoked by uid 500); 3 Nov 2012 00:51:57 -0000 Delivered-To: apmail-incubator-flex-commits-archive@incubator.apache.org Received: (qmail 68596 invoked by uid 500); 3 Nov 2012 00:51:57 -0000 Mailing-List: contact flex-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: flex-dev@incubator.apache.org Delivered-To: mailing list flex-commits@incubator.apache.org Received: (qmail 68587 invoked by uid 99); 3 Nov 2012 00:51:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Nov 2012 00:51:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 03 Nov 2012 00:51:56 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 78C0223888FD; Sat, 3 Nov 2012 00:51:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1405247 - /incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java Date: Sat, 03 Nov 2012 00:51:36 -0000 To: flex-commits@incubator.apache.org From: gordonsmith@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121103005136.78C0223888FD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: gordonsmith Date: Sat Nov 3 00:51:36 2012 New Revision: 1405247 URL: http://svn.apache.org/viewvc?rev=1405247&view=rev Log: Falcon: Added a nontrivial test for parsing a tag. Added: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java (with props) Added: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java URL: http://svn.apache.org/viewvc/incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java?rev=1405247&view=auto ============================================================================== --- incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java (added) +++ incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java Sat Nov 3 00:51:36 2012 @@ -0,0 +1,81 @@ +package org.apache.flex.compiler.internal.tree.mxml; + +import static org.hamcrest.core.Is.is; +import static org.junit.Assert.assertThat; + +import org.apache.flex.compiler.tree.ASTNodeID; +import org.apache.flex.compiler.tree.metadata.IEventTagNode; +import org.apache.flex.compiler.tree.metadata.IMetaTagNode; +import org.apache.flex.compiler.tree.mxml.IMXMLFileNode; +import org.apache.flex.compiler.tree.mxml.IMXMLMetadataNode; +import org.junit.Test; + +/** + * JUnit tests for {@link MXMLMetadataNode}. + * + * @author Gordon Smith + */ +public class MXMLMetadataNodeTests extends MXMLNodeBaseTests +{ + private static String PREFIX = + "\n\t"; + + private static String POSTFIX = + "\n"; + + private static String EOL = "\n\t"; + + @Override + protected IMXMLFileNode getMXMLFileNode(String code) + { + return super.getMXMLFileNode(PREFIX + code + POSTFIX); + } + + private IMXMLMetadataNode getMXMLMetadataNode(String code) + { + IMXMLFileNode fileNode = getMXMLFileNode(code); + IMXMLMetadataNode node = (IMXMLMetadataNode)findFirstDescendantOfType(fileNode, IMXMLMetadataNode.class); + assertThat("getNodeID", node.getNodeID(), is(ASTNodeID.MXMLMetadataID)); + assertThat("getName", node.getName(), is("Metadata")); + return node; + } + + @Test + public void MXMLMetadataNode_empty1() + { + String code = ""; + IMXMLMetadataNode node = getMXMLMetadataNode(code); + assertThat("getChildCount", node.getChildCount(), is(0)); + } + + @Test + public void MXMLMetadataNode_empty2() + { + String code = ""; + IMXMLMetadataNode node = getMXMLMetadataNode(code); + assertThat("getChildCount", node.getChildCount(), is(0)); + } + + @Test + public void MXMLMetadataNode_empty3() + { + String code = " \t\r\n"; + IMXMLMetadataNode node = getMXMLMetadataNode(code); + assertThat("getChildCount", node.getChildCount(), is(0)); + } + + @Test + public void MXMLMetadataNode_two_events() + { + String code = + "" + EOL + + " [Event(name='mouseDown', type='mx.events.MouseEvent')]" + EOL + + " [Event(name='mouseUp', type='mx.events.MouseEvent')]" + EOL + + ""; + IMXMLMetadataNode node = getMXMLMetadataNode(code); + assertThat("getChildCount", node.getChildCount(), is(2)); + IMetaTagNode[] metaTagNodes = node.getMetaTagNodes(); + assertThat("event 0", ((IEventTagNode)metaTagNodes[0]).getName(), is("mouseDown")); + assertThat("event 1", ((IEventTagNode)metaTagNodes[1]).getName(), is("mouseUp")); + } +} Propchange: incubator/flex/falcon/trunk/compiler.tests/unit-tests/org/apache/flex/compiler/internal/tree/mxml/MXMLMetadataNodeTests.java ------------------------------------------------------------------------------ svn:eol-style = native