* [patch] call execution tests
@ 2011-09-10 17:33 Martyn Jago
0 siblings, 0 replies; only message in thread
From: Martyn Jago @ 2011-09-10 17:33 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 246 bytes --]
Preliminary tests for inline call execution (focussing on results
placement).
Some of these tests are commented out highlighting unexpected placement
of results on execution.
I will take a look at the cause when I get a chance.
Best, Martyn
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Preliminary tests for inline call execution (focussing on results placement) --]
[-- Type: text/x-patch, Size: 7469 bytes --]
From e9815c0561347bf9b3d25dad7f9262b4348dfd12 Mon Sep 17 00:00:00 2001
From: Martyn Jago <martyn.jago@btinternet.com>
Date: Sat, 10 Sep 2011 18:26:46 +0100
Subject: [PATCH] Preliminary tests for inline call execution (focussing on results placement)
* testing/org-test.el: Added =org-test-get-before-after= for grabbing
before/after blocks for test in temp-buffer
* testing/examples/babel.org: Test data for inline calls
* testing/lisp/test-ob.el: Tests for inline calls
---
testing/examples/babel.org | 37 ++++++++++++++
testing/lisp/test-ob.el | 119 ++++++++++++++++++++++++++++++++++++++++++++
testing/org-test.el | 20 +++++++
3 files changed, 176 insertions(+), 0 deletions(-)
diff --git a/testing/examples/babel.org b/testing/examples/babel.org
index 5b7f2ef..2875043 100644
--- a/testing/examples/babel.org
+++ b/testing/examples/babel.org
@@ -289,3 +289,40 @@ src_sh{echo "One"} block at start of line
One spaced block in src_sh{ echo "middle" } of line
src_sh{echo 2} blocks on the src_emacs-lisp{"same"} line
Inline block with src_sh[:results silent]{ echo "parameters" }.
+* test-org-babel/inline-call-at-col-0
+ :PROPERTIES:
+ :ID: 698950ce-df69-4df3-90c3-b1230ba7d2fc
+ :END:
+** inline call starting at col 0 :before:
+call_test()
+
+#+source: test
+#+begin_src emacs-lisp
+1
+#+end_src
+** inline call starting at col 0 :after:
+call_test() =1=
+
+#+source: test
+#+begin_src emacs-lisp
+1
+#+end_src
+* test-org-babel/inline-call-at-col-1
+ :PROPERTIES:
+ :ID: D3A63F20-25AD-47F7-B6AE-983B4C82D55C
+ :END:
+** inline call starting at col 1 :before:
+ call_test()
+
+#+source: test
+#+begin_src emacs-lisp
+"2"
+#+end_src
+** inline call starting at col 1 :after:
+ call_test() =2=
+
+#+source: test
+#+begin_src emacs-lisp
+"2"
+#+end_src
+*
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index 1f04c5b..a78bf1e 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -408,6 +408,125 @@
(should (string= (concat test-line " =\"x\"=")
(buffer-substring-no-properties (point-min) (point-max)))))))
+(ert-deftest test-org-babel/inline-call-at-col-0 ()
+ (with-temp-buffer
+ (let ((data (org-test-get-before-after
+ "698950ce-df69-4df3-90c3-b1230ba7d2fc")))
+ (insert (car data))
+ (beginning-of-buffer)
+ ;; point at col 0
+ (save-excursion
+ (org-ctrl-c-ctrl-c)
+ (should (equal (cdr data)
+ (buffer-substring-no-properties (point-min) (point-max)))))
+ ;;TODO Broken (Generates a result block below the inline call)
+ ;; point at col 1
+ ;; (save-excursion
+ ;; (forward-char)
+ ;; (org-ctrl-c-ctrl-c)
+ ;; (should (equal (cdr data)
+ ;; (buffer-substring-no-properties (point-min) (point-max)))))
+ ;;
+
+ ;;TODO Broken (Generates a result block below the inline call)
+ ;; point on _
+ ;; (save-excursion
+ ;; (re-search-forward "test")
+ ;; (org-ctrl-c-ctrl-c)
+ ;; (should (equal (cdr data)
+ ;; (buffer-substring-no-properties (point-min) (point-max)))))
+
+ ;;TODO Broken (Generates a result block below the inline call)
+ ;; point on opening parenthesis
+ ;; (save-excursion
+ ;; (re-search-forward "test")
+ ;; (org-ctrl-c-ctrl-c)
+ ;; (should (equal (cdr data)
+ ;; (buffer-substring-no-properties (point-min) (point-max)))))
+
+ ;;TODO Broken (Generates a result block below the inline call)
+ ;; point on closing parenthesis
+ ;; (save-excursion
+ ;; (re-search-forward "(")
+ ;; (org-ctrl-c-ctrl-c)
+ ;; (should (equal (cdr data)
+ ;; (buffer-substring-no-properties (point-min) (point-max)))))
+
+ ;;TODO Broken (Generates a result block below the inline call)
+ ;; point immediately beyond inline call
+ ;; (save-excursion
+ ;; (re-search-forward ")")
+ ;; (should-error (org-ctrl-c-ctrl-c)))
+
+ ;;TODO Broken (Generates a result block below the inline call)
+ ;; point beyond inline call by a space
+ ;; (save-excursion
+ ;; (re-search-forward "() ")
+ ;; (org-ctrl-c-ctrl-c)
+ ;; (should (equal (cdr data)
+ ;; (buffer-substring-no-properties (point-min) (point-max)))))
+
+ )))
+
+(ert-deftest test-org-babel/inline-call-at-col-1 ()
+ (let ((data
+ (org-test-get-before-after
+ "D3A63F20-25AD-47F7-B6AE-983B4C82D55C")))
+
+ ;; point in front of inline call
+ (with-temp-buffer
+ (insert (car data))
+ (beginning-of-buffer)
+ (org-ctrl-c-ctrl-c)
+ (should (equal (cdr data)
+ (buffer-substring-no-properties (point-min) (point-max)))))
+
+ ;; point on first char of call
+ (with-temp-buffer
+ (insert (car data))
+ (re-search-backward "call")
+ (org-ctrl-c-ctrl-c)
+ (should (equal (cdr data)
+ (buffer-substring-no-properties (point-min) (point-max)))))
+
+ ;; point on underscore of call
+ (with-temp-buffer
+ (insert (car data))
+ (re-search-backward "_test")
+ (org-ctrl-c-ctrl-c)
+ (should (equal (cdr data)
+ (buffer-substring-no-properties (point-min) (point-max)))))
+
+ ;; point on closing parenthesis
+ (with-temp-buffer
+ (insert (car data))
+ (re-search-backward ")")
+ (org-ctrl-c-ctrl-c)
+ (should (equal (cdr data)
+ (buffer-substring-no-properties (point-min) (point-max)))))
+
+ ;;TODO Broken (Generates a result block below the inline call)
+ ;; point just beyond closing parenthesis
+ ;; (with-temp-buffer
+ ;; (insert (car data))
+ ;; (re-search-backward ")")
+ ;; (forward-char)
+ ;; (end-of-line)
+ ;; (org-ctrl-c-ctrl-c)
+ ;; (should (equal (cdr data)
+ ;; (buffer-substring-no-properties (point-min) (point-max)))))
+
+ ;;TODO Broken (Generates a result block below the inline call)
+ ;; point at end of call line
+ ;; (with-temp-buffer
+ ;; (insert (car data))
+ ;; (beginning-of-buffer)
+ ;; (end-of-line)
+ ;; (org-ctrl-c-ctrl-c)
+ ;; (should (equal (cdr data)
+ ;; (buffer-substring-no-properties (point-min) (point-max)))))
+ ))
+
(provide 'test-ob)
;;; test-ob ends here
diff --git a/testing/org-test.el b/testing/org-test.el
index a8b5b49..6e4058d 100644
--- a/testing/org-test.el
+++ b/testing/org-test.el
@@ -251,6 +251,26 @@ Load all test files first."
(org-test-load)
(ert "\\(org\\|ob\\)"))
+(defun org-test-get-before-after (id)
+ "Returns a cons containing before and after blocks (of text) to
+test in a temporary buffer.
+Each block should be in a seperate sub heading in the example org
+file. The argument ID is used in conjunction with =org-test-at-id
+to identify the test data"
+
+ (let ((temp) (before) (after))
+ (org-test-at-id id
+ (outline-next-visible-heading 1)
+ (forward-line)
+ (setq temp (point))
+ (org-end-of-subtree t t)
+ (setq before (buffer-substring-no-properties temp (point)))
+ (forward-line)
+ (setq temp (point))
+ (org-end-of-subtree t t)
+ (setq after (buffer-substring-no-properties temp (point)))
+ (setq temp (cons before after))) temp ))
+
(provide 'org-test)
;;; org-test.el ends here
--
1.7.3.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2011-09-10 17:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-10 17:33 [patch] call execution tests Martyn Jago
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).