Tests: (src) Implement
This commit is contained in:
parent
68ac6ddd28
commit
d784f8f71c
3 changed files with 69 additions and 3 deletions
|
|
@ -563,6 +563,7 @@ Simple links may also be written manually in either sexp or non-sexp form, like:
|
|||
*Internal*
|
||||
+ Certain query predicates, when called multiple times in an ~and~ sub-expression, are optimized to a single call.
|
||||
+ Use ~buffer-chars-modified-tick~ instead of ~buffer-modified-tick~. (Thanks to [[https://github.com/yantar92][Ihor Radchenko]].)
|
||||
+ Implemented tests for ~src~ predicate.
|
||||
|
||||
*Credits*
|
||||
+ Thanks to [[https://github.com/chasecaleb][Caleb Chase]] for help with [[https://github.com/alphapapa/org-ql/pull/285][#285]], fixed in [[https://github.com/alphapapa/org-ql/commit/91908186fcca4b5fd2e9d26da5bc0375c2b41acf][9190818]].
|
||||
|
|
|
|||
29
tests/data-src.org
Normal file
29
tests/data-src.org
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#+title: org-ql test data for ~src~ predicate
|
||||
|
||||
* Alpha
|
||||
|
||||
#+begin_src elisp
|
||||
(message "foo")
|
||||
#+end_src
|
||||
|
||||
#+begin_src python
|
||||
print("foo")
|
||||
#+end_src
|
||||
|
||||
#+begin_src js
|
||||
console.log("foo")
|
||||
#+end_src
|
||||
|
||||
* Bravo
|
||||
|
||||
#+begin_src elisp
|
||||
(message "bar")
|
||||
#+end_src
|
||||
|
||||
#+begin_src python
|
||||
print("bar")
|
||||
#+end_src
|
||||
|
||||
* Charlie
|
||||
|
||||
This entry has no source block.
|
||||
|
|
@ -1367,9 +1367,45 @@ with keyword arg NOW in PLIST."
|
|||
(org-ql-expect ('(scheduled :on 0))
|
||||
'("Practice leaping tall buildings in a single bound" "Order a pizza" "Get haircut" "Fix flux capacitor" "Shop for groceries" "Rewrite Emacs in Common Lisp")))))
|
||||
|
||||
;; ;; TODO: Test (src) predicate. That will require modifying test data, which will be a
|
||||
;; ;; significant hassle. Manual testing shows that the predicate appears to work properly.
|
||||
;;
|
||||
(describe "(src)"
|
||||
(before-each
|
||||
;; It would seem preferable to use :var for this, but this seems more reliable.
|
||||
(setq org-ql-test-buffer (org-ql-test-data-buffer "data-src.org")))
|
||||
|
||||
(org-ql-it "without arguments"
|
||||
(org-ql-expect ('(src))
|
||||
'("Alpha" "Bravo")))
|
||||
|
||||
(org-ql-it "with plain argument"
|
||||
;; Finds in first source block in entry.
|
||||
(org-ql-expect ('(src "foo"))
|
||||
'("Alpha"))
|
||||
(org-ql-expect ('(src "bar"))
|
||||
'("Bravo"))
|
||||
(org-ql-expect ('(src "print"))
|
||||
;; Finds in subsequent source block in entry.
|
||||
'("Alpha" "Bravo")))
|
||||
|
||||
(org-ql-it "with :regexps argument"
|
||||
(org-ql-expect ('(src :regexps ("foo")))
|
||||
'("Alpha"))
|
||||
(org-ql-expect ('(src :regexps ("bar")))
|
||||
'("Bravo"))
|
||||
(org-ql-expect ('(src :regexps ("print" "foo")))
|
||||
'("Alpha"))
|
||||
(org-ql-expect ('(src :regexps ("foo" "bar")))
|
||||
nil))
|
||||
|
||||
(org-ql-it "with :lang argument"
|
||||
;; Finds in first source block in entry.
|
||||
(org-ql-expect ('(src :lang "elisp"))
|
||||
'("Alpha" "Bravo"))
|
||||
;; Finds in subsequent source block in entry.
|
||||
(org-ql-expect ('(src :lang "python"))
|
||||
'("Alpha" "Bravo"))
|
||||
(org-ql-expect ('(src :lang "js"))
|
||||
'("Alpha"))))
|
||||
|
||||
(describe "(todo)"
|
||||
|
||||
(org-ql-it "without arguments"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue