### Eclipse Workspace Patch 1.0 #P org.eclipse.photran.core.vpg Index: src/org/eclipse/photran/internal/core/refactoring/Messages.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.ptp/photran/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/Messages.java,v retrieving revision 1.15 diff -u -r1.15 Messages.java --- src/org/eclipse/photran/internal/core/refactoring/Messages.java 21 Sep 2010 18:32:41 -0000 1.15 +++ src/org/eclipse/photran/internal/core/refactoring/Messages.java 9 Dec 2010 04:31:43 -0000 @@ -420,6 +420,10 @@ public static String RemoveUnreferencedLabelsRefactoring_ThereMustBeAtLeastOneLabeledStatement; + public static String RemoveAssignedGoToRefactoring_Name; + + public static String RemoveAssignedGoToRefactoring_SelectedFileCannotBeParsed; + static { // initialize resource bundle Index: src/org/eclipse/photran/internal/core/refactoring/RemoveAssignedGotoRefactoring.java =================================================================== RCS file: src/org/eclipse/photran/internal/core/refactoring/RemoveAssignedGotoRefactoring.java diff -N src/org/eclipse/photran/internal/core/refactoring/RemoveAssignedGotoRefactoring.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/core/refactoring/RemoveAssignedGotoRefactoring.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,674 @@ +/******************************************************************************* + * Copyright (c) 2010 Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, + * Balaji Ambresh Rajkumar and Paramvir Singh. + * 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: + * Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, Balaji Ambresh Rajkumar + * and Paramvir Singh - Initial API and implementation + * + *******************************************************************************/ +package org.eclipse.photran.internal.core.refactoring; + +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.OperationCanceledException; +import org.eclipse.ltk.core.refactoring.RefactoringStatus; +import org.eclipse.photran.core.IFortranAST; +import org.eclipse.photran.internal.core.analysis.binding.ScopingNode; +import org.eclipse.photran.internal.core.analysis.loops.ASTVisitorWithLoops; +import org.eclipse.photran.internal.core.lexer.Token; +import org.eclipse.photran.internal.core.parser.ASTAssignStmtNode; +import org.eclipse.photran.internal.core.parser.ASTAssignedGotoStmtNode; +import org.eclipse.photran.internal.core.parser.ASTAssignmentStmtNode; +import org.eclipse.photran.internal.core.parser.ASTCaseConstructNode; +import org.eclipse.photran.internal.core.parser.ASTNameNode; +import org.eclipse.photran.internal.core.parser.IASTNode; +import org.eclipse.photran.internal.core.parser.IActionStmt; +import org.eclipse.photran.internal.core.refactoring.infrastructure.FortranResourceRefactoring; +import org.eclipse.photran.internal.core.reindenter.Reindenter; +import org.eclipse.photran.internal.core.reindenter.Reindenter.Strategy; +import org.eclipse.photran.internal.core.vpg.PhotranVPG; + +/** + * Refactoring to remove the assigned GOTOs in the selected Fortran files + * assign 100 to x 100 is the label address x is the variable + * + * is replaced by + * + * x = 100 + * @author Andrea Dranberg + * @author John Hammonds + * @author Rajashekhar Arasanal + * @author Balaji Ambresh Rajkumar + * @author Paramvir Singh + */ +public class RemoveAssignedGotoRefactoring extends FortranResourceRefactoring +{ + /** + * Maintains the lists of goto, assign and action statements that are required to do the actual + * refactoring for an IFile. Instances are created as part of initial precondition check and + * destroyed once the refactoring is done. + */ + public static class FileInfo + { + // All Assigned statements in the Fortran file + private List assignedStmtList; + + // All GoTo statements in the Fortran file + private List assignedGotoStmtList; + + // All action statements in the Fortran file + private List actionStmtList; + + private boolean isVariableInActionStmt; + + private IFile file; + + private PhotranVPG vpg; + + private Set labelAddresses; + + protected FileInfo(PhotranVPG vpg, IFile file) throws PreconditionFailure + { + setVpg(vpg); + setFile(file); + assignedStmtList = new LinkedList(); + assignedGotoStmtList = new LinkedList(); + actionStmtList = new LinkedList(); + labelAddresses = new TreeSet(); + initialize(); + } + + /** + * Collects all the assigned goto statements for the entire file and checks that there is at + * least one valid assigned goto to refactor. + * + * @throws PreconditionFailure + */ + private void initialize() throws PreconditionFailure + { + IFile file = getFile(); + IFortranAST ast = (IFortranAST)getVpg().acquirePermanentAST(file); + if (ast == null) { throw new PreconditionFailure(Messages.bind( + Messages.RemoveAssignedGoToRefactoring_SelectedFileCannotBeParsed, file.getName())); } + collectAllAssignedGoTos(ast.getRoot()); + ensureLabelAddressesArePresent(ast.getRoot()); + } + + public void cleanUp() + { + assignedStmtList.clear(); + assignedGotoStmtList.clear(); + actionStmtList.clear(); + isVariableInActionStmt = false; + vpg.releaseAST(file); + + } + + public List getAssignedStmtList() + { + return assignedStmtList; + } + + public void setAssignedStmtList(List assignedStmtList) + { + this.assignedStmtList = assignedStmtList; + } + + public List getAssignedGotoStmtList() + { + return assignedGotoStmtList; + } + + public void setAssignedGotoStmtList(List assignedGotoStmtList) + { + this.assignedGotoStmtList = assignedGotoStmtList; + } + + public List getActionStmtList() + { + return actionStmtList; + } + + public void setActionStmtList(List actionStmtList) + { + this.actionStmtList = actionStmtList; + } + + public boolean isVariableInActionStmt() + { + return isVariableInActionStmt; + } + + public void setVariableInActionStmt(boolean isVariableUsed) + { + this.isVariableInActionStmt = isVariableUsed; + } + + public IFile getFile() + { + return file; + } + + public void setFile(IFile file) + { + this.file = file; + } + + public PhotranVPG getVpg() + { + return vpg; + } + + public void setVpg(PhotranVPG vpg2) + { + this.vpg = vpg2; + } + + /** + * Remove assign statements whose variable name is used in any action statement. + * + * @return String of removed variable names. + */ + private String removeVariablesUsedInActionStmt() + { + Set removedVariables = new TreeSet(); + List assignStmtList = getAssignedStmtList(); + + for (int i = 0; i < assignStmtList.size(); i++) + { + List actionStmtList = getActionStmtList(); + for (IActionStmt actionStmtNode : actionStmtList) + { + String variable = ((ASTAssignStmtNode)assignStmtList.get(i)).getVariableName() + .getText(); + if (doesActionStmtUseVariable(actionStmtNode, variable)) + { + assignStmtList.remove(i); + removedVariables.add(variable); + --i; + break; + } + } + } + String returnString; + if (removedVariables.size() == 0){ + returnString = ""; + } + else { + returnString = removedVariables.toString(); + } + return returnString; + } + + /** + * Determines if the variable is used within an action statement. + * + * @param node The action statement node to search + * @param variable The label to be used in the goto statement + * @return true if label is in the action statement, otherwise false. + */ + private boolean doesActionStmtUseVariable(IActionStmt node, final String variable) + { + setVariableInActionStmt(false); + node.accept(new ASTVisitorWithLoops() + { + @Override + public void visitASTNameNode(ASTNameNode nameNode) + { + if (nameNode.getName().getText().equalsIgnoreCase(variable)) + { + setVariableInActionStmt(true); + } + } + }); + return isVariableInActionStmt(); + } + + /** + * Sorts the assignment statements by label address. + */ + private void sortAssignedStmtList() + { + int maxIndex = getAssignedStmtList().size(); + for (int i = 0; i < maxIndex; i++) + { + for (int j = 0; j < maxIndex; j++) + { + ASTAssignStmtNode assignNode1 = (ASTAssignStmtNode)getAssignedStmtList().get(i); + ASTAssignStmtNode assignNode2 = (ASTAssignStmtNode)getAssignedStmtList().get(j); + String ref1 = assignNode1.getAssignedLblRef().getLabel().getText(); + String ref2 = assignNode2.getAssignedLblRef().getLabel().getText(); + if (ref1.compareTo(ref2) < 0) + { + ASTAssignStmtNode temp = assignNode1; + getAssignedStmtList().remove(assignNode1); + getAssignedStmtList().add(j, temp); + } + } + } + } + + /** + * Remove duplicate assign statements. 2 Assign statements are considered to be duplicates if + * they have the same label addresses and variable names. + */ + private void removeDuplicateAssigns() + { + int maxIndex = getAssignedStmtList().size(); + for (int i = 0; i < maxIndex; i++) + { + for (int j = i + 1; j < maxIndex; j++) + { + ASTAssignStmtNode assignNode1 = (ASTAssignStmtNode)getAssignedStmtList().get(i); + ASTAssignStmtNode assignNode2 = (ASTAssignStmtNode)getAssignedStmtList().get(j); + String ref1 = assignNode1.getAssignedLblRef().getLabel().getText(); + String ref2 = assignNode2.getAssignedLblRef().getLabel().getText(); + String var1 = assignNode1.getVariableName().getText(); + String var2 = assignNode2.getVariableName().getText(); + + if (ref1.equals(ref2) && var1.equals(var2)) + { + getAssignedStmtList().remove(j); + maxIndex--; + j--; + } + } + } + } + + /** + * Removes all goto labels used in an action statement. Checks if there is at least one + * assigned goto label left to refactor. + * @param scope + * @throws PreconditionFailure + */ + private void ensureLabelAddressesArePresent(ScopingNode scope) throws PreconditionFailure + { + scope.accept(new ASTVisitorWithLoops() + { + @Override + public void visitIActionStmt(IActionStmt node) + { + Token address = node.getLabel(); + if (address instanceof Token) + { + labelAddresses.remove(address.getText()); + } + traverseChildren(node); + } + }); + if (labelAddresses.size() != 0) { + throw new PreconditionFailure("One or more numeric labels used in ASSIGN statements are not found in file " + file.getFullPath()); + } + } + + private void collectAllAssignedGoTos(ScopingNode scope) + { + scope.accept(new ASTVisitorWithLoops() + { + @Override + public void visitASTAssignStmtNode(ASTAssignStmtNode node) + { + Token address = node.getAssignedLblRef().getLabel(); + if (address instanceof Token) + { + labelAddresses.add(address.getText()); + } + getAssignedStmtList().add(0, node); + traverseChildren(node); + } + + // goto 100 --> ASTGotoStmtNode + // goto label --> ASTAssignedGotoStmtNode + @Override + public void visitASTAssignedGotoStmtNode(ASTAssignedGotoStmtNode node) + { + getAssignedGotoStmtList().add(0, node); + traverseChildren(node); + } + + /** + * Collect action statements that are not ASTAssignedGotoStmtNode or + * ASTAssignStmtNode. + */ + @Override + public void visitIActionStmt(IActionStmt node) + { + if (!(node instanceof ASTAssignedGotoStmtNode) + && !(node instanceof ASTAssignStmtNode)) + { + getActionStmtList().add(0, node); + traverseChildren(node); + } + } + }); + } + } + + /** + * Keeps track of FileInfo for all the selected files. + * The store is cleared when refactoring starts, ends, when the refactoring is + * canceled from the input page or when an error occurs. + */ + public static class FileInfoFactory + { + private static final Map store = new HashMap(); + + public static FileInfo getInstance(IFile file, PhotranVPG vpg) throws PreconditionFailure + { + FileInfo storedInfo = store.get(file); + + if (storedInfo != null) + { + return storedInfo; + } + FileInfo newInstance = new FileInfo(vpg, file); + + store.put(file, newInstance); + + return newInstance; + } + + public static void reset() + { + for (Map.Entry entry : store.entrySet()) + { + entry.getValue().cleanUp(); + } + store.clear(); + } + + public static void remove(FileInfo instance) + { + instance.cleanUp(); + store.remove(instance.getFile()); + } + + public static void removeInstance(IFile file) + { + FileInfo instance = store.get(file); + remove(instance); + } + } + + // Initialized to true by default since the button change listener from the + // input page would be triggered only when a selection is made. + // If the user directly clicks to OK button without making a choice, the button + // listener would not be invoked. Refer RemoveAssignedGotoInputPage for more info. + protected boolean isDefaultCaseRequired = true; + + @Override + public String getName() + { + return Messages.RemoveAssignedGoToRefactoring_Name; + } + + public void setDefaultSelected(boolean isDefaultCaseRequired) + { + this.isDefaultCaseRequired = isDefaultCaseRequired; + } + + /** + * Checks the initial conditions before starting refactoring + * 1. Checks if refactoring is enabled for this project + * 2. Remove files with fixed form, from list of files to be refactored + * 3. Remove C-Preprocessed files from list of files to be refactored + * 4. Initializes the FileInfo for all selected files. + */ + @Override + protected void doCheckInitialConditions(RefactoringStatus status, IProgressMonitor pm) + throws PreconditionFailure + { + ensureProjectHasRefactoringEnabled(status); + removeFixedFormFilesFrom(selectedFiles, status); + removeCpreprocessedFilesFrom(selectedFiles, status); + FileInfoFactory.reset(); + try + { + checkFilesForAssign(status); + } + catch (PreconditionFailure pre) + { + FileInfoFactory.reset(); + status.addError(pre.getMessage()); + throw pre; + } + + } + + /** + * Each selected file is checked for an assign statement. Any file that doesn't contain the + * assigned goto statement is considered to violate the precondition check. + * + * @throws PreconditionFailure. + */ + protected void checkFilesForAssign(RefactoringStatus status) throws PreconditionFailure + { + for (IFile file : selectedFiles) + { + FileInfo newInstance = FileInfoFactory.getInstance(file, vpg); + if (newInstance.getAssignedStmtList().isEmpty()) + { + throw new PreconditionFailure("Nothing to be refactored for the file " + file.getFullPath() + ". None of the files will be refactored."); + } + } + + } + + /** + * Iterates over the list of selected files for refactoring. For each file + * 1. It gets AST for that file + * 2. Puts together a list of all Assign and GoTo statements + * 3. Does actual refactoring for each of the Assign Gotos + * 4. Releases the AST for that file. + */ + @Override + protected void doCheckFinalConditions(RefactoringStatus status, IProgressMonitor pm) + throws PreconditionFailure + { + for (IFile file : selectedFiles) + { + FileInfo data = FileInfoFactory.getInstance(file, vpg); + String removedVariables = data.removeVariablesUsedInActionStmt(); + + if (data.getAssignedStmtList().isEmpty()) + { + FileInfoFactory.reset(); + throw new PreconditionFailure( + "All the labels were used in an action statement. Nothing left to refactor for " + file.getFullPath()); + } + else if (removedVariables.length() != 0) + { + status + .addWarning(new StringBuffer( + "The following labels cannot be refactored since they're used in an action statement : ") + .append(removedVariables).append(" for file ").append(file.getFullPath()) + .toString()); + } + } + } + + /** + * First try to create the case body by going through the list of ASSIGN statements. If we + * don't find any ASSIGN statement with the , return null. + */ + @SuppressWarnings("nls") + private ASTCaseConstructNode createSelectCaseConstruct( + ASTAssignedGotoStmtNode assignedGotoNode, FileInfo data) + { + ASTCaseConstructNode caseStmt; + String caseConstructString = ""; + String defaultCaseString = ""; + String endSelectString = "end select"; + + String caseBodyString = createSelectCaseBody(assignedGotoNode, data); + + if (caseBodyString.isEmpty()) + { + return null; + } + if (isDefaultCaseRequired) + { + defaultCaseString = "case default; stop \"Unknown label\"\n"; + } + // Create the select case string. + String selCaseString = "select case (" + assignedGotoNode.getVariableName().getText() + ")"; + + // Create the end select. + caseConstructString = selCaseString + "\n" + caseBodyString + defaultCaseString + + endSelectString + "\n"; + caseStmt = (ASTCaseConstructNode)parseLiteralStatement(caseConstructString); + + return caseStmt; + } + + private String createSelectCaseBody(ASTAssignedGotoStmtNode assignedGotoNode, FileInfo data) + { + String caseBodyString = ""; + List list = data.getAssignedStmtList(); + for (ASTAssignStmtNode assignNode : list) + { + if (assignNode.getVariableName().getText() + .equals(assignedGotoNode.getVariableName().getText())) + { + // There is at least one matching ASSIGN statement for the label. + caseBodyString += "case (" + assignNode.getAssignedLblRef().getLabel().getText() + + "); "; + caseBodyString += "goto " + assignNode.getAssignedLblRef().getLabel().getText() + + "\n"; + } + } + return caseBodyString; + } + + /** + * Does the actual change to the selected files to replace the assigned goto statements. + * + * @throws PreconditionFailure + */ + private void makeChangesTo(IFile fileInEditor, IFortranAST ast, RefactoringStatus status, + IProgressMonitor pm) throws PreconditionFailure + { + if (ast == null) + { + return; + } + FileInfo data = FileInfoFactory.getInstance(fileInEditor, vpg); + + List list = data.getAssignedStmtList(); + for (ASTAssignStmtNode assignStmtNode : list) + { + replaceAssignedWithAssignment(ast, assignStmtNode); + } + + data.sortAssignedStmtList(); + + // We also need to remove the duplicate ASSIGN statements so that the + // case construct should not have duplicate case statements in the body. + data.removeDuplicateAssigns(); + + List assignedGotoList = data.getAssignedGotoStmtList(); + for (ASTAssignedGotoStmtNode assignedGotoNode : assignedGotoList) + { + ASTCaseConstructNode caseConstructNode = createSelectCaseConstruct(assignedGotoNode, + data); + + if (caseConstructNode != null) + { + caseConstructNode.getSelectCaseStmt().setLabel(assignedGotoNode.getLabel()); + copyCommentsFromOldNode(assignedGotoNode, caseConstructNode); + assignedGotoNode.replaceWith(caseConstructNode); + Reindenter.reindent(caseConstructNode, ast, Strategy.SHIFT_ENTIRE_BLOCK); + } + } + + this.addChangeFromModifiedAST(fileInEditor, pm); + } + + /** + * Builds and replaces an existing assign statement an assignment statement. + * 1. Create the label + * 2. Build the basic assignment string + * 3. Create the node from the strings. + * 4. Replace the old with the new + * 5. Properly format the new node + * + * @param ast The AST in use + * @param node The assign statement node to replace + */ + @SuppressWarnings("nls") + private void replaceAssignedWithAssignment(IFortranAST ast, ASTAssignStmtNode node) + { + String labelStr = (node.getLabel() != null) ? node.getLabel().getText() : ""; + + String assignmentStr = node.getVariableName().getText() + " = " + + node.getAssignedLblRef().getLabel().getText(); + ASTAssignmentStmtNode assignmentStmt = (ASTAssignmentStmtNode)parseLiteralStatement(labelStr + + assignmentStr); + node.replaceWith(assignmentStmt); + + Reindenter.reindent(assignmentStmt.findFirstToken(), assignmentStmt.findLastToken(), ast); + copyCommentsFromOldNode(node, assignmentStmt); + } + + /** + * Does the refactoring for each selected file. + * Cleans up the FileInfo of the visited files. + * + * @throws OperationCanceledException if the refactoring fails. + */ + @Override + protected void doCreateChange(IProgressMonitor pm) throws CoreException, + OperationCanceledException + { + RefactoringStatus status = new RefactoringStatus(); + for (IFile file : selectedFiles) + { + IFortranAST ast = vpg.acquirePermanentAST(file); + try + { + makeChangesTo(file, ast, status, pm); + FileInfoFactory.removeInstance(file); + } + catch (PreconditionFailure e) + { + FileInfoFactory.reset(); + throw new OperationCanceledException(e.getMessage()); + } + } + } + + /** + * Copies the formatting and comments from the oldNode to the new one to preserve the structure + * when replacing a node. + * + * @param oldNode The node replaced by the refactoring + * @param newNode The node inserted with the refactoring + */ + private void copyCommentsFromOldNode(IASTNode oldNode, IASTNode newNode) + { + // Copy the formatting and comments before the statement. + newNode.findFirstToken().setWhiteBefore(oldNode.findFirstToken().getWhiteBefore()); + + // Copy the comments from end of the statement. + newNode.findLastToken().setWhiteBefore(oldNode.findLastToken().getWhiteBefore()); + } + + public PhotranVPG getVpg() + { + return vpg; + } +} Index: src/org/eclipse/photran/internal/core/refactoring/messages.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.ptp/photran/org.eclipse.photran.core.vpg/src/org/eclipse/photran/internal/core/refactoring/messages.properties,v retrieving revision 1.13 diff -u -r1.13 messages.properties --- src/org/eclipse/photran/internal/core/refactoring/messages.properties 21 Sep 2010 15:31:10 -0000 1.13 +++ src/org/eclipse/photran/internal/core/refactoring/messages.properties 9 Dec 2010 04:31:44 -0000 @@ -147,6 +147,8 @@ MoveSavedToCommonBlockRefactoring_PleaseSelectSubprogramNotInINTERFACE=The subroutine's or the function's statement should not be the interface declaration. RemoveArithmeticIfRefactoring_Error=One of the selected files ({0}) cannot be parsed. RemoveArithmeticIfRefactoring_Name=Remove Arithmetic If Statements +RemoveAssignedGoToRefactoring_Name=Remove Assigned GOTO +RemoveAssignedGoToRefactoring_SelectedFileCannotBeParsed=One of the selected files ({0}) cannot be parsed. RemoveComputedGoToRefactoring_Name=Remove Computed Goto RemoveComputedGoToRefactoring_PleaseSelectComputedGotoStmt=Please select a computed GOTO statement. RemoveUnreferencedLabelsRefactoring_Name=Remove Unreferenced Labels #P org.eclipse.photran.core.vpg.tests Index: refactoring-test-code/remove-assign-gotos-white-box/one_label_no_goto.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos-white-box/one_label_no_goto.f90 diff -N refactoring-test-code/remove-assign-gotos-white-box/one_label_no_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos-white-box/one_label_no_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +! Test 1: 1 ASSIGN Label, No GOTO statement !<<<<< 1, 1, 5, 12, pass +program one_label_no_goto + assign 100 to label +100 stop +end program Index: refactoring-test-code/remove-assign-gotos-white-box/one_label_no_goto.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos-white-box/one_label_no_goto.f90.result diff -N refactoring-test-code/remove-assign-gotos-white-box/one_label_no_goto.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos-white-box/one_label_no_goto.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +! Test 1: 1 ASSIGN Label, No GOTO statement !<<<<< 1, 1, 5, 12, pass +program one_label_no_goto + label = 100 +100 stop +end program Index: refactoring-test-code/remove-assign-gotos/test01/one_label_no_goto.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test01/one_label_no_goto.f90 diff -N refactoring-test-code/remove-assign-gotos/test01/one_label_no_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test01/one_label_no_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,6 @@ +! Test 1: 1 ASSIGN Label, No GOTO statement +! This test passes and replaces the assign statement with an assignment +program one_label_no_goto !<<<<< 1, 1, 6, 12, true, pass + assign 100 to label +100 stop +end program Index: refactoring-test-code/remove-assign-gotos/test01/one_label_no_goto.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test01/one_label_no_goto.f90.result diff -N refactoring-test-code/remove-assign-gotos/test01/one_label_no_goto.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test01/one_label_no_goto.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,6 @@ +! Test 1: 1 ASSIGN Label, No GOTO statement +! This test passes and replaces the assign statement with an assignment +program one_label_no_goto !<<<<< 1, 1, 6, 12, true, pass + label = 100 +100 stop +end program Index: refactoring-test-code/remove-assign-gotos/test02/one_label_one_address.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test02/one_label_one_address.f90 diff -N refactoring-test-code/remove-assign-gotos/test02/one_label_one_address.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test02/one_label_one_address.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,12 @@ +!Test 2: 1 ASSIGN Label, 1 goto address +!Test passes and replaces the assigned goto statements with a select case +program one_label_one_address !<<<<< 1, 1, 12, 12, true, pass + + assign 100 to label + goto 1000 +100 stop + +! Here is the intended "subroutine" +1000 print *, "hello" + goto label +end program Index: refactoring-test-code/remove-assign-gotos/test02/one_label_one_address.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test02/one_label_one_address.f90.result diff -N refactoring-test-code/remove-assign-gotos/test02/one_label_one_address.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test02/one_label_one_address.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +!Test 2: 1 ASSIGN Label, 1 goto address +!Test passes and replaces the assigned goto statements with a select case +program one_label_one_address !<<<<< 1, 1, 12, 12, true, pass + + label = 100 + goto 1000 +100 stop + +! Here is the intended "subroutine" +1000 print *, "hello" + select case (label) + case (100); goto 100 + case default; stop "Unknown label" + end select +end program Index: refactoring-test-code/remove-assign-gotos/test03/one_label_three_addresses.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test03/one_label_three_addresses.f90 diff -N refactoring-test-code/remove-assign-gotos/test03/one_label_three_addresses.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test03/one_label_three_addresses.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +! Test 3: 1 ASSIGN Label, 3 goto address +! Test passes and replaces the three assigns and gotos with a select case +! (Modified test case from the user stories) +program one_label_three_addresses !<<<<< 1, 1, 26, 12, true, pass + + character*50 message + + message = "setting initial label address" + assign 100 to label + goto 9000 + +100 message = "changing label addr for the first time" + assign 200 to label + goto 9000 + +200 message = "changing label address 2nd time." + assign 300 to label + goto 9000 + +300 stop + +! This is the "subroutine" +9000 print *, message + goto label + +end program Index: refactoring-test-code/remove-assign-gotos/test03/one_label_three_addresses.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test03/one_label_three_addresses.f90.result diff -N refactoring-test-code/remove-assign-gotos/test03/one_label_three_addresses.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test03/one_label_three_addresses.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,31 @@ +! Test 3: 1 ASSIGN Label, 3 goto address +! Test passes and replaces the three assigns and gotos with a select case +! (Modified test case from the user stories) +program one_label_three_addresses !<<<<< 1, 1, 26, 12, true, pass + + character*50 message + + message = "setting initial label address" + label = 100 + goto 9000 + +100 message = "changing label addr for the first time" + label = 200 + goto 9000 + +200 message = "changing label address 2nd time." + label = 300 + goto 9000 + +300 stop + +! This is the "subroutine" +9000 print *, message + select case (label) + case (100); goto 100 + case (200); goto 200 + case (300); goto 300 + case default; stop "Unknown label" + end select + +end program Index: refactoring-test-code/remove-assign-gotos/test04/two_labels_no_goto.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test04/two_labels_no_goto.f90 diff -N refactoring-test-code/remove-assign-gotos/test04/two_labels_no_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test04/two_labels_no_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +! Test 4: 2 ASSIGN Labels, No GOTO statement +! Test passes and replaces two assign statements with assignments +program two_labels_no_goto !<<<<< 1, 1, 7, 12, true, pass + assign 100 to label1 + assign 325 to label2 +100 continue +325 stop +end program Index: refactoring-test-code/remove-assign-gotos/test04/two_labels_no_goto.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test04/two_labels_no_goto.f90.result diff -N refactoring-test-code/remove-assign-gotos/test04/two_labels_no_goto.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test04/two_labels_no_goto.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +! Test 4: 2 ASSIGN Labels, No GOTO statement +! Test passes and replaces two assign statements with assignments +program two_labels_no_goto !<<<<< 1, 1, 7, 12, true, pass + label1 = 100 + label2 = 325 +100 continue +325 stop +end program Index: refactoring-test-code/remove-assign-gotos/test05/two_labels_one_address.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test05/two_labels_one_address.f90 diff -N refactoring-test-code/remove-assign-gotos/test05/two_labels_one_address.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test05/two_labels_one_address.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,22 @@ +! Test 5: 2 ASSIGN Labels, One GOTO address each +! Test passes and replaces two assigned gotos and creates two select case statements +program two_labels_one_address !<<<<< 1, 1, 22, 12, true, pass + real :: area + real :: radius + + assign 100 to label1 + goto 7000 + +100 radius = 3.0 + assign 325 to label2 + goto 9000 + +325 stop + +7000 print *, "hello" + goto label1 + +9000 area = 3.1415 * r**2 + goto label2 + +end program Index: refactoring-test-code/remove-assign-gotos/test05/two_labels_one_address.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test05/two_labels_one_address.f90.result diff -N refactoring-test-code/remove-assign-gotos/test05/two_labels_one_address.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test05/two_labels_one_address.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,28 @@ +! Test 5: 2 ASSIGN Labels, One GOTO address each +! Test passes and replaces two assigned gotos and creates two select case statements +program two_labels_one_address !<<<<< 1, 1, 22, 12, true, pass + real :: area + real :: radius + + label1 = 100 + goto 7000 + +100 radius = 3.0 + label2 = 325 + goto 9000 + +325 stop + +7000 print *, "hello" + select case (label1) + case (100); goto 100 + case default; stop "Unknown label" + end select + +9000 area = 3.1415 * r**2 + select case (label2) + case (325); goto 325 + case default; stop "Unknown label" + end select + +end program Index: refactoring-test-code/remove-assign-gotos/test06/two_labels_three_addresses.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test06/two_labels_three_addresses.f90 diff -N refactoring-test-code/remove-assign-gotos/test06/two_labels_three_addresses.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test06/two_labels_three_addresses.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,38 @@ +! Test 6: 2 ASSIGN Labels, Three GOTO address each +! Test passes and creates two select cases and replaces the assign statements +program two_labels_one_address !<<<<< 1, 1, 38, 12, true, pass + real :: area + real :: radius + + assign 20 to label1 + goto 7000 + +10 assign 30 to label1 + goto 7000 + +20 assign 10 to label1 + goto 7000 + stop + + +30 radius = 3.0 + assign 200 to label2 + goto 9000 + +200 radius = 4.0 + assign 300 to label2 + goto 9000 + +300 radius = 5.0 + assign 325 to label2 + goto 9000 + +325 stop + +7000 print *, "hello" + goto label1 + +9000 area = 3.1415 * r**2 + goto label2 + +end program Index: refactoring-test-code/remove-assign-gotos/test06/two_labels_three_addresses.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test06/two_labels_three_addresses.f90.result diff -N refactoring-test-code/remove-assign-gotos/test06/two_labels_three_addresses.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test06/two_labels_three_addresses.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,48 @@ +! Test 6: 2 ASSIGN Labels, Three GOTO address each +! Test passes and creates two select cases and replaces the assign statements +program two_labels_one_address !<<<<< 1, 1, 38, 12, true, pass + real :: area + real :: radius + + label1 = 20 + goto 7000 + +10 label1 = 30 + goto 7000 + +20 label1 = 10 + goto 7000 + stop + + +30 radius = 3.0 + label2 = 200 + goto 9000 + +200 radius = 4.0 + label2 = 300 + goto 9000 + +300 radius = 5.0 + label2 = 325 + goto 9000 + +325 stop + +7000 print *, "hello" + select case (label1) + case (10); goto 10 + case (20); goto 20 + case (30); goto 30 + case default; stop "Unknown label" + end select + +9000 area = 3.1415 * r**2 + select case (label2) + case (200); goto 200 + case (300); goto 300 + case (325); goto 325 + case default; stop "Unknown label" + end select + +end program Index: refactoring-test-code/remove-assign-gotos/test07/one_label_reassign_address.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test07/one_label_reassign_address.f90 diff -N refactoring-test-code/remove-assign-gotos/test07/one_label_reassign_address.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test07/one_label_reassign_address.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +! Test 7: 1 ASSIGN Label, Change value on label +! Test passes and changes the assign statements to one variable to assignments +program one_label_reassign_address !<<<<< 1, 1, 8, 12, true, pass + assign 100 to label1 + assign 200 to label1 +200 continue +100 stop +end program Index: refactoring-test-code/remove-assign-gotos/test07/one_label_reassign_label.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test07/one_label_reassign_label.f90.result diff -N refactoring-test-code/remove-assign-gotos/test07/one_label_reassign_label.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test07/one_label_reassign_label.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +! Test 7: 1 ASSIGN Label, Change value on label +! Test passes and changes the assign statements to one variable to assignments +program one_label_reassign_address !<<<<< 1, 1, 8, 12, true, pass + label1 = 100 + label1 = 200 +200 continue +100 stop +end program Index: refactoring-test-code/remove-assign-gotos/test08/two_label_same_address.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test08/two_label_same_address.f90 diff -N refactoring-test-code/remove-assign-gotos/test08/two_label_same_address.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test08/two_label_same_address.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,20 @@ +! Test 8: 2 ASSIGN Labels, goto same address +! Test passes, creating two select case statements +program two_labels_same_address !<<<<< 1, 1, 20, 12, true, pass + + assign 100 to label1 + goto 1000 +100 print *, "Return to here" + stop + + assign 100 to label2 + goto 2000 + +! Here is the intended "subroutine" +1000 print *, "This code will get executed" + goto label1 + +2000 print *, "This will not get executed since we return back since the other case stops" + goto label2 + +end program Index: refactoring-test-code/remove-assign-gotos/test08/two_labels_same_address.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test08/two_labels_same_address.f90.result diff -N refactoring-test-code/remove-assign-gotos/test08/two_labels_same_address.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test08/two_labels_same_address.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +! Test 8: 2 ASSIGN Labels, goto same address +! Test passes, creating two select case statements +program two_labels_same_address !<<<<< 1, 1, 20, 12, true, pass + + label1 = 100 + goto 1000 +100 print *, "Return to here" + stop + + label2 = 100 + goto 2000 + +! Here is the intended "subroutine" +1000 print *, "This code will get executed" + select case (label1) + case (100); goto 100 + case default; stop "Unknown label" + end select + +2000 print *, "This will not get executed since we return back since the other case stops" + select case (label2) + case (100); goto 100 + case default; stop "Unknown label" + end select + +end program Index: refactoring-test-code/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90 diff -N refactoring-test-code/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,18 @@ +! Test 9: 1 ASSIGN Label, goto 2 different addresses +! Test passes with two select case statements for the single label +program one_label_goto_two_different_addresses !<<<<< 1, 1, 17, 12, true, pass + + assign 100 to label + goto 1000 + +100 assign 200 to label + goto 2000 + +200 stop + +1000 print *, "First goto reaches here" + goto label + +2000 print *, "Second goto reaches here" + goto label +end program Index: refactoring-test-code/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90.result diff -N refactoring-test-code/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +! Test 9: 1 ASSIGN Label, goto 2 different addresses +! Test passes with two select case statements for the single label +program one_label_goto_two_different_addresses !<<<<< 1, 1, 17, 12, true, pass + + label = 100 + goto 1000 + +100 label = 200 + goto 2000 + +200 stop + +1000 print *, "First goto reaches here" + select case (label) + case (100); goto 100 + case (200); goto 200 + case default; stop "Unknown label" + end select + +2000 print *, "Second goto reaches here" + select case (label) + case (100); goto 100 + case (200); goto 200 + case default; stop "Unknown label" + end select +end program Index: refactoring-test-code/remove-assign-gotos/test10/comment_assign_and_goto.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test10/comment_assign_and_goto.f90 diff -N refactoring-test-code/remove-assign-gotos/test10/comment_assign_and_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test10/comment_assign_and_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test 10: Comment ASSIGN and GOTO statement +! Test fails because the assign and goto statements are commented out +program comment_assign_and_goto !<<<<< 1, 1, 11, 12, true, fail-initial + + !assign 100 to label + !goto 1000 +100 stop + +1000 print *, "Should not get here" + goto 100 +end program Index: refactoring-test-code/remove-assign-gotos/test11/comment_assign_valid_goto.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test11/comment_assign_valid_goto.f90 diff -N refactoring-test-code/remove-assign-gotos/test11/comment_assign_valid_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test11/comment_assign_valid_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test 11: Comment ASSIGN have a valid GOTO statement +! Test fails because the assign statement is commented out +program comment_assign_valid_goto !<<<<< 1, 1, 11, 12, true, fail-initial + + !assign 100 to label + goto 1000 +100 stop + +1000 print *, "We will get here" + goto 100 +end program Index: refactoring-test-code/remove-assign-gotos/test12/valid_assign_comment_goto.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test12/valid_assign_comment_goto.f90 diff -N refactoring-test-code/remove-assign-gotos/test12/valid_assign_comment_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test12/valid_assign_comment_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test 12: Valid ASSIGN and comment GOTO statement +! Test passes and only replaces the assign because the goto is commented out +program valid_assign_comment_goto !<<<<< 1, 1, 11, 12, true, pass + + assign 100 to label + !goto 1000 +100 stop + +1000 print *, "Should not get here" + goto 100 +end program Index: refactoring-test-code/remove-assign-gotos/test12/valid_assign_comment_goto.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test12/valid_assign_comment_goto.f90.result diff -N refactoring-test-code/remove-assign-gotos/test12/valid_assign_comment_goto.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test12/valid_assign_comment_goto.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test 12: Valid ASSIGN and comment GOTO statement +! Test passes and only replaces the assign because the goto is commented out +program valid_assign_comment_goto !<<<<< 1, 1, 11, 12, true, pass + + label = 100 + !goto 1000 +100 stop + +1000 print *, "Should not get here" + goto 100 +end program Index: refactoring-test-code/remove-assign-gotos/test13/split_assign_to_two_lines.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test13/split_assign_to_two_lines.f90 diff -N refactoring-test-code/remove-assign-gotos/test13/split_assign_to_two_lines.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test13/split_assign_to_two_lines.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,13 @@ +! Test 13: Split assign statement with ampersand +! Test passes by replacing the split-up assigned goto and creating a select case +program split_assign_to_two_lines !<<<<< 1, 1, 13, 12, true, pass + + assign 100 & + to & + label + goto 1000 +100 stop + +1000 print *, "Subroutine like stuff here" + goto label +end program Index: refactoring-test-code/remove-assign-gotos/test13/split_assign_to_two_lines.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test13/split_assign_to_two_lines.f90.result diff -N refactoring-test-code/remove-assign-gotos/test13/split_assign_to_two_lines.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test13/split_assign_to_two_lines.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +! Test 13: Split assign statement with ampersand +! Test passes by replacing the split-up assigned goto and creating a select case +program split_assign_to_two_lines !<<<<< 1, 1, 13, 12, true, pass + + label = 100 + goto 1000 +100 stop + +1000 print *, "Subroutine like stuff here" + select case (label) + case (100); goto 100 + case default; stop "Unknown label" + end select +end program Index: refactoring-test-code/remove-assign-gotos/test14/one_label_no_goto_no_address.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test14/one_label_no_goto_no_address.f90 diff -N refactoring-test-code/remove-assign-gotos/test14/one_label_no_goto_no_address.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test14/one_label_no_goto_no_address.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +! Test 14: 1 ASSIGN Label, No GOTO statement, No address +! Test fails because there is no statement 100 +program one_label_no_goto_no_address !<<<<< 1, 1, 5, 12, true, fail-initial + assign 100 to label +end program Index: refactoring-test-code/remove-assign-gotos/test15/use_label_in_equivalence.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test15/use_label_in_equivalence.f90 diff -N refactoring-test-code/remove-assign-gotos/test15/use_label_in_equivalence.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test15/use_label_in_equivalence.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,12 @@ +! Test Case 15 Label Used in Equivalence +! Test passes because equivalence is not an action statement +program use_label_in_equivalence !<<<<< 1, 1, 12, 37, true, pass + implicit none + real :: flabel + integer :: label + equivalence (label, flabel) + assign 20 to label + goto label + +20 continue +end program use_label_in_equivalence Index: refactoring-test-code/remove-assign-gotos/test15/use_label_in_equivalence.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test15/use_label_in_equivalence.f90.result diff -N refactoring-test-code/remove-assign-gotos/test15/use_label_in_equivalence.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test15/use_label_in_equivalence.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +! Test Case 15 Label Used in Equivalence +! Test passes because equivalence is not an action statement +program use_label_in_equivalence !<<<<< 1, 1, 12, 37, true, pass + implicit none + real :: flabel + integer :: label + equivalence (label, flabel) + label = 20 + select case (label) + case (20); goto 20 + case default; stop "Unknown label" + end select + +20 continue +end program use_label_in_equivalence Index: refactoring-test-code/remove-assign-gotos/test16/use_label_in_subroutine.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test16/use_label_in_subroutine.f90 diff -N refactoring-test-code/remove-assign-gotos/test16/use_label_in_subroutine.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test16/use_label_in_subroutine.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +! Test Case 16 Labels Used in a Subroutine +! Test fails because a subroutine is an action statement +program use_label_in_subroutine !<<<<< 1, 1, 15, 4, true, fail-final + implicit none + integer label + assign 20 to label + goto label +20 call print_label(label) + +end program use_label_in_subroutine + +subroutine print_label( label1 ) + integer :: label1 + print *,label1 +end Index: refactoring-test-code/remove-assign-gotos/test17/use_label_in_write.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test17/use_label_in_write.f90 diff -N refactoring-test-code/remove-assign-gotos/test17/use_label_in_write.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test17/use_label_in_write.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test Case 17 Label Used in Write +! Test fails because a write is an action statement +program use_label_in_write !<<<<< 1, 1, 11, 31, true, fail-final + implicit none + integer label + assign 20 to label + goto label + write (6, label) +20 format("6xTrying specify this line with label") + +end program use_label_in_write Index: refactoring-test-code/remove-assign-gotos/test18/use_label_in_assignment.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test18/use_label_in_assignment.f90 diff -N refactoring-test-code/remove-assign-gotos/test18/use_label_in_assignment.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test18/use_label_in_assignment.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +! Test Case 18 Label Used in Assignment +! Test fails because an assignment is an action statement +program use_label_in_assignment !<<<<< 1, 1, 8, 36, true, fail-final + implicit none + integer label + assign 20 to label + goto label + label = 40 +20 continue +end program use_label_in_assignment Index: refactoring-test-code/remove-assign-gotos/test19/use_label_in_declaration.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test19/use_label_in_declaration.f90 diff -N refactoring-test-code/remove-assign-gotos/test19/use_label_in_declaration.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test19/use_label_in_declaration.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +! Test Case 19 Label Used in Declaration +! Test passes because a declaration is not an action statement +program use_label_in_declaration !<<<<< 1, 1, 10, 37, true, pass + implicit none + integer label + assign 20 to label + goto label + +20 continue +end program use_label_in_declaration Index: refactoring-test-code/remove-assign-gotos/test19/use_label_in_declaration.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test19/use_label_in_declaration.f90.result diff -N refactoring-test-code/remove-assign-gotos/test19/use_label_in_declaration.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test19/use_label_in_declaration.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,13 @@ +! Test Case 19 Label Used in Declaration +! Test passes because a declaration is not an action statement +program use_label_in_declaration !<<<<< 1, 1, 10, 37, true, pass + implicit none + integer label + label = 20 + select case (label) + case (20); goto 20 + case default; stop "Unknown label" + end select + +20 continue +end program use_label_in_declaration Index: refactoring-test-code/remove-assign-gotos/test20/use_label_in_common_block.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test20/use_label_in_common_block.f90 diff -N refactoring-test-code/remove-assign-gotos/test20/use_label_in_common_block.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test20/use_label_in_common_block.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test Case 20 Label Used in Common Block +! Test passes because a common block is not an action statement +program use_label_in_common_block !<<<<< 1, 1, 11, 38, true, pass + implicit none + common /test/ label + integer label + assign 20 to label + goto label + +20 continue +end program use_label_in_common_block Index: refactoring-test-code/remove-assign-gotos/test20/use_label_in_common_block.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test20/use_label_in_common_block.f90.result diff -N refactoring-test-code/remove-assign-gotos/test20/use_label_in_common_block.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test20/use_label_in_common_block.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +! Test Case 20 Label Used in Common Block +! Test passes because a common block is not an action statement +program use_label_in_common_block !<<<<< 1, 1, 11, 38, true, pass + implicit none + common /test/ label + integer label + label = 20 + select case (label) + case (20); goto 20 + case default; stop "Unknown label" + end select + +20 continue +end program use_label_in_common_block Index: refactoring-test-code/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90 diff -N refactoring-test-code/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,13 @@ +! Test Case 21 Two of the Same Assign Statements +! Test passes and creates one select case statement with one select case +program two_assign_same_label_withgotos !<<<<< 1, 1, 13, 12, true, pass + + assign 100 to label + goto 1000 + +100 assign 100 to label + goto 1000 + +1000 print *, "Infinite loop" + goto label +end program Index: refactoring-test-code/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90.result diff -N refactoring-test-code/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,16 @@ +! Test Case 21 Two of the Same Assign Statements +! Test passes and creates one select case statement with one select case +program two_assign_same_label_withgotos !<<<<< 1, 1, 13, 12, true, pass + + label = 100 + goto 1000 + +100 label = 100 + goto 1000 + +1000 print *, "Infinite loop" + select case (label) + case (100); goto 100 + case default; stop "Unknown label" + end select +end program Index: refactoring-test-code/remove-assign-gotos/test22/one_label_one_address_no_default.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test22/one_label_one_address_no_default.f90 diff -N refactoring-test-code/remove-assign-gotos/test22/one_label_one_address_no_default.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test22/one_label_one_address_no_default.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,12 @@ +! Test Case 22 1 ASSIGN Label, 1 Goto Address No Default Case +! Test passes but does not include a default case in the select case statement +program one_label_one_address !<<<<< 1, 1, 12, 12, false, pass + + assign 100 to label + goto 1000 +100 stop + +! Here is the intended "subroutine" +1000 print *, "hello" + goto label +end program Index: refactoring-test-code/remove-assign-gotos/test22/one_label_one_address_no_default.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test22/one_label_one_address_no_default.f90.result diff -N refactoring-test-code/remove-assign-gotos/test22/one_label_one_address_no_default.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test22/one_label_one_address_no_default.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +! Test Case 22 1 ASSIGN Label, 1 Goto Address No Default Case +! Test passes but does not include a default case in the select case statement +program one_label_one_address !<<<<< 1, 1, 12, 12, false, pass + + label = 100 + goto 1000 +100 stop + +! Here is the intended "subroutine" +1000 print *, "hello" + select case (label) + case (100); goto 100 + end select +end program Index: refactoring-test-code/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90 diff -N refactoring-test-code/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,20 @@ +! Test Case 23 1 ASSIGN Label, goto 2 different addresses, without the default case +! Test passes but does not include the default case in the two select case statements +program one_label_goto_two_different_addresses !<<<<< 1, 1, 20, 12, false, pass + + assign 100 to label + goto 1000 + +100 assign 200 to label + goto 2000 + +200 stop + +1000 print *, "First goto reaches here" + goto label + +2000 print *, "Second goto reaches here" + goto label + +3000 print *, "Fall-through" +end program Index: refactoring-test-code/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90.result diff -N refactoring-test-code/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +! Test Case 23 1 ASSIGN Label, goto 2 different addresses, without the default case +! Test passes but does not include the default case in the two select case statements +program one_label_goto_two_different_addresses !<<<<< 1, 1, 20, 12, false, pass + + label = 100 + goto 1000 + +100 label = 200 + goto 2000 + +200 stop + +1000 print *, "First goto reaches here" + select case (label) + case (100); goto 100 + case (200); goto 200 + end select + +2000 print *, "Second goto reaches here" + select case (label) + case (100); goto 100 + case (200); goto 200 + end select + +3000 print *, "Fall-through" +end program Index: refactoring-test-code/remove-assign-gotos/test24/one_goto_with_statement_label.f90 =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test24/one_goto_with_statement_label.f90 diff -N refactoring-test-code/remove-assign-gotos/test24/one_goto_with_statement_label.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test24/one_goto_with_statement_label.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,17 @@ +! Test Case 24 with one of the assigned goto has a statement label. +! Test passes to include the statement label at the start of the select case section. +program one_goto_with_stmt_label !<<<<< 1, 1, 17, 31, true, pass +implicit none +integer labelinaction +integer anotherlabel + +assign 20 to labelinaction +goto labelinaction + +assign 30 to anotherlabel + +write (6, labelinaction) +20 format("6xTrying specify this line with label") + +30 goto anotherlabel +end program one_goto_with_stmt_label \ No newline at end of file Index: refactoring-test-code/remove-assign-gotos/test24/one_goto_with_statement_label.f90.result =================================================================== RCS file: refactoring-test-code/remove-assign-gotos/test24/one_goto_with_statement_label.f90.result diff -N refactoring-test-code/remove-assign-gotos/test24/one_goto_with_statement_label.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ refactoring-test-code/remove-assign-gotos/test24/one_goto_with_statement_label.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,19 @@ +! Test Case 24 with one of the assigned goto has a statement label. +! Test passes to include the statement label at the start of the select case section. +program one_goto_with_stmt_label !<<<<< 1, 1, 17, 31, true, pass +implicit none +integer labelinaction +integer anotherlabel + +assign 20 to labelinaction +goto labelinaction + +anotherlabel = 30 + +write (6, labelinaction) +20 format("6xTrying specify this line with label") +30 select case (anotherlabel) + case (30); goto 30 + case default; stop "Unknown label" + end select +end program one_goto_with_stmt_label Index: src/org/eclipse/photran/internal/tests/refactoring/RemoveAssignGotoTestSuite.java =================================================================== RCS file: src/org/eclipse/photran/internal/tests/refactoring/RemoveAssignGotoTestSuite.java diff -N src/org/eclipse/photran/internal/tests/refactoring/RemoveAssignGotoTestSuite.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/tests/refactoring/RemoveAssignGotoTestSuite.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2010 Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, + * Balaji Ambresh Rajkumar and Paramvir Singh. + * 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: + * Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, Balaji Ambresh Rajkumar + * and Paramvir Singh - Initial API and implementation + * + *******************************************************************************/ +package org.eclipse.photran.internal.tests.refactoring; + +import junit.framework.Test; + +import org.eclipse.core.resources.IFile; +import org.eclipse.jface.text.TextSelection; +import org.eclipse.photran.internal.core.refactoring.RemoveAssignedGotoRefactoring; +import org.eclipse.photran.internal.tests.Activator; +import org.eclipse.photran.internal.tests.PhotranRefactoringTestSuiteFromMarkers; + +/** + * Unit tests for the Remove Assigned Goto refactoring. + * + * * @author Andrea Dranberg + * @author John Hammonds + * @author Rajashekhar Arasanal + * @author Balaji Ambresh Rajkumar + * @author Paramvir Singh + */ +public class RemoveAssignGotoTestSuite + extends PhotranRefactoringTestSuiteFromMarkers +{ + private static final String DIR = "refactoring-test-code/remove-assign-gotos"; + + public static Test suite() throws Exception + { + return new RemoveAssignGotoTestSuite(); + } + + public RemoveAssignGotoTestSuite() throws Exception + { + super(Activator.getDefault(), + "Running Remove Assigned Goto refactoring in", + DIR, + RemoveAssignedGotoRefactoring.class); + } + + /** + * Overridden method to allow refactoring to process the 'isDefaultCaseRequired' + * field of the marker. + * + * MARKER FORMAT: !<<<<< startLine, startCol, endLine, endCol, isDefaultCaseRequired, result + * + * Note: result is either pass, fail-initial, or fail-final + */ + @Override + protected boolean configureRefactoring(RemoveAssignedGotoRefactoring refactoring, + IFile file, + TextSelection selection, + String[] markerText) + { + boolean shouldSucceed = super.configureRefactoring(refactoring, file, selection, markerText); + refactoring.setDefaultSelected(Boolean.parseBoolean(markerText[4])); + + return shouldSucceed; + } + + /** + * Method that prevents compilation of test files we know aren't supposed to compile + */ + @Override protected boolean shouldCompile(IFile fileContainingMarker) + { + return ! (fileContainingMarker.getName().equalsIgnoreCase("one_label_no_goto_no_address.f90") || + fileContainingMarker.getName().equalsIgnoreCase("integer_label_assign_and_assignment.f90")); + } +} Index: src/org/eclipse/photran/internal/tests/refactoring/removeassignedgoto/RemoveAssignedGotoTestCase.java =================================================================== RCS file: src/org/eclipse/photran/internal/tests/refactoring/removeassignedgoto/RemoveAssignedGotoTestCase.java diff -N src/org/eclipse/photran/internal/tests/refactoring/removeassignedgoto/RemoveAssignedGotoTestCase.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/tests/refactoring/removeassignedgoto/RemoveAssignedGotoTestCase.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2010 Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, + * Balaji Ambresh Rajkumar and Paramvir Singh. + * 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: + * Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, Balaji Ambresh Rajkumar + * and Paramvir Singh - Initial API and implementation + * + *******************************************************************************/ +package org.eclipse.photran.internal.tests.refactoring.removeassignedgoto; + +import java.util.Collections; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.jface.text.ITextSelection; +import org.eclipse.photran.internal.core.refactoring.RemoveAssignedGotoRefactoring; +import org.eclipse.photran.internal.tests.Activator; +import org.eclipse.photran.internal.tests.PhotranWorkspaceTestCase; + +/** + * White-box test cases for the remove assigned goto refactoring. + * @author Andrea Dranberg + * @author John Hammonds + * @author Rajashekhar Arasanal + * @author Balaji Ambresh Rajkumar + * @author Paramvir Singh + */ +public class RemoveAssignedGotoTestCase extends PhotranWorkspaceTestCase +{ + private static final String DIR = "refactoring-test-code/remove-assign-gotos-white-box"; + + private static NullProgressMonitor pm = new NullProgressMonitor(); + + protected ITextSelection selectionToExtract = null; + + public RemoveAssignedGotoTestCase() + { + this.setName("test"); + } + + /** + * Test case to check if the tool collects correct number of ASSIGN + * and assigned GOTOs from the input file one_label_no_goto.f90. + */ + protected void doRefactoring() + { + try + { + IFile thisFile; + thisFile = importFile(Activator.getDefault(), DIR, "one_label_no_goto.f90"); + RemoveAssignedGotoRefactoring tool = new RemoveAssignedGotoRefactoring(); + tool.initialize(Collections.singletonList(thisFile)); + tool.checkInitialConditions(pm); + RemoveAssignedGotoRefactoring.FileInfo data = RemoveAssignedGotoRefactoring.FileInfoFactory + .getInstance(thisFile, tool.getVpg()); + assertTrue(data.getAssignedGotoStmtList().size() == 0); + assertTrue(data.getAssignedStmtList().size() == 1); + } catch (Exception e) + { + fail("problem in doRefactoring"); + } + } + + public void test() throws Exception + { + // There is only one white-box test case at the moment. + doRefactoring(); + + // Add more functions like doRefactoring() to add more white-box + // test cases here. + } +} Index: src/org/eclipse/photran/internal/tests/refactoring/removeassignedgoto/RemoveAssignedGotoTestSuite.java =================================================================== RCS file: src/org/eclipse/photran/internal/tests/refactoring/removeassignedgoto/RemoveAssignedGotoTestSuite.java diff -N src/org/eclipse/photran/internal/tests/refactoring/removeassignedgoto/RemoveAssignedGotoTestSuite.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/tests/refactoring/removeassignedgoto/RemoveAssignedGotoTestSuite.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2010 Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, + * Balaji Ambresh Rajkumar and Paramvir Singh. + * 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: + * Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, Balaji Ambresh Rajkumar + * and Paramvir Singh - Initial API and implementation + * + *******************************************************************************/ +package org.eclipse.photran.internal.tests.refactoring.removeassignedgoto; + +import junit.framework.Test; +import junit.framework.TestSuite; +/** + * White-box test suite for the remove assigned goto refactoring. + * + * @author Andrea Dranberg + * @author John Hammonds + * @author Rajashekhar Arasanal + * @author Balaji Ambresh Rajkumar + * @author Paramvir Singh + */ + +public class RemoveAssignedGotoTestSuite extends TestSuite +{ + public static Test suite() throws Exception + { + TestSuite suite = new TestSuite(); + suite.addTest(getSuiteFor()); + return suite; + } + + private static TestSuite getSuiteFor() + { + TestSuite subSuite = new TestSuite("Removing assigned gotos white-box test cases"); + subSuite.addTest(new RemoveAssignedGotoTestCase()); + return subSuite; + } +} #P org.eclipse.photran.ui.vpg Index: plugin.xml =================================================================== RCS file: /cvsroot/tools/org.eclipse.ptp/photran/org.eclipse.photran.ui.vpg/plugin.xml,v retrieving revision 1.78 diff -u -r1.78 plugin.xml --- plugin.xml 16 Nov 2010 18:07:25 -0000 1.78 +++ plugin.xml 9 Dec 2010 04:31:45 -0000 @@ -83,6 +83,9 @@ + + + @@ -174,6 +182,12 @@ contextId="org.eclipse.photran.ui.FortranEditorContext" commandId="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand" /> + @@ -199,6 +213,11 @@ definitionId="org.eclipse.photran.ui.ExtractLocalVariableRefactoringCommand" class="org.eclipse.photran.internal.ui.refactoring.ExtractLocalVariableAction" id="org.eclipse.photran.ui.ExtractLocalVariableRefactoringAction"/> + Index: src/org/eclipse/photran/internal/ui/refactoring/Messages.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.ptp/photran/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/refactoring/Messages.java,v retrieving revision 1.3 diff -u -r1.3 Messages.java --- src/org/eclipse/photran/internal/ui/refactoring/Messages.java 21 Sep 2010 13:26:16 -0000 1.3 +++ src/org/eclipse/photran/internal/ui/refactoring/Messages.java 9 Dec 2010 04:31:45 -0000 @@ -19,6 +19,14 @@ { private static final String BUNDLE_NAME = "org.eclipse.photran.internal.ui.refactoring.messages"; //$NON-NLS-1$ + public static String RemoveAssignGotoInputPage_ClickOKMessage; + + public static String RemoveAssignGotoInputPage_Yes; + + public static String RemoveAssignGotoInputPage_No; + + public static String RemoveAssignGotoInputPage_Prompt; + public static String AbstractFortranRefactoringActionDelegate_ErrorTitle; public static String AbstractFortranRefactoringActionDelegate_FileInEditorCannotBeRefactored; Index: src/org/eclipse/photran/internal/ui/refactoring/RemoveAssignedGotoAction.java =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/RemoveAssignedGotoAction.java diff -N src/org/eclipse/photran/internal/ui/refactoring/RemoveAssignedGotoAction.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/RemoveAssignedGotoAction.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2010 Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, + * Balaji Ambresh Rajkumar and Paramvir Singh. + * 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: + * Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, Balaji Ambresh Rajkumar + * and Paramvir Singh - Initial API and implementation + * + *******************************************************************************/ +package org.eclipse.photran.internal.ui.refactoring; + +import java.util.List; + +import org.eclipse.core.resources.IFile; +import org.eclipse.photran.core.IFortranAST; +import org.eclipse.photran.internal.core.lexer.Token; +import org.eclipse.photran.internal.core.refactoring.RemoveAssignedGotoRefactoring; +import org.eclipse.photran.internal.core.vpg.PhotranVPG; +import org.eclipse.rephraserengine.core.vpg.refactoring.VPGRefactoring; +import org.eclipse.ui.IEditorActionDelegate; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +/** + * Handles the Remove Assigned Goto action in the Fortran editor's Refactoring popup menu and in the + * Refactor menu in the workbench menu bar. + * White-box test cases for the remove assigned goto refactoring. + * @author Andrea Dranberg + * @author John Hammonds + * @author Rajashekhar Arasanal + * @author Balaji Ambresh Rajkumar + * @author Paramvir Singh + */ +public class RemoveAssignedGotoAction extends AbstractFortranRefactoringActionDelegate implements + IWorkbenchWindowActionDelegate, IEditorActionDelegate +{ + public RemoveAssignedGotoAction() + { + super(RemoveAssignedGotoRefactoring.class, FortranRemoveAssignedGotoWizard.class); + } + + @Override + protected VPGRefactoring getRefactoring(List files) + { + RemoveAssignedGotoRefactoring r = new RemoveAssignedGotoRefactoring(); + r.initialize(files); + return r; + } + + /** + * Creates the user input dialog box that is specific to the RemoveAssignedGotoRefactoring. + * This class is used by the action class. + */ + public static class FortranRemoveAssignedGotoWizard extends AbstractFortranRefactoringWizard + { + public FortranRemoveAssignedGotoWizard(VPGRefactoring r) + { + super(r); + } + + /** + * Sets the refactoring tool to {@link #RemoveAssignedGotoInputPage} for + * the input wizard. + */ + @Override + protected void doAddUserInputPages() + { + RemoveAssignedGotoInputPage inputPage = new RemoveAssignedGotoInputPage(); + inputPage.setRefactoring((RemoveAssignedGotoRefactoring)getRefactoring()); + addPage(inputPage); + } + } +} Index: src/org/eclipse/photran/internal/ui/refactoring/RemoveAssignedGotoInputPage.java =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/RemoveAssignedGotoInputPage.java diff -N src/org/eclipse/photran/internal/ui/refactoring/RemoveAssignedGotoInputPage.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/RemoveAssignedGotoInputPage.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,76 @@ +/******************************************************************************* + * Copyright (c) 2010 Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, + * Balaji Ambresh Rajkumar and Paramvir Singh. + * 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: + * Andrea Dranberg, John Hammonds, Rajashekhar Arasanal, Balaji Ambresh Rajkumar + * and Paramvir Singh - Initial API and implementation + * + *******************************************************************************/ +package org.eclipse.photran.internal.ui.refactoring; + +import org.eclipse.photran.internal.core.refactoring.RemoveAssignedGotoRefactoring; +import org.eclipse.rephraserengine.ui.refactoring.CustomUserInputPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +/** + * Creates the input wizard with a YES/NO radio button with the refactoring + * prompt. Starter code was borrowed from {#link KeywordCaseInputPage} + * White-box test cases for the remove assigned goto refactoring. + * @author Andrea Dranberg + * @author John Hammonds + * @author Rajashekhar Arasanal + * @author Balaji Ambresh Rajkumar + * @author Paramvir Singh + */ +public class RemoveAssignedGotoInputPage extends CustomUserInputPage +{ + protected Button radioYes; + protected Button radioNo; + + @Override + public void createControl(Composite parent) + { + Composite top = new Composite(parent, SWT.NONE); + initializeDialogUnits(top); + setControl(top); + + top.setLayout(new GridLayout(1, false)); + + Composite group = top; + Label instr = new Label(group, SWT.NONE); + instr.setText(Messages.RemoveAssignGotoInputPage_Prompt); + + radioYes = new Button(group, SWT.RADIO); + radioYes.setText(Messages.RemoveAssignGotoInputPage_Yes); + radioYes.setSelection(true); + radioYes.addSelectionListener(new SelectionListener() + { + public void widgetDefaultSelected(SelectionEvent e) + { + widgetSelected(e); + } + + public void widgetSelected(SelectionEvent e) + { + getRefactoring().setDefaultSelected(radioYes.getSelection()); + } + }); + + radioNo = new Button(group, SWT.RADIO); + radioNo.setText(Messages.RemoveAssignGotoInputPage_No); + + Label lbl = new Label(group, SWT.NONE); + lbl.setText(Messages.RemoveAssignGotoInputPage_ClickOKMessage); + } +} Index: src/org/eclipse/photran/internal/ui/refactoring/messages.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.ptp/photran/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/refactoring/messages.properties,v retrieving revision 1.2 diff -u -r1.2 messages.properties --- src/org/eclipse/photran/internal/ui/refactoring/messages.properties 21 Sep 2010 13:26:16 -0000 1.2 +++ src/org/eclipse/photran/internal/ui/refactoring/messages.properties 9 Dec 2010 04:31:45 -0000 @@ -31,3 +31,7 @@ MoveFromModuleInputPage_selectDataMessage=Please select member data to move from module RenameAction_MatchExternalSubprograms=Match external subprograms with interfaces and external declarations RenameAction_RenameAtoB=Rename {0} to +RemoveAssignGotoInputPage_Prompt=Add Default Case? +RemoveAssignGotoInputPage_Yes=Yes +RemoveAssignGotoInputPage_No=No +RemoveAssignGotoInputPage_ClickOKMessage=Click OK to change all asigned gotos to select case blocks. To see what changes will be made, click Preview. \ No newline at end of file Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos-white-box/one_label_no_goto.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos-white-box/one_label_no_goto.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos-white-box/one_label_no_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos-white-box/one_label_no_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +! Test 1: 1 ASSIGN Label, No GOTO statement !<<<<< 1, 1, 5, 12, pass +program one_label_no_goto + assign 100 to label +100 stop +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos-white-box/one_label_no_goto.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos-white-box/one_label_no_goto.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos-white-box/one_label_no_goto.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos-white-box/one_label_no_goto.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +! Test 1: 1 ASSIGN Label, No GOTO statement !<<<<< 1, 1, 5, 12, pass +program one_label_no_goto + label = 100 +100 stop +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test01/one_label_no_goto.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test01/one_label_no_goto.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test01/one_label_no_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test01/one_label_no_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,6 @@ +! Test 1: 1 ASSIGN Label, No GOTO statement +! This test passes and replaces the assign statement with an assignment +program one_label_no_goto !<<<<< 1, 1, 6, 12, true, pass + assign 100 to label +100 stop +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test01/one_label_no_goto.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test01/one_label_no_goto.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test01/one_label_no_goto.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test01/one_label_no_goto.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,6 @@ +! Test 1: 1 ASSIGN Label, No GOTO statement +! This test passes and replaces the assign statement with an assignment +program one_label_no_goto !<<<<< 1, 1, 6, 12, true, pass + label = 100 +100 stop +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test02/one_label_one_address.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test02/one_label_one_address.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test02/one_label_one_address.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test02/one_label_one_address.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,12 @@ +!Test 2: 1 ASSIGN Label, 1 goto address +!Test passes and replaces the assigned goto statements with a select case +program one_label_one_address !<<<<< 1, 1, 12, 12, true, pass + + assign 100 to label + goto 1000 +100 stop + +! Here is the intended "subroutine" +1000 print *, "hello" + goto label +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test02/one_label_one_address.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test02/one_label_one_address.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test02/one_label_one_address.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test02/one_label_one_address.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +!Test 2: 1 ASSIGN Label, 1 goto address +!Test passes and replaces the assigned goto statements with a select case +program one_label_one_address !<<<<< 1, 1, 12, 12, true, pass + + label = 100 + goto 1000 +100 stop + +! Here is the intended "subroutine" +1000 print *, "hello" + select case (label) + case (100); goto 100 + case default; stop "Unknown label" + end select +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test03/one_label_three_addresses.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test03/one_label_three_addresses.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test03/one_label_three_addresses.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test03/one_label_three_addresses.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +! Test 3: 1 ASSIGN Label, 3 goto address +! Test passes and replaces the three assigns and gotos with a select case +! (Modified test case from the user stories) +program one_label_three_addresses !<<<<< 1, 1, 26, 12, true, pass + + character*50 message + + message = "setting initial label address" + assign 100 to label + goto 9000 + +100 message = "changing label addr for the first time" + assign 200 to label + goto 9000 + +200 message = "changing label address 2nd time." + assign 300 to label + goto 9000 + +300 stop + +! This is the "subroutine" +9000 print *, message + goto label + +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test03/one_label_three_addresses.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test03/one_label_three_addresses.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test03/one_label_three_addresses.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test03/one_label_three_addresses.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,31 @@ +! Test 3: 1 ASSIGN Label, 3 goto address +! Test passes and replaces the three assigns and gotos with a select case +! (Modified test case from the user stories) +program one_label_three_addresses !<<<<< 1, 1, 26, 12, true, pass + + character*50 message + + message = "setting initial label address" + label = 100 + goto 9000 + +100 message = "changing label addr for the first time" + label = 200 + goto 9000 + +200 message = "changing label address 2nd time." + label = 300 + goto 9000 + +300 stop + +! This is the "subroutine" +9000 print *, message + select case (label) + case (100); goto 100 + case (200); goto 200 + case (300); goto 300 + case default; stop "Unknown label" + end select + +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test04/two_labels_no_goto.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test04/two_labels_no_goto.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test04/two_labels_no_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test04/two_labels_no_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +! Test 4: 2 ASSIGN Labels, No GOTO statement +! Test passes and replaces two assign statements with assignments +program two_labels_no_goto !<<<<< 1, 1, 7, 12, true, pass + assign 100 to label1 + assign 325 to label2 +100 continue +325 stop +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test04/two_labels_no_goto.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test04/two_labels_no_goto.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test04/two_labels_no_goto.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test04/two_labels_no_goto.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +! Test 4: 2 ASSIGN Labels, No GOTO statement +! Test passes and replaces two assign statements with assignments +program two_labels_no_goto !<<<<< 1, 1, 7, 12, true, pass + label1 = 100 + label2 = 325 +100 continue +325 stop +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test05/two_labels_one_address.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test05/two_labels_one_address.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test05/two_labels_one_address.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test05/two_labels_one_address.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,22 @@ +! Test 5: 2 ASSIGN Labels, One GOTO address each +! Test passes and replaces two assigned gotos and creates two select case statements +program two_labels_one_address !<<<<< 1, 1, 22, 12, true, pass + real :: area + real :: radius + + assign 100 to label1 + goto 7000 + +100 radius = 3.0 + assign 325 to label2 + goto 9000 + +325 stop + +7000 print *, "hello" + goto label1 + +9000 area = 3.1415 * r**2 + goto label2 + +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test05/two_labels_one_address.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test05/two_labels_one_address.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test05/two_labels_one_address.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test05/two_labels_one_address.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,28 @@ +! Test 5: 2 ASSIGN Labels, One GOTO address each +! Test passes and replaces two assigned gotos and creates two select case statements +program two_labels_one_address !<<<<< 1, 1, 22, 12, true, pass + real :: area + real :: radius + + label1 = 100 + goto 7000 + +100 radius = 3.0 + label2 = 325 + goto 9000 + +325 stop + +7000 print *, "hello" + select case (label1) + case (100); goto 100 + case default; stop "Unknown label" + end select + +9000 area = 3.1415 * r**2 + select case (label2) + case (325); goto 325 + case default; stop "Unknown label" + end select + +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test06/two_labels_three_addresses.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test06/two_labels_three_addresses.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test06/two_labels_three_addresses.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test06/two_labels_three_addresses.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,38 @@ +! Test 6: 2 ASSIGN Labels, Three GOTO address each +! Test passes and creates two select cases and replaces the assign statements +program two_labels_one_address !<<<<< 1, 1, 38, 12, true, pass + real :: area + real :: radius + + assign 20 to label1 + goto 7000 + +10 assign 30 to label1 + goto 7000 + +20 assign 10 to label1 + goto 7000 + stop + + +30 radius = 3.0 + assign 200 to label2 + goto 9000 + +200 radius = 4.0 + assign 300 to label2 + goto 9000 + +300 radius = 5.0 + assign 325 to label2 + goto 9000 + +325 stop + +7000 print *, "hello" + goto label1 + +9000 area = 3.1415 * r**2 + goto label2 + +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test06/two_labels_three_addresses.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test06/two_labels_three_addresses.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test06/two_labels_three_addresses.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test06/two_labels_three_addresses.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,48 @@ +! Test 6: 2 ASSIGN Labels, Three GOTO address each +! Test passes and creates two select cases and replaces the assign statements +program two_labels_one_address !<<<<< 1, 1, 38, 12, true, pass + real :: area + real :: radius + + label1 = 20 + goto 7000 + +10 label1 = 30 + goto 7000 + +20 label1 = 10 + goto 7000 + stop + + +30 radius = 3.0 + label2 = 200 + goto 9000 + +200 radius = 4.0 + label2 = 300 + goto 9000 + +300 radius = 5.0 + label2 = 325 + goto 9000 + +325 stop + +7000 print *, "hello" + select case (label1) + case (10); goto 10 + case (20); goto 20 + case (30); goto 30 + case default; stop "Unknown label" + end select + +9000 area = 3.1415 * r**2 + select case (label2) + case (200); goto 200 + case (300); goto 300 + case (325); goto 325 + case default; stop "Unknown label" + end select + +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test07/one_label_reassign_address.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test07/one_label_reassign_address.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test07/one_label_reassign_address.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test07/one_label_reassign_address.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +! Test 7: 1 ASSIGN Label, Change value on label +! Test passes and changes the assign statements to one variable to assignments +program one_label_reassign_address !<<<<< 1, 1, 8, 12, true, pass + assign 100 to label1 + assign 200 to label1 +200 continue +100 stop +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test07/one_label_reassign_label.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test07/one_label_reassign_label.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test07/one_label_reassign_label.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test07/one_label_reassign_label.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,8 @@ +! Test 7: 1 ASSIGN Label, Change value on label +! Test passes and changes the assign statements to one variable to assignments +program one_label_reassign_address !<<<<< 1, 1, 8, 12, true, pass + label1 = 100 + label1 = 200 +200 continue +100 stop +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test08/two_label_same_address.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test08/two_label_same_address.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test08/two_label_same_address.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test08/two_label_same_address.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,20 @@ +! Test 8: 2 ASSIGN Labels, goto same address +! Test passes, creating two select case statements +program two_labels_same_address !<<<<< 1, 1, 20, 12, true, pass + + assign 100 to label1 + goto 1000 +100 print *, "Return to here" + stop + + assign 100 to label2 + goto 2000 + +! Here is the intended "subroutine" +1000 print *, "This code will get executed" + goto label1 + +2000 print *, "This will not get executed since we return back since the other case stops" + goto label2 + +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test08/two_labels_same_address.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test08/two_labels_same_address.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test08/two_labels_same_address.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test08/two_labels_same_address.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +! Test 8: 2 ASSIGN Labels, goto same address +! Test passes, creating two select case statements +program two_labels_same_address !<<<<< 1, 1, 20, 12, true, pass + + label1 = 100 + goto 1000 +100 print *, "Return to here" + stop + + label2 = 100 + goto 2000 + +! Here is the intended "subroutine" +1000 print *, "This code will get executed" + select case (label1) + case (100); goto 100 + case default; stop "Unknown label" + end select + +2000 print *, "This will not get executed since we return back since the other case stops" + select case (label2) + case (100); goto 100 + case default; stop "Unknown label" + end select + +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,18 @@ +! Test 9: 1 ASSIGN Label, goto 2 different addresses +! Test passes with two select case statements for the single label +program one_label_goto_two_different_addresses !<<<<< 1, 1, 17, 12, true, pass + + assign 100 to label + goto 1000 + +100 assign 200 to label + goto 2000 + +200 stop + +1000 print *, "First goto reaches here" + goto label + +2000 print *, "Second goto reaches here" + goto label +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test09/one_label_goto_two_different_addresses.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +! Test 9: 1 ASSIGN Label, goto 2 different addresses +! Test passes with two select case statements for the single label +program one_label_goto_two_different_addresses !<<<<< 1, 1, 17, 12, true, pass + + label = 100 + goto 1000 + +100 label = 200 + goto 2000 + +200 stop + +1000 print *, "First goto reaches here" + select case (label) + case (100); goto 100 + case (200); goto 200 + case default; stop "Unknown label" + end select + +2000 print *, "Second goto reaches here" + select case (label) + case (100); goto 100 + case (200); goto 200 + case default; stop "Unknown label" + end select +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test10/comment_assign_and_goto.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test10/comment_assign_and_goto.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test10/comment_assign_and_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test10/comment_assign_and_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test 10: Comment ASSIGN and GOTO statement +! Test fails because the assign and goto statements are commented out +program comment_assign_and_goto !<<<<< 1, 1, 11, 12, true, fail-initial + + !assign 100 to label + !goto 1000 +100 stop + +1000 print *, "Should not get here" + goto 100 +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test11/comment_assign_valid_goto.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test11/comment_assign_valid_goto.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test11/comment_assign_valid_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test11/comment_assign_valid_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test 11: Comment ASSIGN have a valid GOTO statement +! Test fails because the assign statement is commented out +program comment_assign_valid_goto !<<<<< 1, 1, 11, 12, true, fail-initial + + !assign 100 to label + goto 1000 +100 stop + +1000 print *, "We will get here" + goto 100 +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test12/valid_assign_comment_goto.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test12/valid_assign_comment_goto.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test12/valid_assign_comment_goto.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test12/valid_assign_comment_goto.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test 12: Valid ASSIGN and comment GOTO statement +! Test passes and only replaces the assign because the goto is commented out +program valid_assign_comment_goto !<<<<< 1, 1, 11, 12, true, pass + + assign 100 to label + !goto 1000 +100 stop + +1000 print *, "Should not get here" + goto 100 +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test12/valid_assign_comment_goto.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test12/valid_assign_comment_goto.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test12/valid_assign_comment_goto.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test12/valid_assign_comment_goto.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test 12: Valid ASSIGN and comment GOTO statement +! Test passes and only replaces the assign because the goto is commented out +program valid_assign_comment_goto !<<<<< 1, 1, 11, 12, true, pass + + label = 100 + !goto 1000 +100 stop + +1000 print *, "Should not get here" + goto 100 +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test13/split_assign_to_two_lines.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test13/split_assign_to_two_lines.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test13/split_assign_to_two_lines.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test13/split_assign_to_two_lines.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,13 @@ +! Test 13: Split assign statement with ampersand +! Test passes by replacing the split-up assigned goto and creating a select case +program split_assign_to_two_lines !<<<<< 1, 1, 13, 12, true, pass + + assign 100 & + to & + label + goto 1000 +100 stop + +1000 print *, "Subroutine like stuff here" + goto label +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test13/split_assign_to_two_lines.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test13/split_assign_to_two_lines.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test13/split_assign_to_two_lines.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test13/split_assign_to_two_lines.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +! Test 13: Split assign statement with ampersand +! Test passes by replacing the split-up assigned goto and creating a select case +program split_assign_to_two_lines !<<<<< 1, 1, 13, 12, true, pass + + label = 100 + goto 1000 +100 stop + +1000 print *, "Subroutine like stuff here" + select case (label) + case (100); goto 100 + case default; stop "Unknown label" + end select +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test14/one_label_no_goto_no_address.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test14/one_label_no_goto_no_address.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test14/one_label_no_goto_no_address.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test14/one_label_no_goto_no_address.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,5 @@ +! Test 14: 1 ASSIGN Label, No GOTO statement, No address +! Test fails because there is no statement 100 +program one_label_no_goto_no_address !<<<<< 1, 1, 5, 12, true, fail-initial + assign 100 to label +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test15/use_label_in_equivalence.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test15/use_label_in_equivalence.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test15/use_label_in_equivalence.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test15/use_label_in_equivalence.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,12 @@ +! Test Case 15 Label Used in Equivalence +! Test passes because equivalence is not an action statement +program use_label_in_equivalence !<<<<< 1, 1, 12, 37, true, pass + implicit none + real :: flabel + integer :: label + equivalence (label, flabel) + assign 20 to label + goto label + +20 continue +end program use_label_in_equivalence Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test15/use_label_in_equivalence.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test15/use_label_in_equivalence.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test15/use_label_in_equivalence.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test15/use_label_in_equivalence.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +! Test Case 15 Label Used in Equivalence +! Test passes because equivalence is not an action statement +program use_label_in_equivalence !<<<<< 1, 1, 12, 37, true, pass + implicit none + real :: flabel + integer :: label + equivalence (label, flabel) + label = 20 + select case (label) + case (20); goto 20 + case default; stop "Unknown label" + end select + +20 continue +end program use_label_in_equivalence Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test16/use_label_in_subroutine.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test16/use_label_in_subroutine.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test16/use_label_in_subroutine.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test16/use_label_in_subroutine.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,15 @@ +! Test Case 16 Labels Used in a Subroutine +! Test fails because a subroutine is an action statement +program use_label_in_subroutine !<<<<< 1, 1, 15, 4, true, fail-final + implicit none + integer label + assign 20 to label + goto label +20 call print_label(label) + +end program use_label_in_subroutine + +subroutine print_label( label1 ) + integer :: label1 + print *,label1 +end Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test17/use_label_in_write.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test17/use_label_in_write.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test17/use_label_in_write.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test17/use_label_in_write.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test Case 17 Label Used in Write +! Test fails because a write is an action statement +program use_label_in_write !<<<<< 1, 1, 11, 31, true, fail-final + implicit none + integer label + assign 20 to label + goto label + write (6, label) +20 format("6xTrying specify this line with label") + +end program use_label_in_write Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test18/use_label_in_assignment.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test18/use_label_in_assignment.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test18/use_label_in_assignment.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test18/use_label_in_assignment.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +! Test Case 18 Label Used in Assignment +! Test fails because an assignment is an action statement +program use_label_in_assignment !<<<<< 1, 1, 8, 36, true, fail-final + implicit none + integer label + assign 20 to label + goto label + label = 40 +20 continue +end program use_label_in_assignment Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test19/use_label_in_declaration.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test19/use_label_in_declaration.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test19/use_label_in_declaration.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test19/use_label_in_declaration.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,10 @@ +! Test Case 19 Label Used in Declaration +! Test passes because a declaration is not an action statement +program use_label_in_declaration !<<<<< 1, 1, 10, 37, true, pass + implicit none + integer label + assign 20 to label + goto label + +20 continue +end program use_label_in_declaration Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test19/use_label_in_declaration.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test19/use_label_in_declaration.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test19/use_label_in_declaration.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test19/use_label_in_declaration.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,13 @@ +! Test Case 19 Label Used in Declaration +! Test passes because a declaration is not an action statement +program use_label_in_declaration !<<<<< 1, 1, 10, 37, true, pass + implicit none + integer label + label = 20 + select case (label) + case (20); goto 20 + case default; stop "Unknown label" + end select + +20 continue +end program use_label_in_declaration Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test20/use_label_in_common_block.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test20/use_label_in_common_block.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test20/use_label_in_common_block.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test20/use_label_in_common_block.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,11 @@ +! Test Case 20 Label Used in Common Block +! Test passes because a common block is not an action statement +program use_label_in_common_block !<<<<< 1, 1, 11, 38, true, pass + implicit none + common /test/ label + integer label + assign 20 to label + goto label + +20 continue +end program use_label_in_common_block Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test20/use_label_in_common_block.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test20/use_label_in_common_block.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test20/use_label_in_common_block.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test20/use_label_in_common_block.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +! Test Case 20 Label Used in Common Block +! Test passes because a common block is not an action statement +program use_label_in_common_block !<<<<< 1, 1, 11, 38, true, pass + implicit none + common /test/ label + integer label + label = 20 + select case (label) + case (20); goto 20 + case default; stop "Unknown label" + end select + +20 continue +end program use_label_in_common_block Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,13 @@ +! Test Case 21 Two of the Same Assign Statements +! Test passes and creates one select case statement with one select case +program two_assign_same_label_withgotos !<<<<< 1, 1, 13, 12, true, pass + + assign 100 to label + goto 1000 + +100 assign 100 to label + goto 1000 + +1000 print *, "Infinite loop" + goto label +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test21/two_assign_same_label_withgotos.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,16 @@ +! Test Case 21 Two of the Same Assign Statements +! Test passes and creates one select case statement with one select case +program two_assign_same_label_withgotos !<<<<< 1, 1, 13, 12, true, pass + + label = 100 + goto 1000 + +100 label = 100 + goto 1000 + +1000 print *, "Infinite loop" + select case (label) + case (100); goto 100 + case default; stop "Unknown label" + end select +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test22/one_label_one_address_no_default.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test22/one_label_one_address_no_default.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test22/one_label_one_address_no_default.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test22/one_label_one_address_no_default.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,12 @@ +! Test Case 22 1 ASSIGN Label, 1 Goto Address No Default Case +! Test passes but does not include a default case in the select case statement +program one_label_one_address !<<<<< 1, 1, 12, 12, false, pass + + assign 100 to label + goto 1000 +100 stop + +! Here is the intended "subroutine" +1000 print *, "hello" + goto label +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test22/one_label_one_address_no_default.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test22/one_label_one_address_no_default.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test22/one_label_one_address_no_default.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test22/one_label_one_address_no_default.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,14 @@ +! Test Case 22 1 ASSIGN Label, 1 Goto Address No Default Case +! Test passes but does not include a default case in the select case statement +program one_label_one_address !<<<<< 1, 1, 12, 12, false, pass + + label = 100 + goto 1000 +100 stop + +! Here is the intended "subroutine" +1000 print *, "hello" + select case (label) + case (100); goto 100 + end select +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,20 @@ +! Test Case 23 1 ASSIGN Label, goto 2 different addresses, without the default case +! Test passes but does not include the default case in the two select case statements +program one_label_goto_two_different_addresses !<<<<< 1, 1, 20, 12, false, pass + + assign 100 to label + goto 1000 + +100 assign 200 to label + goto 2000 + +200 stop + +1000 print *, "First goto reaches here" + goto label + +2000 print *, "Second goto reaches here" + goto label + +3000 print *, "Fall-through" +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test23/one_label_goto_two_different_addresses_no_default.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,26 @@ +! Test Case 23 1 ASSIGN Label, goto 2 different addresses, without the default case +! Test passes but does not include the default case in the two select case statements +program one_label_goto_two_different_addresses !<<<<< 1, 1, 20, 12, false, pass + + label = 100 + goto 1000 + +100 label = 200 + goto 2000 + +200 stop + +1000 print *, "First goto reaches here" + select case (label) + case (100); goto 100 + case (200); goto 200 + end select + +2000 print *, "Second goto reaches here" + select case (label) + case (100); goto 100 + case (200); goto 200 + end select + +3000 print *, "Fall-through" +end program Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test24/one_goto_with_statement_label.f90 =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test24/one_goto_with_statement_label.f90 diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test24/one_goto_with_statement_label.f90 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test24/one_goto_with_statement_label.f90 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,17 @@ +! Test Case 24 with one of the assigned goto has a statement label. +! Test passes to include the statement label at the start of the select case section. +program one_goto_with_stmt_label !<<<<< 1, 1, 17, 31, true, pass +implicit none +integer labelinaction +integer anotherlabel + +assign 20 to labelinaction +goto labelinaction + +assign 30 to anotherlabel + +write (6, labelinaction) +20 format("6xTrying specify this line with label") + +30 goto anotherlabel +end program one_goto_with_stmt_label \ No newline at end of file Index: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test24/one_goto_with_statement_label.f90.result =================================================================== RCS file: src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test24/one_goto_with_statement_label.f90.result diff -N src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test24/one_goto_with_statement_label.f90.result --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/photran/internal/ui/refactoring/remove-assign-gotos/test24/one_goto_with_statement_label.f90.result 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,19 @@ +! Test Case 24 with one of the assigned goto has a statement label. +! Test passes to include the statement label at the start of the select case section. +program one_goto_with_stmt_label !<<<<< 1, 1, 17, 31, true, pass +implicit none +integer labelinaction +integer anotherlabel + +assign 20 to labelinaction +goto labelinaction + +anotherlabel = 30 + +write (6, labelinaction) +20 format("6xTrying specify this line with label") +30 select case (anotherlabel) + case (30); goto 30 + case default; stop "Unknown label" + end select +end program one_goto_with_stmt_label