Repository: systemml Updated Branches: refs/heads/master 51057e471 -> 233b38c14
[MINOR] Additional tests for missing and unknown functions Project: http://git-wip-us.apache.org/repos/asf/systemml/repo Commit: http://git-wip-us.apache.org/repos/asf/systemml/commit/68f37af3 Tree: http://git-wip-us.apache.org/repos/asf/systemml/tree/68f37af3 Diff: http://git-wip-us.apache.org/repos/asf/systemml/diff/68f37af3 Branch: refs/heads/master Commit: 68f37af3ecdaeaac16120eb8a5dcbb2af7a1a0ba Parents: 51057e4 Author: Matthias Boehm <[email protected]> Authored: Tue Jun 5 16:34:02 2018 -0700 Committer: Matthias Boehm <[email protected]> Committed: Tue Jun 5 18:25:49 2018 -0700 ---------------------------------------------------------------------- .../functions/misc/FunctionNotFoundTest.java | 65 ++++++++++++++++++++ .../scripts/functions/misc/FunNotFound1.dml | 36 +++++++++++ .../scripts/functions/misc/FunNotFound2.dml | 33 ++++++++++ .../functions/misc/ZPackageSuite.java | 1 + 4 files changed, 135 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/systemml/blob/68f37af3/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionNotFoundTest.java ---------------------------------------------------------------------- diff --git a/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionNotFoundTest.java b/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionNotFoundTest.java new file mode 100644 index 0000000..9605c2b --- /dev/null +++ b/src/test/java/org/apache/sysml/test/integration/functions/misc/FunctionNotFoundTest.java @@ -0,0 +1,65 @@ +/* + * 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.sysml.test.integration.functions.misc; + + +import org.junit.Test; +import org.apache.sysml.api.DMLException; +import org.apache.sysml.test.integration.AutomatedTestBase; +import org.apache.sysml.test.integration.TestConfiguration; +import org.apache.sysml.test.utils.TestUtils; + +public class FunctionNotFoundTest extends AutomatedTestBase +{ + private final static String TEST_NAME1 = "FunNotFound1"; + private final static String TEST_NAME2 = "FunNotFound2"; + private final static String TEST_DIR = "functions/misc/"; + private final static String TEST_CLASS_DIR = TEST_DIR + FunctionNotFoundTest.class.getSimpleName() + "/"; + + @Override + public void setUp() { + TestUtils.clearAssertionInformation(); + addTestConfiguration( TEST_NAME1, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME1, new String[] { "R" }) ); + addTestConfiguration( TEST_NAME2, new TestConfiguration(TEST_CLASS_DIR, TEST_NAME2, new String[] { "R" }) ); + } + + @Test + public void testFunNotFound1() { + runFunctionNotFoundTest( TEST_NAME1, true ); + } + + @Test + public void testFunNotFound2() { + //parse issues (import statement) written to stderr + runFunctionNotFoundTest( TEST_NAME2, false ); + } + + private void runFunctionNotFoundTest(String testName, boolean error) { + TestConfiguration config = getTestConfiguration(testName); + loadTestConfiguration(config); + + String HOME = SCRIPT_DIR + TEST_DIR; + fullDMLScriptName = HOME + testName + ".dml"; + programArgs = new String[]{"-explain", "-stats"}; + + //run script and compare output + runTest(true, error, DMLException.class, -1); + } +} http://git-wip-us.apache.org/repos/asf/systemml/blob/68f37af3/src/test/scripts/functions/misc/FunNotFound1.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/FunNotFound1.dml b/src/test/scripts/functions/misc/FunNotFound1.dml new file mode 100644 index 0000000..4eea30a --- /dev/null +++ b/src/test/scripts/functions/misc/FunNotFound1.dml @@ -0,0 +1,36 @@ +#------------------------------------------------------------- +# +# 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. +# +#------------------------------------------------------------- + + +foo = function( Matrix[Double] B ) return (Matrix[Double] V) { + V = baar(B + 7); + while(FALSE){} +} +baar = function( Matrix[Double] B ) return (Matrix[Double] V) { + V = B+B; + while(FALSE){} +} + +X = matrix(7, 10, 10); +Y = foo(X); +Z = bar(Y); +R = baar(Z); +print(sum(R)); http://git-wip-us.apache.org/repos/asf/systemml/blob/68f37af3/src/test/scripts/functions/misc/FunNotFound2.dml ---------------------------------------------------------------------- diff --git a/src/test/scripts/functions/misc/FunNotFound2.dml b/src/test/scripts/functions/misc/FunNotFound2.dml new file mode 100644 index 0000000..342c2fc --- /dev/null +++ b/src/test/scripts/functions/misc/FunNotFound2.dml @@ -0,0 +1,33 @@ +#------------------------------------------------------------- +# +# 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("./non-existing-dir/bar.dml") as bar + +foo = function( Matrix[Double] B ) return (Matrix[Double] V) { + V = bar::bar(B + 7); + while(FALSE){} +} + +X = matrix(7, 10, 10); +Y = foo(X); +Z = bar::bar(Y); +R = bar::baar(Z); +print(sum(R)); http://git-wip-us.apache.org/repos/asf/systemml/blob/68f37af3/src/test_suites/java/org/apache/sysml/test/integration/functions/misc/ZPackageSuite.java ---------------------------------------------------------------------- diff --git a/src/test_suites/java/org/apache/sysml/test/integration/functions/misc/ZPackageSuite.java b/src/test_suites/java/org/apache/sysml/test/integration/functions/misc/ZPackageSuite.java index 8d3f7f3..be92a5c 100644 --- a/src/test_suites/java/org/apache/sysml/test/integration/functions/misc/ZPackageSuite.java +++ b/src/test_suites/java/org/apache/sysml/test/integration/functions/misc/ZPackageSuite.java @@ -33,6 +33,7 @@ import org.junit.runners.Suite; FunctionInExpressionTest.class, FunctionInliningTest.class, FunctionNamespaceTest.class, + FunctionNotFoundTest.class, FunctionReturnTest.class, IfTest.class, InvalidBuiltinFunctionCallTest.class,
