1+ /*
2+ * Copyright (c) 2016 Patrick Scheibe
3+ * Permission is hereby granted, free of charge, to any person obtaining a copy
4+ * of this software and associated documentation files (the "Software"), to deal
5+ * in the Software without restriction, including without limitation the rights
6+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+ * copies of the Software, and to permit persons to whom the Software is
8+ * furnished to do so, subject to the following conditions:
9+ *
10+ * The above copyright notice and this permission notice shall be included in
11+ * all copies or substantial portions of the Software.
12+ *
13+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+ * THE SOFTWARE.
20+ */
21+
22+ package de .halirutan .mathematica .refactoring ;
23+
24+ import com .intellij .testFramework .fixtures .LightCodeInsightFixtureTestCase ;
25+ import de .halirutan .mathematica .filetypes .MathematicaFileType ;
26+
27+ /**
28+ * @author patrick (24.12.16).
29+ */
30+ public class RenameTest extends LightCodeInsightFixtureTestCase {
31+
32+ public void testNormalVariable () throws Exception {
33+ myFixture .configureByText (MathematicaFileType .INSTANCE ,
34+ "var1;\n " +
35+ "var1::usage = \" var1 is equal to nothing..\" ;\n " +
36+ "var1<caret>=1;" );
37+ myFixture .renameElementAtCaret ("var2" );
38+ myFixture .checkResult ("var2;\n " +
39+ "var2::usage = \" var2 is equal to nothing..\" ;\n " +
40+ "var2=1;" );
41+ }
42+
43+ public void testModule () throws Exception {
44+ myFixture .configureByText (MathematicaFileType .INSTANCE ,
45+ "var;\n " +
46+ "var::usage = \" var is equal to nothing..\" ;\n " +
47+ "var=1;\n " +
48+ "\n " +
49+ "Module[{var},\n " +
50+ " var + var<caret>\n " +
51+ " \n " +
52+ "]" );
53+ myFixture .renameElementAtCaret ("var2" );
54+ myFixture .checkResult ("var;\n " +
55+ "var::usage = \" var is equal to nothing..\" ;\n " +
56+ "var=1;\n " +
57+ "\n " +
58+ "Module[{var2},\n " +
59+ " var2 + var2\n " +
60+ " \n " +
61+ "]" );
62+ }
63+
64+ public void testUsage () throws Exception {
65+ myFixture .configureByText (MathematicaFileType .INSTANCE ,
66+ "func::usage = \" func<caret> is a function called like func[]\" ;" );
67+ myFixture .renameElementAtCaret ("newFunc" );
68+ myFixture .checkResult ("newFunc::usage = \" newFunc is a function called like newFunc[]\" ;" );
69+ }
70+
71+ // This test fails du to a bug in idea
72+ // @Test
73+ // public void testDollarVariables() throws Exception {
74+ // myFixture.configureByText(MathematicaFileType.INSTANCE,
75+ // "var$ = 1;\n" +
76+ // "var$<caret> + var$");
77+ // myFixture.renameElementAtCaret("$var$");
78+ // myFixture.checkResult("$var$ = 1;\n" +
79+ // "$var$ + $var$");
80+ // }
81+
82+ }
0 commit comments