@@ -228,6 +228,33 @@ public void readXMLRelabelEdgeIterate() {
228
228
assertEquals (newSg , expected );
229
229
}
230
230
231
+ /**
232
+ * Test that the relabel named edge operation is bomb-proof.
233
+ * The initial version would relabel an edge to the new edge name
234
+ * even if the existing edge had the same name
235
+ */
236
+ @ Test
237
+ public void readXMLRelabelEdgeBombProof () {
238
+ String doc = String .join (newline ,
239
+ "<ssurgeon-pattern-list>" ,
240
+ " <ssurgeon-pattern>" ,
241
+ " <uid>38</uid>" ,
242
+ " <notes>This is a simple test of RelabelNamedEdge</notes>" ,
243
+ " <semgrex>" + XMLUtils .escapeXML ("{}=a1 >=foo {}=a2" ) + "</semgrex>" ,
244
+ " <edit-list>relabelNamedEdge -edge foo -reln dep</edit-list>" ,
245
+ " </ssurgeon-pattern>" ,
246
+ "</ssurgeon-pattern-list>" );
247
+ Ssurgeon inst = Ssurgeon .inst ();
248
+ List <SsurgeonPattern > patterns = inst .readFromString (doc );
249
+ assertEquals (patterns .size (), 1 );
250
+ SsurgeonPattern pattern = patterns .get (0 );
251
+
252
+ // check a simple case of relabeling
253
+ SemanticGraph sg = SemanticGraph .valueOf ("[A-0 obj> B-1]" );
254
+ SemanticGraph expected = SemanticGraph .valueOf ("[A-0 dep> B-1]" );
255
+ SemanticGraph newSg = pattern .iterate (sg );
256
+ assertEquals (newSg , expected );
257
+ }
231
258
232
259
/**
233
260
* Test that the RelabelNamedEdge operation updates the name of the edge in the SemgrexMatcher
0 commit comments