浏览代码

Add tests for require-match and default non-nil

Ryan C. Thompson 9 年之前
父节点
当前提交
9438bb928b
共有 1 个文件被更改,包括 26 次插入3 次删除
  1. 26 3
      test/ido-ubiquitous-test.el

+ 26 - 3
test/ido-ubiquitous-test.el

@@ -312,6 +312,22 @@ See `should-with-tag'."
 
 (ert-deftest ido-cr+-require-match ()
   "Test whether require-match works."
+  ;; "C-j" should be allowed to return an empty string even if
+  ;; require-match is non-nil, as long as default is nil
+  (should
+   (string=
+    ""
+    (with-simulated-input "C-j"
+      (ido-completing-read+
+       "Prompt: "
+       '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
+  ;; "C-j" should NOT be allowed to return an empty string if
+  ;; require-match and default are both non-nil.
+  (should-error
+   (with-simulated-input "C-j"
+     (ido-completing-read+
+      "Prompt: "
+      '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t nil nil "yellow")))
   (should-error
    (with-simulated-input "b C-j C-j C-j"
      (ido-completing-read+
@@ -341,9 +357,16 @@ See `should-with-tag'."
       (ido-completing-read+
        "Prompt: "
        '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
-  ;; Finally, test for the expected wrong behavior without ido-cr+. If
-  ;; ido.el ever fixes this bug, it will cause this test to fail as a
-  ;; signal that the workaround can be phased out.
+  ;; Finally, a few tests for the expected wrong behavior without
+  ;; ido-cr+. If ido.el ever fixes this bug, it will cause this test
+  ;; to fail as a signal that the workaround can be phased out.
+  (should
+   (string=
+    ""
+    (with-simulated-input "C-j"
+      (ido-completing-read
+       "Prompt: "
+       '("bluebird" "blues" "bluegrass" "blueberry" "yellow ""green") nil t))))
   (should
    (string=
     "b"