flex-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joshtynj...@apache.org
Subject git commit: [flex-falcon] [refs/heads/develop] - compiler-jx: added test for Node.js externs
Date Mon, 27 Jun 2016 16:12:18 GMT
Repository: flex-falcon
Updated Branches:
  refs/heads/develop 8a37541fe -> 5c359cb91


compiler-jx: added test for Node.js externs


Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/5c359cb9
Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/5c359cb9
Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/5c359cb9

Branch: refs/heads/develop
Commit: 5c359cb914339f4892fe2d51a0d073ba83c24ec4
Parents: 8a37541
Author: Josh Tynjala <joshtynjala@gmail.com>
Authored: Mon Jun 27 09:12:12 2016 -0700
Committer: Josh Tynjala <joshtynjala@gmail.com>
Committed: Mon Jun 27 09:12:12 2016 -0700

----------------------------------------------------------------------
 .../codegen/externals/ExternalsTestUtils.java   |   3 +
 .../codegen/externals/TestExternNode.java       | 120 +++++++++++++++++++
 2 files changed, 123 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5c359cb9/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
index b583465..88367c4 100644
--- a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/ExternalsTestUtils.java
@@ -47,6 +47,9 @@ public class ExternalsTestUtils
     public static File EXTERNAL_JASMINE_DIR = FilenameNormalization.normalize(new File(
             "../../../externs/jasmine/target/downloads"));
 
+    public static File EXTERNAL_NODE_DIR = FilenameNormalization.normalize(new File(
+            "../../../externs/node/target/downloads/closure-compiler-master/contrib/nodejs"));
+
     public static File AS_ROOT_DIR = new File(TEMP_DIR, "externals/as");
 
     public static void addTestExcludesFull(ExternCConfiguration config)

http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/5c359cb9/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternNode.java
----------------------------------------------------------------------
diff --git a/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternNode.java
b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternNode.java
new file mode 100644
index 0000000..b47dfa3
--- /dev/null
+++ b/compiler-jx/src/test/java/org/apache/flex/compiler/internal/codegen/externals/TestExternNode.java
@@ -0,0 +1,120 @@
+/*
+ *
+ *  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.compiler.internal.codegen.externals;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+
+import org.apache.flex.compiler.clients.ExternCConfiguration;
+import org.apache.flex.compiler.internal.codegen.externals.reference.ClassReference;
+import org.junit.Test;
+
+import com.google.javascript.jscomp.Result;
+
+public class TestExternNode extends ExternalsTestBase
+{
+    @SuppressWarnings("unused")
+    @Test
+    public void test_classes() throws IOException
+    {
+        Result result = compile();
+        assertTrue("Compile Node.js externs not successful", result.success);
+
+        ClassReference child_process_ChildProcess = model.getClassReference("child_process.ChildProcess");
+        assertNotNull("child_process.ChildProcess not found in Node.js externs", child_process_ChildProcess);
+
+        StringBuilder sb = new StringBuilder();
+        child_process_ChildProcess.emit(sb);
+        String r = sb.toString();
+        assertTrue("child_process.ChildProcess must contain [JSModule(name=\"child_process\")]
named module metadata",
+                r.contains("[JSModule(name=\"child_process\")]"));
+    }
+
+    @Override
+    protected void configure(ExternCConfiguration config) throws IOException
+    {
+        config.setASRoot(ExternalsTestUtils.AS_ROOT_DIR);
+
+        config.addNamedModule("assert");
+        config.addNamedModule("buffer");
+        config.addNamedModule("child_process");
+        config.addNamedModule("cluster");
+        config.addNamedModule("crypto");
+        config.addNamedModule("dgram");
+        config.addNamedModule("dns");
+        config.addNamedModule("domain");
+        config.addNamedModule("events");
+        config.addNamedModule("fs");
+        config.addNamedModule("globals");
+        config.addNamedModule("http");
+        config.addNamedModule("https");
+        config.addNamedModule("net");
+        config.addNamedModule("os");
+        config.addNamedModule("path");
+        config.addNamedModule("punycode");
+        config.addNamedModule("querystring");
+        config.addNamedModule("readline");
+        config.addNamedModule("repl");
+        config.addNamedModule("stream");
+        config.addNamedModule("string_decoder");
+        config.addNamedModule("tls");
+        config.addNamedModule("tty");
+        config.addNamedModule("url");
+        config.addNamedModule("util");
+        config.addNamedModule("vm");
+        config.addNamedModule("zlib");
+
+        config.addExclude("Buffer", "toJSON");
+        config.addExclude("osNetworkInterfacesInfo", "internal");
+
+        String coreRoot = ExternalsTestUtils.EXTERNAL_NODE_DIR.getAbsolutePath();
+        config.addExternal(coreRoot + "/assert.js");
+        config.addExternal(coreRoot + "/buffer.js");
+        config.addExternal(coreRoot + "/child_process.js");
+        config.addExternal(coreRoot + "/cluster.js");
+        config.addExternal(coreRoot + "/crypto.js");
+        config.addExternal(coreRoot + "/dgram.js");
+        config.addExternal(coreRoot + "/dns.js");
+        config.addExternal(coreRoot + "/domain.js");
+        config.addExternal(coreRoot + "/events.js");
+        config.addExternal(coreRoot + "/fs.js");
+        config.addExternal(coreRoot + "/globals.js");
+        config.addExternal(coreRoot + "/http.js");
+        config.addExternal(coreRoot + "/https.js");
+        config.addExternal(coreRoot + "/net.js");
+        config.addExternal(coreRoot + "/os.js");
+        config.addExternal(coreRoot + "/path.js");
+        config.addExternal(coreRoot + "/punycode.js");
+        config.addExternal(coreRoot + "/querystring.js");
+        config.addExternal(coreRoot + "/readline.js");
+        config.addExternal(coreRoot + "/repl.js");
+        config.addExternal(coreRoot + "/stream.js");
+        config.addExternal(coreRoot + "/string_decoder.js");
+        config.addExternal(coreRoot + "/tls.js");
+        config.addExternal(coreRoot + "/tty.js");
+        config.addExternal(coreRoot + "/url.js");
+        config.addExternal(coreRoot + "/util.js");
+        config.addExternal(coreRoot + "/vm.js");
+        config.addExternal(coreRoot + "/zlib.js");
+    }
+
+}


Mime
View raw message