|
From: <mir...@us...> - 2007-04-20 08:37:29
|
Revision: 2344
http://svn.sourceforge.net/rubyeclipse/?rev=2344&view=rev
Author: mirkostocker
Date: 2007-04-20 01:37:24 -0700 (Fri, 20 Apr 2007)
Log Message:
-----------
create the extract constant test-infrastructure
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractconstant/ExtractConstantConditionChecker.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/TS_All.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/conditionchecks/
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/conditionchecks/extract_constant_checker_test_1.source.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/conditionchecks/extract_constant_checker_test_1.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.result.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.source.rb
trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.test_properties
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/ExtractConstantTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/TS_ExtractConstant.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/conditionchecks/
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/conditionchecks/ExtractConstantConditionTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/conditionchecks/TS_ExtractConstantChecks.java
Modified: trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF 2007-04-19 23:54:02 UTC (rev 2343)
+++ trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF 2007-04-20 08:37:24 UTC (rev 2344)
@@ -12,6 +12,7 @@
org.rubypeople.rdt.refactoring.core,
org.rubypeople.rdt.refactoring.core.convertlocaltofield,
org.rubypeople.rdt.refactoring.core.encapsulatefield,
+ org.rubypeople.rdt.refactoring.core.extractconstant,
org.rubypeople.rdt.refactoring.core.extractmethod,
org.rubypeople.rdt.refactoring.core.formatsource,
org.rubypeople.rdt.refactoring.core.generateaccessors,
@@ -24,6 +25,7 @@
org.rubypeople.rdt.refactoring.core.movefield,
org.rubypeople.rdt.refactoring.core.movemethod,
org.rubypeople.rdt.refactoring.core.overridemethod,
+ org.rubypeople.rdt.refactoring.core.pullup,
org.rubypeople.rdt.refactoring.core.pushdown,
org.rubypeople.rdt.refactoring.core.rename,
org.rubypeople.rdt.refactoring.core.renameclass,
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractconstant/ExtractConstantConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractconstant/ExtractConstantConditionChecker.java 2007-04-19 23:54:02 UTC (rev 2343)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/extractconstant/ExtractConstantConditionChecker.java 2007-04-20 08:37:24 UTC (rev 2344)
@@ -26,8 +26,8 @@
private ExtractConstantConfig config;
- public ExtractConstantConditionChecker(ExtractConstantConfig config) {
- super(config);
+ public ExtractConstantConditionChecker(IRefactoringConfig config2) {
+ super(config2);
}
protected void checkInitialConditions() {
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/conditionchecks/extract_constant_checker_test_1.source.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/conditionchecks/extract_constant_checker_test_1.source.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/conditionchecks/extract_constant_checker_test_1.source.rb 2007-04-20 08:37:24 UTC (rev 2344)
@@ -0,0 +1,5 @@
+class Test
+ def method param
+ puts param
+ end
+end
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/conditionchecks/extract_constant_checker_test_1.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/conditionchecks/extract_constant_checker_test_1.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/conditionchecks/extract_constant_checker_test_1.test_properties 2007-04-20 08:37:24 UTC (rev 2344)
@@ -0,0 +1,4 @@
+start=39
+end=44
+name=Test
+initialError0=Extracting constant not possible on things other than strings, numbers, hashes or arrays.
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.result.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.result.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.result.rb 2007-04-20 08:37:24 UTC (rev 2344)
@@ -0,0 +1,2 @@
+Name = "Mirko"
+puts "Hello " + Name
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.source.rb
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.source.rb (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.source.rb 2007-04-20 08:37:24 UTC (rev 2344)
@@ -0,0 +1 @@
+puts "Hello " + "Mirko"
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.test_properties
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.test_properties (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/resources/core/extractconstant/extract_constant_test_1.test_properties 2007-04-20 08:37:24 UTC (rev 2344)
@@ -0,0 +1,3 @@
+start=18
+end=20
+name=Name
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/TS_All.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/TS_All.java 2007-04-19 23:54:02 UTC (rev 2343)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/TS_All.java 2007-04-20 08:37:24 UTC (rev 2344)
@@ -35,6 +35,7 @@
import org.rubypeople.rdt.refactoring.tests.core.TS_Core;
import org.rubypeople.rdt.refactoring.tests.core.convertlocaltofield.TS_LocalToField;
import org.rubypeople.rdt.refactoring.tests.core.encapsulatefield.TS_EncapsulateField;
+import org.rubypeople.rdt.refactoring.tests.core.extractconstant.TS_ExtractConstant;
import org.rubypeople.rdt.refactoring.tests.core.extractmethod.TS_ExtractMethod;
import org.rubypeople.rdt.refactoring.tests.core.formatsource.TS_FormatSource;
import org.rubypeople.rdt.refactoring.tests.core.generateaccessors.TS_GenerateAccessors;
@@ -75,6 +76,7 @@
suite.addTest(TS_LocalToField.suite());
suite.addTest(TS_Core.suite());
suite.addTest(TS_ExtractMethod.suite());
+ suite.addTest(TS_ExtractConstant.suite());
suite.addTest(TS_MergeWithExternalClassParts.suite());
suite.addTest(TS_MergeClassPartsInFile.suite());
suite.addTest(TS_InlineLocal.suite());
Added: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/ExtractConstantTester.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/ExtractConstantTester.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/ExtractConstantTester.java 2007-04-20 08:37:24 UTC (rev 2344)
@@ -0,0 +1,64 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2007 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.tests.core.extractconstant;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.rubypeople.rdt.refactoring.core.SelectionInformation;
+import org.rubypeople.rdt.refactoring.core.extractconstant.ConstantExtractor;
+import org.rubypeople.rdt.refactoring.core.extractconstant.ExtractConstantConditionChecker;
+import org.rubypeople.rdt.refactoring.core.extractconstant.ExtractConstantConfig;
+import org.rubypeople.rdt.refactoring.tests.FileTestCase;
+import org.rubypeople.rdt.refactoring.tests.FileTestData;
+
+public class ExtractConstantTester extends FileTestCase {
+
+ public ExtractConstantTester(String fileName) {
+ super(fileName);
+ }
+
+ @Override
+ public void runTest() throws FileNotFoundException, IOException, BadLocationException {
+
+ FileTestData testData = new FileTestData(getName(), ".source.rb", ".result.rb");
+
+ SelectionInformation selection = new SelectionInformation(testData.getIntProperty("start"), testData.getIntProperty("end"), "");
+
+ ExtractConstantConfig renameModuleConfig = new ExtractConstantConfig(testData, selection);
+ new ExtractConstantConditionChecker(renameModuleConfig);
+
+ renameModuleConfig.setConstantName(testData.getProperty("name"));
+
+ ConstantExtractor editProvider = new ConstantExtractor(renameModuleConfig);
+
+ createEditAndCompareResult(testData.getSource(), testData.getExpectedResult(), editProvider);
+ }
+}
Added: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/TS_ExtractConstant.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/TS_ExtractConstant.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/TS_ExtractConstant.java 2007-04-20 08:37:24 UTC (rev 2344)
@@ -0,0 +1,42 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2007 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.tests.core.extractconstant;
+
+import junit.framework.TestSuite;
+
+import org.rubypeople.rdt.refactoring.tests.FileTestSuite;
+import org.rubypeople.rdt.refactoring.tests.core.extractconstant.conditionchecks.TS_ExtractConstantChecks;
+
+public class TS_ExtractConstant extends FileTestSuite {
+ public static TestSuite suite() {
+ TestSuite suite = createSuite("Extract Constant", "extract_constant_test_*.source.rb", ExtractConstantTester.class);
+ suite.addTest(TS_ExtractConstantChecks.suite());
+ return suite;
+ }
+}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/conditionchecks/ExtractConstantConditionTester.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/conditionchecks/ExtractConstantConditionTester.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/conditionchecks/ExtractConstantConditionTester.java 2007-04-20 08:37:24 UTC (rev 2344)
@@ -0,0 +1,66 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2007 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.tests.core.extractconstant.conditionchecks;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import org.rubypeople.rdt.refactoring.core.SelectionInformation;
+import org.rubypeople.rdt.refactoring.core.extractconstant.ConstantExtractor;
+import org.rubypeople.rdt.refactoring.core.extractconstant.ExtractConstantConditionChecker;
+import org.rubypeople.rdt.refactoring.core.extractconstant.ExtractConstantConfig;
+import org.rubypeople.rdt.refactoring.tests.FilePropertyData;
+import org.rubypeople.rdt.refactoring.tests.FileTestData;
+import org.rubypeople.rdt.refactoring.tests.RefactoringConditionTestCase;
+
+public class ExtractConstantConditionTester extends RefactoringConditionTestCase {
+
+ private FilePropertyData testData;
+ private ExtractConstantConfig config;
+
+ public ExtractConstantConditionTester(String fileName) {
+ super(fileName);
+ }
+
+ @Override
+ public void runTest() throws FileNotFoundException, IOException {
+ testData = new FileTestData(getName(), ".source.rb", ".source.rb");
+
+ SelectionInformation selection = new SelectionInformation(testData.getIntProperty("start"), testData.getIntProperty("end"), "");
+ config = new ExtractConstantConfig(testData , selection);
+ ExtractConstantConditionChecker checker = new ExtractConstantConditionChecker(config);
+ checkConditions(checker, testData);
+ }
+
+ @Override
+ protected void createEditProviderAndSetUserInput() {
+ new ConstantExtractor(config);
+ config.setConstantName(testData.getProperty("name"));
+ }
+}
Added: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/conditionchecks/TS_ExtractConstantChecks.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/conditionchecks/TS_ExtractConstantChecks.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/extractconstant/conditionchecks/TS_ExtractConstantChecks.java 2007-04-20 08:37:24 UTC (rev 2344)
@@ -0,0 +1,41 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2007 Mirko Stocker <me...@mi...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.tests.core.extractconstant.conditionchecks;
+
+import junit.framework.Test;
+
+import org.rubypeople.rdt.refactoring.tests.FileTestSuite;
+
+public class TS_ExtractConstantChecks extends FileTestSuite {
+
+ public static Test suite() {
+ return createSuite("Extract Constant Conditionchecks", "extract_constant_checker_test_*.source.rb", ExtractConstantConditionTester.class);
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|