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 CA985E0E6 for ; Fri, 28 Dec 2012 10:09:38 +0000 (UTC) Received: (qmail 80078 invoked by uid 500); 28 Dec 2012 10:09:38 -0000 Delivered-To: apmail-incubator-flex-commits-archive@incubator.apache.org Received: (qmail 79972 invoked by uid 500); 28 Dec 2012 10:09:36 -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 79943 invoked by uid 99); 28 Dec 2012 10:09:35 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 28 Dec 2012 10:09:35 +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; Fri, 28 Dec 2012 10:09:32 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id A8E292388993; Fri, 28 Dec 2012 10:09:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1426450 - in /incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/js/codegen/goog: ./ TestGoogPackage.java Date: Fri, 28 Dec 2012 10:09:11 -0000 To: flex-commits@incubator.apache.org From: erikdebruin@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121228100911.A8E292388993@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: erikdebruin Date: Fri Dec 28 10:09:11 2012 New Revision: 1426450 URL: http://svn.apache.org/viewvc?rev=1426450&view=rev Log: Adding test for production of 'goog'-ified JS Package code. Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/js/codegen/goog/ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/js/codegen/goog/TestGoogPackage.java (with props) Added: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/js/codegen/goog/TestGoogPackage.java URL: http://svn.apache.org/viewvc/incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/js/codegen/goog/TestGoogPackage.java?rev=1426450&view=auto ============================================================================== --- incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/js/codegen/goog/TestGoogPackage.java (added) +++ incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/js/codegen/goog/TestGoogPackage.java Fri Dec 28 10:09:11 2012 @@ -0,0 +1,114 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +package org.apache.flex.js.internal.js.codegen.goog; + +import java.io.FilterWriter; + +import org.apache.flex.compiler.clients.IBackend; +import org.apache.flex.compiler.internal.driver.JSBackend; +import org.apache.flex.compiler.internal.js.codgen.JSEmitter; +import org.apache.flex.compiler.internal.js.codgen.JSGoogEmitter; +import org.apache.flex.compiler.tree.as.IFileNode; +import org.apache.flex.js.internal.driver.TestPackage; +import org.junit.Ignore; +import org.junit.Test; + +/** + * This class tests the production of 'goog' JavaScript for Package production. + * + * @author Michael Schmalle + * @author Erik de Bruin + */ +public class TestGoogPackage extends TestPackage +{ + // TODO (erikdebruin) + // 1) empty packages cause exception + // 2) empty classes don't get a JS block (curly brackets) + // 3) empty classes get an '@extends {Object}' annotation: remove + // 4) there is an extra line after the 'goog.provide' line: remove + // 5) there are two extra lines at the end of the code: remove + // 6) constructor body in 'testPackageQualified_ClassBodyMethodContents' + // contains cody that is not yet 'goog'-ified + + @Ignore + @Test + public void testPackage_Simple() + { + IFileNode node = getFileNode("package{}"); + visitor.visitFile(node); + //assertOut(""); + } + + @Ignore + @Test + public void testPackage_Name() + { + IFileNode node = getFileNode("package foo.bar.baz {}"); + visitor.visitFile(node); + //assertOut(""); + } + + @Test + public void testPackageSimple_Class() + { + IFileNode node = getFileNode("package {public class A{}}"); + visitor.visitFile(node); + //assertOut(""); + } + + @Test + public void testPackageQualified_Class() + { + IFileNode node = getFileNode("package foo.bar.baz {public class A{}}"); + visitor.visitFile(node); + //assertOut(""); + } + + @Test + public void testPackageQualified_ClassBody() + { + IFileNode node = getFileNode("package foo.bar.baz {public class A{public function A(){}}}"); + visitor.visitFile(node); + assertOut("goog.provide('foo.bar.baz.A');\n\n\n/**\n * @constructor\n * @extends {Object}\n */\nfoo.bar.baz.A = function() {\n};\n\n"); + } + + @Test + public void testPackageQualified_ClassBodyMethodContents() + { + IFileNode node = getFileNode("package foo.bar.baz {public class A{public function A(){if (a){for each(var i:Object in obj){doit();}}}}}"); + visitor.visitFile(node); + //assertOut(""); + } + + protected IBackend createBackend() + { + return new GoogBackend(); + } + + class GoogBackend extends JSBackend + { + @Override + protected JSEmitter createEmitter(FilterWriter out) + { + return new JSGoogEmitter(out); + } + } + +} Propchange: incubator/flex/whiteboard/mschmalle/falconjx/compiler.jx.tests/src/org/apache/flex/js/internal/js/codegen/goog/TestGoogPackage.java ------------------------------------------------------------------------------ svn:eol-style = native