Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 7406 Details for
Bug 37643
[quick assist] convert == to equals() and vice versa
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
tests
37643tests.txt (text/plain), 11.35 KB, created by
Sebastian Davids
on 2004-01-12 05:00:36 EST
(
hide
)
Description:
tests
Filename:
MIME Type:
Creator:
Sebastian Davids
Created:
2004-01-12 05:00:36 EST
Size:
11.35 KB
patch
obsolete
>Index: AssistQuickFixTest.java >=================================================================== >retrieving revision 1.28 >diff -u -r1.28 AssistQuickFixTest.java >--- AssistQuickFixTest.java 8 Jan 2004 15:14:50 -0000 1.28 >+++ AssistQuickFixTest.java 12 Jan 2004 09:54:56 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Sebastian Davids <sdavids@gmx.de> - testChangeEqualsToSame, testChangeSameToEquals > *******************************************************************************/ > package org.eclipse.jdt.ui.tests.quickfix; > >@@ -1333,4 +1334,240 @@ > assertEqualString(preview, buf.toString()); > } > >+ public void testChangeEqualsToSame() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= \"a\".equals(\"b\");\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ String str= "equals"; >+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); >+ List proposals= collectAssists(context, false); >+ >+ assertNumberOf("proposals", proposals.size(), 2); >+ assertCorrectLabels(proposals); >+ >+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(1); >+ String preview= proposal.getCompilationUnitChange().getPreviewContent(); >+ >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= \"a\" == \"b\";\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testChangeEqualsToSame2() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= equals(null);\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ String str= "equals"; >+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); >+ List proposals= collectAssists(context, false); >+ >+ assertNumberOf("proposals", proposals.size(), 1); >+ assertCorrectLabels(proposals); >+ >+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); >+ String preview= proposal.getCompilationUnitChange().getPreviewContent(); >+ >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= this == null;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testChangeEqualsToSame3() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" boolean equals(Object o, boolean a) {\n"); >+ buf.append(" return false;\n"); >+ buf.append(" }\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= new E().equals(\"a\", false);\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ String str= "equals"; >+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); >+ List proposals= collectAssists(context, false); >+ >+ assertNumberOf("proposals", proposals.size(), 0); >+ assertCorrectLabels(proposals); >+ >+ context= getCorrectionContext(cu, buf.toString().lastIndexOf(str), 0); >+ proposals= collectAssists(context, false); >+ >+ assertNumberOf("proposals", proposals.size(), 0); >+ assertCorrectLabels(proposals); >+ } >+ >+ public void testChangeEqualsToSame4() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" boolean equals(boolean b) {\n"); >+ buf.append(" return false;\n"); >+ buf.append(" }\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= new E().equals(false);\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ String str= "equals"; >+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); >+ List proposals= collectAssists(context, false); >+ >+ assertNumberOf("proposals", proposals.size(), 0); >+ assertCorrectLabels(proposals); >+ >+ context= getCorrectionContext(cu, buf.toString().lastIndexOf(str), 0); >+ proposals= collectAssists(context, false); >+ >+ assertNumberOf("proposals", proposals.size(), 0); >+ assertCorrectLabels(proposals); >+ } >+ >+ public void testChangeEqualsToSame5() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= new E().equals(\"a\");\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ String str= "equals"; >+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); >+ List proposals= collectAssists(context, false); >+ >+ assertNumberOf("proposals", proposals.size(), 1); >+ assertCorrectLabels(proposals); >+ } >+ >+ public void testChangeSameToEquals() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= \"a\" == \"b\";\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ String str= "=="; >+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); >+ List proposals= collectAssists(context, false); >+ >+ assertNumberOf("proposals", proposals.size(), 2); >+ assertCorrectLabels(proposals); >+ >+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(1); >+ String preview= proposal.getCompilationUnitChange().getPreviewContent(); >+ >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= \"a\".equals(\"b\");\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testChangeSameToEquals2() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= this == null;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ String str= "=="; >+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); >+ List proposals= collectAssists(context, false); >+ >+ assertNumberOf("proposals", proposals.size(), 2); >+ assertCorrectLabels(proposals); >+ >+ CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(1); >+ String preview= proposal.getCompilationUnitChange().getPreviewContent(); >+ >+ buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= equals(null);\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ assertEqualString(preview, buf.toString()); >+ } >+ >+ public void testChangeSameToEquals3() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= 1 == 2;\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ String str= "=="; >+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); >+ List proposals= collectAssists(context, false); >+ >+ assertNumberOf("proposals", proposals.size(), 1); >+ assertCorrectLabels(proposals); >+ } >+ >+ public void testChangeSameToEquals4() throws Exception { >+ IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); >+ StringBuffer buf= new StringBuffer(); >+ buf.append("package test1;\n"); >+ buf.append("public class E {\n"); >+ buf.append(" public void foo() {\n"); >+ buf.append(" boolean b= null == \"a\";\n"); >+ buf.append(" }\n"); >+ buf.append("}\n"); >+ ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); >+ >+ String str= "=="; >+ AssistContext context= getCorrectionContext(cu, buf.toString().indexOf(str), 0); >+ List proposals= collectAssists(context, false); >+ >+ assertNumberOf("proposals", proposals.size(), 1); >+ assertCorrectLabels(proposals); >+ } > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Flags:
daniel_megert
:
review-
Actions:
View
|
Diff
Attachments on
bug 37643
:
7404
|
7405
|
7406