Repository: systemml Updated Branches: refs/heads/master 0f7190c87 -> 15971f797
[MINOR] Additional tests for cyclic JMLC package namespace functions Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/f6de9b1b Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/f6de9b1b Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/f6de9b1b Branch: refs/heads/master Commit: f6de9b1be115eb8af7919f5779d080c027c5f91f Parents: 0f7190c Author: Matthias Boehm <[email protected]> Authored: Wed Jun 6 21:40:17 2018 -0700 Committer: Matthias Boehm <[email protected]> Committed: Wed Jun 6 21:40:17 2018 -0700 ---------------------------------------------------------------------- .../functions/jmlc/NamespaceFunctionTest.java | 41 +++++++++++++++----- src/test/scripts/functions/jmlc/bar3.dml | 27 +++++++++++++ src/test/scripts/functions/jmlc/foo2.dml | 32 +++++++++++++++ 3 files changed, 90 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/f6de9b1b/src/test/java/org/apache/sysml/test/integration/functions/jmlc/NamespaceFunctionTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/jmlc/NamespaceFunctionTest.java b/src/test/java/org/apache/sysml/test/integration/functions/jmlc/NamespaceFunctionTest.java index 8b65eb8..63d8be6 100644 --- a/src/test/java/org/apache/sysml/test/integration/functions/jmlc/NamespaceFunctionTest.java +++ b/src/test/java/org/apache/sysml/test/integration/functions/jmlc/NamespaceFunctionTest.java @@ -40,6 +40,9 @@ public class NamespaceFunctionTest extends AutomatedTestBase private final static String TEST_NAME2 = "bar1.dml"; private final static String TEST_NAME3 = "bar2.dml"; + private final static String TEST_NAME4 = "foo2.dml"; + private final static String TEST_NAME5 = "bar3.dml"; + private final static String TEST_DIR = "functions/jmlc/"; private final static String TEST_CLASS_DIR = TEST_DIR + NamespaceFunctionTest.class.getSimpleName() + "/"; @@ -48,24 +51,34 @@ public class NamespaceFunctionTest extends AutomatedTestBase private final static double sparsity1 = 0.7; private final static double sparsity2 = 0.1; - @Override public void setUp() { - addTestConfiguration(TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "F2" }) ); + addTestConfiguration(TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "F2" }) ); + addTestConfiguration(TEST_NAME4, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME4, new String[] { "F2" }) ); + } + + @Test + public void testJMLCNamespaceAcyclicDense() throws IOException { + runJMLCNamespaceTest(false, false); + } + + @Test + public void testJMLCNamespaceAcyclicSparse() throws IOException { + runJMLCNamespaceTest(true, false); } @Test - public void testJMLCNamespaceDense() throws IOException { - runJMLCNamespaceTest(false); + public void testJMLCNamespaceCyclicDense() throws IOException { + runJMLCNamespaceTest(false, true); } @Test - public void testJMLCNamespaceSparse() throws IOException { - runJMLCNamespaceTest(true); + public void testJMLCNamespaceCyclicSparse() throws IOException { + runJMLCNamespaceTest(true, true); } - private void runJMLCNamespaceTest(boolean sparse) + private void runJMLCNamespaceTest(boolean sparse, boolean cyclic) throws IOException { TestConfiguration config = getTestConfiguration(TEST_NAME1); @@ -73,10 +86,18 @@ public class NamespaceFunctionTest extends AutomatedTestBase //load scripts and create prepared script Connection conn = new Connection(); - String script1 = conn.readScript(SCRIPT_DIR + TEST_DIR + TEST_NAME1); Map<String,String> nsscripts = new HashMap<>(); - nsscripts.put(TEST_NAME2, conn.readScript(SCRIPT_DIR + TEST_DIR + TEST_NAME2)); - nsscripts.put(TEST_NAME3, conn.readScript(SCRIPT_DIR + TEST_DIR + TEST_NAME3)); + String script1 = null; + if( cyclic ) { + script1 = conn.readScript(SCRIPT_DIR + TEST_DIR + TEST_NAME4); + nsscripts.put(TEST_NAME4, conn.readScript(SCRIPT_DIR + TEST_DIR + TEST_NAME4)); + nsscripts.put(TEST_NAME5, conn.readScript(SCRIPT_DIR + TEST_DIR + TEST_NAME5)); + } + else { + script1 = conn.readScript(SCRIPT_DIR + TEST_DIR + TEST_NAME1); + nsscripts.put(TEST_NAME2, conn.readScript(SCRIPT_DIR + TEST_DIR + TEST_NAME2)); + nsscripts.put(TEST_NAME3, conn.readScript(SCRIPT_DIR + TEST_DIR + TEST_NAME3)); + } PreparedScript pstmt = conn.prepareScript(script1, nsscripts, Collections.emptyMap(), new String[]{"X"}, new String[]{"Z"}, false); http://git-wip-us.apache.org/repos/asf/systemml/blob/f6de9b1b/src/test/scripts/functions/jmlc/bar3.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/jmlc/bar3.dml b/src/test/scripts/functions/jmlc/bar3.dml new file mode 100644 index 0000000..ea9b8a7 --- /dev/null +++ b/src/test/scripts/functions/jmlc/bar3.dml @@ -0,0 +1,27 @@ +#------------------------------------------------------------- +# +# 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. +# +#------------------------------------------------------------- + +source("foo2.dml") as ns1 + +exec = function(matrix[double] A) return (matrix[double] B) { + while(FALSE) {} + B = ns1::debug(A + 10); +} http://git-wip-us.apache.org/repos/asf/systemml/blob/f6de9b1b/src/test/scripts/functions/jmlc/foo2.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/jmlc/foo2.dml b/src/test/scripts/functions/jmlc/foo2.dml new file mode 100644 index 0000000..377a6f3 --- /dev/null +++ b/src/test/scripts/functions/jmlc/foo2.dml @@ -0,0 +1,32 @@ +#------------------------------------------------------------- +# +# 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. +# +#------------------------------------------------------------- + +source("bar3.dml") as ns1 + +X = read($1); +Z = ns1::exec(X); +write(Z, $2) + +debug = function(matrix[double] A) return (matrix[double] B) { + while(FALSE){} + print("sum(A) = " + sum(A)); + B = A; +}
