Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Ratz2018-09-23 11:22:26 -0400
committerAndrey Loskutov2018-09-23 12:36:46 -0400
commit542f40e5776d928308fc6443fe6293463e2b5483 (patch)
tree211f3902148d42c72616b93cdc16325e8515a9c7 /org.eclipse.jface.text.tests
parentbb4abd131785dc66b2a4da321ded042fd4e37db1 (diff)
downloadeclipse.platform.text-542f40e5776d928308fc6443fe6293463e2b5483.tar.gz
eclipse.platform.text-542f40e5776d928308fc6443fe6293463e2b5483.tar.xz
eclipse.platform.text-542f40e5776d928308fc6443fe6293463e2b5483.zip
Bug 535964 - Move some non UI classes from jface.text to o.e.text.I20180923-1800
Another update to the #equals() implementation. bb4abd131785dc66b2a4da321ded042fd4e37db1 broke equals() in other scenarios. A = org.eclipse.text.templates.TemplatePersistenceData B = org.eclipse.jface.text.templates.persistence.TemplatePersistenceData Properly implement equals() in the super class (A) and in the deprecated subclass (B), such that the symmetric property of equals holds: A.equals(B) B.equals(A) This is ensured by always using B as a dummy and delegating via "ref". In the super type A introduce a new dummy UUID just for equals. This simulates the previous object identity semantics for equals (there can exist multiple *different* templates with identical values). Change-Id: Ia34e7019a54464b6f4d95521eddea8e682e87bf1 Signed-off-by: Sebastian Ratz <sebastian.ratz@sap.com>
Diffstat (limited to 'org.eclipse.jface.text.tests')
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/templates/persistence/TemplatePersistenceDataTest.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/templates/persistence/TemplatePersistenceDataTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/templates/persistence/TemplatePersistenceDataTest.java
index 07719d8c1..ff98b8038 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/templates/persistence/TemplatePersistenceDataTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/templates/persistence/TemplatePersistenceDataTest.java
@@ -28,19 +28,31 @@ public class TemplatePersistenceDataTest {
@Test
public void testEquals() throws Exception {
Template template= new Template();
+
org.eclipse.text.templates.TemplatePersistenceData persistenceData1= new org.eclipse.text.templates.TemplatePersistenceData(template, false);
org.eclipse.text.templates.TemplatePersistenceData persistenceData2= new org.eclipse.text.templates.TemplatePersistenceData(template, false);
- TemplatePersistenceData deprPersistenceDataWithRef1A= new TemplatePersistenceData(persistenceData1);
- TemplatePersistenceData deprPersistenceDataWithRef1B= new TemplatePersistenceData(persistenceData1);
-
- TemplatePersistenceData deprPersistenceDataWithRef2= new TemplatePersistenceData(persistenceData2);
-
+ TemplatePersistenceData deprPersistenceData1A= new TemplatePersistenceData(persistenceData1);
+ TemplatePersistenceData deprPersistenceData1B= new TemplatePersistenceData(persistenceData1);
+ TemplatePersistenceData deprPersistenceData1X= new TemplatePersistenceData(deprPersistenceData1A);
+ TemplatePersistenceData deprPersistenceData2= new TemplatePersistenceData(persistenceData2);
TemplatePersistenceData deprPersistenceData3= new TemplatePersistenceData(template, false);
- assertTrue(deprPersistenceDataWithRef1A.equals(deprPersistenceDataWithRef1B));
- assertFalse(deprPersistenceDataWithRef1A.equals(deprPersistenceDataWithRef2));
- assertFalse(deprPersistenceDataWithRef1A.equals(deprPersistenceData3));
+ // deprecated type <-> deprecated type
+ assertTrue(deprPersistenceData1A.equals(deprPersistenceData1B));
+ assertFalse(deprPersistenceData1A.equals(deprPersistenceData2));
+ assertFalse(deprPersistenceData1A.equals(deprPersistenceData3));
assertTrue(deprPersistenceData3.equals(deprPersistenceData3));
+ assertTrue(deprPersistenceData1X.equals(deprPersistenceData1A));
+
+ // super type <-> super type
+ assertTrue(persistenceData1.equals(persistenceData1));
+ assertFalse(persistenceData1.equals(persistenceData2));
+
+ // super type <-> deprecated type
+ assertTrue(persistenceData1.equals(deprPersistenceData1A));
+ assertTrue(deprPersistenceData1A.equals(persistenceData1));
+ assertFalse(persistenceData1.equals(deprPersistenceData2));
+ assertFalse(deprPersistenceData2.equals(persistenceData1));
}
}

Back to the top