diff options
author | Jeffrey Overbey | 2010-09-21 13:26:16 +0000 |
---|---|---|
committer | Jeffrey Overbey | 2010-09-21 13:26:16 +0000 |
commit | 78076d337fad67da21736b2684221bed535df5bb (patch) | |
tree | 382bdf4e884f3c0d6ad4a0f3fb572f1ef459d1d0 /org.eclipse.photran.core.vpg.tests | |
parent | f1d407a5135a5f50b606eb509cadba5314be56d6 (diff) | |
download | org.eclipse.photran-78076d337fad67da21736b2684221bed535df5bb.tar.gz org.eclipse.photran-78076d337fad67da21736b2684221bed535df5bb.tar.xz org.eclipse.photran-78076d337fad67da21736b2684221bed535df5bb.zip |
Committed Permute Subroutine Arguments (Bug 319733)
Diffstat (limited to 'org.eclipse.photran.core.vpg.tests')
15 files changed, 319 insertions, 1 deletions
diff --git a/org.eclipse.photran.core.vpg.tests/build.properties b/org.eclipse.photran.core.vpg.tests/build.properties index e0d36b3e..c0875624 100644 --- a/org.eclipse.photran.core.vpg.tests/build.properties +++ b/org.eclipse.photran.core.vpg.tests/build.properties @@ -5,7 +5,8 @@ bin.includes = META-INF/,\ parser-test-code/,\ refactoring-test-code/,\ search-test-code/,\ - vpg-test-code/ + vpg-test-code/,\ + control-flow-test-code/ src.includes = Makefile,\ NOTE,\ refactoring-test-code/,\ diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-alternate-return/test-alternate-return.f90 b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-alternate-return/test-alternate-return.f90 new file mode 100644 index 00000000..bd57f51c --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-alternate-return/test-alternate-return.f90 @@ -0,0 +1,10 @@ +program testaltreturn + call testsub(4,3,200,10,200,E=10,D=2) + +200 print *, "hello, world!" + +end program + +subroutine testsub(A,B,*,C,*,D,E) !<<<<< 8,1,8,5,2,1,0,4,3,6,5,pass + +end subroutine
\ No newline at end of file diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-alternate-return/test-alternate-return.f90.result b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-alternate-return/test-alternate-return.f90.result new file mode 100644 index 00000000..15f53cb5 --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-alternate-return/test-alternate-return.f90.result @@ -0,0 +1,10 @@ +program testaltreturn + call testsub(200,3,4,200,10,E=10,D=2) + +200 print *, "hello, world!" + +end program + +subroutine testsub(*,B,A,*,C,E,D) !<<<<< 8,1,8,5,2,1,0,4,3,6,5,pass + +end subroutine diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-basic/test-basic.f90 b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-basic/test-basic.f90 new file mode 100644 index 00000000..10c87dd2 --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-basic/test-basic.f90 @@ -0,0 +1,11 @@ +program basictest + call simple(4,3,2) + + call simple(4,Gamma=2,Beta=3) +end program basictest + +subroutine simple(Alpha, Beta, Gamma) !<<<<< 7,1,7,5,2,1,0,pass + integer, intent(in) :: Alpha + integer, intent(out) :: Beta + integer, intent(inout) :: Gamma +end subroutine
\ No newline at end of file diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-basic/test-basic.f90.result b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-basic/test-basic.f90.result new file mode 100644 index 00000000..447bb2d5 --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-basic/test-basic.f90.result @@ -0,0 +1,11 @@ +program basictest + call simple(2,3,4) + + call simple(Gamma=2,Beta=3,Alpha=4) +end program basictest + +subroutine simple( Gamma, Beta,Alpha) !<<<<< 7,1,7,5,2,1,0,pass + integer, intent(in) :: Alpha + integer, intent(out) :: Beta + integer, intent(inout) :: Gamma +end subroutine diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface/test-interface.f90 b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface/test-interface.f90 new file mode 100644 index 00000000..2ee2a7ab --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface/test-interface.f90 @@ -0,0 +1,33 @@ +program testoptional + interface + subroutine testsub(A,B,*,*,C,D,E,F) + integer, optional :: C + integer, optional :: E + end subroutine + end interface + + call testsub(1,2,200,200,3,4,5,6) + + call testsub(1,2,200,200,F=3,D=4) + +200 print *, "hello, world!" +end program testoptional + +subroutine testsub(A,B,*,*,C,D,E,F) !<<<<< 16,1,16,5,2,1,3,0,5,4,6,7,pass + integer, optional :: C + integer, optional :: E +end subroutine + +subroutine testsub2 + interface + subroutine testsub(A,B,*,*,C,D,E,F) + integer, optional :: C + integer, optional :: E + end subroutine + end interface + + call testsub(1,2,300,300,D=20,E=30,F=2,C=5) + +300 print *, "world, hello!!" + +end subroutine diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface/test-interface.f90.result b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface/test-interface.f90.result new file mode 100644 index 00000000..36bbf872 --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface/test-interface.f90.result @@ -0,0 +1,33 @@ +program testoptional + interface + subroutine testsub(*,B,*,A,D,C,E,F) + integer, optional :: C + integer, optional :: E + end subroutine + end interface + + call testsub(200,2,200,1,4,3,5,6) + + call testsub(200,2,200,1,D=4,F=3) + +200 print *, "hello, world!" +end program testoptional + +subroutine testsub(*,B,*,A,D,C,E,F) !<<<<< 16,1,16,5,2,1,3,0,5,4,6,7,pass + integer, optional :: C + integer, optional :: E +end subroutine + +subroutine testsub2 + interface + subroutine testsub(*,B,*,A,D,C,E,F) + integer, optional :: C + integer, optional :: E + end subroutine + end interface + + call testsub(300,2,300,1,D=20,C=5,E=30,F=2) + +300 print *, "world, hello!!" + +end subroutine diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface2/test-interface2.f90 b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface2/test-interface2.f90 new file mode 100644 index 00000000..fad6c696 --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface2/test-interface2.f90 @@ -0,0 +1,37 @@ +program testoptional + interface + subroutine testsub(A,B,*,*,C,D,E,F) + integer, optional :: C + integer, optional :: E + end subroutine + end interface + + call testsub(1,2,200,200,3,4,5,6) + + call testsub(1,2,200,200,F=3,D=4) + +200 print *, "hello, world!" +end program testoptional + +subroutine testsub(A,B,*,*,C,D,E,F) !<<<<< 16,1,16,5,2,1,3,0,5,4,6,7,pass + integer, optional :: C + integer, optional :: E +end subroutine + +subroutine testsub2 + interface + subroutine testsub(A,B,*,*,C,D,E,F) + integer, optional :: C + integer, optional :: E + end subroutine + + subroutine testsub(A) + integer :: A + end subroutine + end interface + + call testsub(1,2,300,300,D=20,E=30,F=2,C=5) + +300 print *, "world, hello!!" + +end subroutine diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface2/test-interface2.f90.result b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface2/test-interface2.f90.result new file mode 100644 index 00000000..425a255c --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-interface2/test-interface2.f90.result @@ -0,0 +1,37 @@ +program testoptional + interface + subroutine testsub(*,B,*,A,D,C,E,F) + integer, optional :: C + integer, optional :: E + end subroutine + end interface + + call testsub(200,2,200,1,4,3,5,6) + + call testsub(200,2,200,1,D=4,F=3) + +200 print *, "hello, world!" +end program testoptional + +subroutine testsub(*,B,*,A,D,C,E,F) !<<<<< 16,1,16,5,2,1,3,0,5,4,6,7,pass + integer, optional :: C + integer, optional :: E +end subroutine + +subroutine testsub2 + interface + subroutine testsub(*,B,*,A,D,C,E,F) + integer, optional :: C + integer, optional :: E + end subroutine + + subroutine testsub(A) + integer :: A + end subroutine + end interface + + call testsub(300,2,300,1,D=20,C=5,E=30,F=2) + +300 print *, "world, hello!!" + +end subroutine diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-internal-subroutine/test-internal-subroutine.f90 b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-internal-subroutine/test-internal-subroutine.f90 new file mode 100644 index 00000000..bbc89e0e --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-internal-subroutine/test-internal-subroutine.f90 @@ -0,0 +1,11 @@ +program testaltreturn + call testsub(4,3,200,10,200,E=10,D=2) + +200 print *, "hello, world!" + +contains + + subroutine testsub(A,B,*,C,*,D,E) !<<<<< 8,5,8,9,2,1,0,4,3,6,5,pass + + end subroutine +end program diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-internal-subroutine/test-internal-subroutine.f90.result b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-internal-subroutine/test-internal-subroutine.f90.result new file mode 100644 index 00000000..a153c587 --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-internal-subroutine/test-internal-subroutine.f90.result @@ -0,0 +1,11 @@ +program testaltreturn + call testsub(200,3,4,200,10,E=10,D=2) + +200 print *, "hello, world!" + +contains + + subroutine testsub(*,B,A,*,C,E,D) !<<<<< 8,5,8,9,2,1,0,4,3,6,5,pass + + end subroutine +end program diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-no-arguments/test-no-arguments.f90 b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-no-arguments/test-no-arguments.f90 new file mode 100644 index 00000000..07ad314d --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-no-arguments/test-no-arguments.f90 @@ -0,0 +1,9 @@ +program testnoarg + + call testsub + +end program + +subroutine testsub !<<<<< 7,1,7,5,pass + +end subroutine
\ No newline at end of file diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-optional-arguments/test-optional-arguments.f90 b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-optional-arguments/test-optional-arguments.f90 new file mode 100644 index 00000000..477a3d9f --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-optional-arguments/test-optional-arguments.f90 @@ -0,0 +1,14 @@ +program testoptional + call testsub(1,2,200,200,3,4,5,6) + + call testsub(1,2,200,200,F=3,D=4) + + call testsub(1,2,200,200,E=5,F=3,D=4) + +200 print *, "hello, world!" +end program testoptional + +subroutine testsub(A,B,*,*,C,D,E,F) !<<<<< 11,1,11,5,2,1,3,0,5,4,6,7,pass + integer, optional :: C + integer, optional :: E +end subroutine
\ No newline at end of file diff --git a/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-optional-arguments/test-optional-arguments.f90.result b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-optional-arguments/test-optional-arguments.f90.result new file mode 100644 index 00000000..761e5834 --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/refactoring-test-code/permute-subroutine-args/test-optional-arguments/test-optional-arguments.f90.result @@ -0,0 +1,14 @@ +program testoptional + call testsub(200,2,200,1,4,3,5,6) + + call testsub(200,2,200,1,D=4,F=3) + + call testsub(200,2,200,1,D=4,E=5,F=3) + +200 print *, "hello, world!" +end program testoptional + +subroutine testsub(*,B,*,A,D,C,E,F) !<<<<< 11,1,11,5,2,1,3,0,5,4,6,7,pass + integer, optional :: C + integer, optional :: E +end subroutine diff --git a/org.eclipse.photran.core.vpg.tests/src/org/eclipse/photran/internal/tests/refactoring/PermuteSubroutineArgsTestSuite.java b/org.eclipse.photran.core.vpg.tests/src/org/eclipse/photran/internal/tests/refactoring/PermuteSubroutineArgsTestSuite.java new file mode 100644 index 00000000..76dd7e63 --- /dev/null +++ b/org.eclipse.photran.core.vpg.tests/src/org/eclipse/photran/internal/tests/refactoring/PermuteSubroutineArgsTestSuite.java @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2010 University of Illinois at Urbana-Champaign and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Matthew Fotzler, UIUC - Initial API and implementation + *******************************************************************************/ +package org.eclipse.photran.internal.tests.refactoring; + +import java.util.ArrayList; +import java.util.List; + +import junit.framework.Test; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.text.TextSelection; +import org.eclipse.photran.internal.core.refactoring.PermuteSubroutineArgsRefactoring; +import org.eclipse.photran.internal.tests.Activator; +import org.eclipse.photran.internal.tests.PhotranRefactoringTestSuiteFromMarkers; + +/** + * Test suite for the change subroutine signature refactoring. + * + * @author Matthew Fotzler + */ +public class PermuteSubroutineArgsTestSuite extends PhotranRefactoringTestSuiteFromMarkers<PermuteSubroutineArgsRefactoring> +{ + private static final String DIR = "refactoring-test-code/permute-subroutine-args"; + + public PermuteSubroutineArgsTestSuite() throws Exception + { + super(Activator.getDefault(), + "Running Permute Subroutine Arguments refactoring in", + DIR, + PermuteSubroutineArgsRefactoring.class); + } + + public static Test suite() throws Exception + { + return new PermuteSubroutineArgsTestSuite(); + } + + // Marker format is !<<<<< startRow,startCol,endRow,endCol,[sigma],pass/fail-initial/fail-final + // where sigma is the desired permutation of the subroutine arguments given by the selection + @Override + protected boolean initializeRefactoring(PermuteSubroutineArgsRefactoring refactoring, + IFile file, + TextSelection selection, + String[] markerText) + { + boolean result = super.initializeRefactoring(refactoring, file, selection, markerText); + List<Integer> sigma = new ArrayList<Integer>(); + + for (int i = 4; i < markerText.length-1; i++) + { + String nextElement = markerText[i]; + + sigma.add(Integer.parseInt(nextElement)); + } + + refactoring.setSigma(sigma); + + return result; + } + + /** + * Method that prevents the compilation of any test we know don't compile + */ + @Override protected boolean shouldCompile(IFile fileContainingMarker) + { + return false; + } +} |