Program: 87364
Project: 87364
Buggy source:
private void helpTestGetSuggestionSpansAtWord(final int cursorPos){
  final MockInputMethodService mockInputMethodService=new MockInputMethodService();
  final RichInputConnection ic=new RichInputConnection(mockInputMethodService);
  final String[] SUGGESTIONS1={"String_Node_Str","String_Node_Str"};
  final String[] SUGGESTIONS2={"String_Node_Str","String_Node_Str"};
  SpannableString text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),10,16,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  TextRange r;
  SuggestionSpan[] suggestions;
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,1);
  MoreAsserts.assertEquals(suggestions[0].getSuggestions(),SUGGESTIONS1);
  text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),10,16,0);
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS2,0),10,16,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,2);
  MoreAsserts.assertEquals(suggestions[0].getSuggestions(),SUGGESTIONS1);
  MoreAsserts.assertEquals(suggestions[1].getSuggestions(),SUGGESTIONS2);
  text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),10,16,0);
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS2,0),5,16,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,1);
  MoreAsserts.assertEquals(suggestions[0].getSuggestions(),SUGGESTIONS1);
  text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),10,16,0);
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS2,0),10,20,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,1);
  MoreAsserts.assertEquals(suggestions[0].getSuggestions(),SUGGESTIONS1);
  text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),10,16,0);
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS2,0),5,20,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,1);
  MoreAsserts.assertEquals(suggestions[0].getSuggestions(),SUGGESTIONS1);
  text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),5,16,0);
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS2,0),5,20,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,0);
}

Fixed version (ground truth):
private void helpTestGetSuggestionSpansAtWord(final int cursorPos){
  final SpacingAndPunctuations SPACE=new SpacingAndPunctuations(mSpacingAndPunctuations,new int[]{Constants.CODE_SPACE});
  final MockInputMethodService mockInputMethodService=new MockInputMethodService();
  final RichInputConnection ic=new RichInputConnection(mockInputMethodService);
  final String[] SUGGESTIONS1={"String_Node_Str","String_Node_Str"};
  final String[] SUGGESTIONS2={"String_Node_Str","String_Node_Str"};
  SpannableString text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),10,16,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  TextRange r;
  SuggestionSpan[] suggestions;
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,1);
  MoreAsserts.assertEquals(suggestions[0].getSuggestions(),SUGGESTIONS1);
  text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),10,16,0);
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS2,0),10,16,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,2);
  MoreAsserts.assertEquals(suggestions[0].getSuggestions(),SUGGESTIONS1);
  MoreAsserts.assertEquals(suggestions[1].getSuggestions(),SUGGESTIONS2);
  text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),10,16,0);
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS2,0),5,16,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,1);
  MoreAsserts.assertEquals(suggestions[0].getSuggestions(),SUGGESTIONS1);
  text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),10,16,0);
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS2,0),10,20,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,1);
  MoreAsserts.assertEquals(suggestions[0].getSuggestions(),SUGGESTIONS1);
  text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),10,16,0);
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS2,0),5,20,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,1);
  MoreAsserts.assertEquals(suggestions[0].getSuggestions(),SUGGESTIONS1);
  text=new SpannableString("String_Node_Str");
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS1,0),5,16,0);
  text.setSpan(new SuggestionSpan(Locale.ENGLISH,SUGGESTIONS2,0),5,20,0);
  mockInputMethodService.setInputConnection(new MockConnection(text,cursorPos));
  r=ic.getWordRangeAtCursor(SPACE,ScriptUtils.SCRIPT_LATIN);
  suggestions=r.getSuggestionSpansAtWord();
  assertEquals(suggestions.length,0);
}