(abbrev-expansion "s-a-t" ert-save-test-table)))
(delete-file temp-test-file))))
+(ert-deftest inverse-add-abbrev-skips-trailing-nonword ()
+ "Test that adding an inverse abbrev skips trailing nonword characters."
+ (let ((table (make-abbrev-table)))
+ (with-temp-buffer
+ (insert "some text foo ")
+ (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "bar")))
+ (inverse-add-abbrev table "Global" 1)))
+ (should (string= (abbrev-expansion "foo" table) "bar"))))
+
+(ert-deftest inverse-add-abbrev-skips-trailing-nonword/postiive-arg ()
+ "Test that adding an inverse abbrev skips trailing nonword characters."
+ (let ((table (make-abbrev-table)))
+ (with-temp-buffer
+ (insert "some text foo ")
+ (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "bar")))
+ (inverse-add-abbrev table "Global" 2)))
+ (should (string= (abbrev-expansion "text" table) "bar"))))
+
+(ert-deftest inverse-add-abbrev-skips-trailing-nonword/negative-arg ()
+ "Test that adding an inverse abbrev skips trailing nonword characters."
+ (let ((table (make-abbrev-table)))
+ (with-temp-buffer
+ (insert "some text foo")
+ (goto-char (point-min))
+ (cl-letf (((symbol-function 'read-string) (lambda (&rest _) "bar")))
+ (inverse-add-abbrev table "Global" -1)))
+ (should (string= (abbrev-expansion "text" table) "bar"))))
+
(provide 'abbrev-tests)
;;; abbrev-tests.el ends here