@@ -671,6 +671,53 @@ public void readXMLAddDepBrokenAnnotation() {
671
671
}
672
672
}
673
673
674
+ @ Test
675
+ public void checkAnnotationConversionErrors () {
676
+ Ssurgeon inst = Ssurgeon .inst ();
677
+
678
+ // this should exist, but a string will not produce it
679
+ assertNotNull (AnnotationLookup .toCoreKey ("SPAN" ));
680
+
681
+ // This will fail because IntPair cannot be converted from a String
682
+ String add = String .join (newline ,
683
+ "<ssurgeon-pattern-list>" ,
684
+ " <ssurgeon-pattern>" ,
685
+ " <uid>38</uid>" ,
686
+ " <notes>Remove all incoming edges for a node</notes>" ,
687
+ // have to bomb-proof the pattern
688
+ " <semgrex>" + XMLUtils .escapeXML ("{word:antennae}=antennae !> {word:blue}" ) + "</semgrex>" ,
689
+ " <edit-list>addDep -gov antennae -reln dep -SPAN blue</edit-list>" ,
690
+ " </ssurgeon-pattern>" ,
691
+ "</ssurgeon-pattern-list>" );
692
+
693
+ try {
694
+ List <SsurgeonPattern > patterns = inst .readFromString (add );
695
+ throw new AssertionError ("Expected a failure because IntPair is not readable from a String in CoreLabel" );
696
+ } catch (SsurgeonParseException e ) {
697
+ // yay
698
+ }
699
+
700
+ assertNotNull (AnnotationLookup .toCoreKey ("headidx" ));
701
+ // This will also fail, this time because Integer cannot be converted from a String
702
+ add = String .join (newline ,
703
+ "<ssurgeon-pattern-list>" ,
704
+ " <ssurgeon-pattern>" ,
705
+ " <uid>38</uid>" ,
706
+ " <notes>Remove all incoming edges for a node</notes>" ,
707
+ // have to bomb-proof the pattern
708
+ " <semgrex>" + XMLUtils .escapeXML ("{word:antennae}=antennae !> {word:blue}" ) + "</semgrex>" ,
709
+ " <edit-list>addDep -gov antennae -reln dep -headidx blue</edit-list>" ,
710
+ " </ssurgeon-pattern>" ,
711
+ "</ssurgeon-pattern-list>" );
712
+
713
+ try {
714
+ List <SsurgeonPattern > patterns = inst .readFromString (add );
715
+ throw new AssertionError ("Expected a failure because IntPair is not readable from a String in CoreLabel" );
716
+ } catch (SsurgeonParseException e ) {
717
+ // yay
718
+ }
719
+ }
720
+
674
721
/**
675
722
* Simple test of an Ssurgeon edit script. This instances a simple semantic graph,
676
723
* a semgrex pattern, and then the resulting actions over the named nodes in the
0 commit comments