summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <eric.schulte@gmx.com>2012-01-06 00:32:30 -0700
committerEric Schulte <eric.schulte@gmx.com>2012-01-06 00:32:30 -0700
commit4db4fe84a8c435d62c917578bb90cfd77fa4f5b1 (patch)
treecd5815c963bdda454237eacd557a8ed3f166ff6a
parent08bad014c74e1402035a719e143542a0d1f8f5f1 (diff)
parentd270cfcf74b557522711922873efcfa9587523f0 (diff)
downloadorg-mode-4db4fe84a8c435d62c917578bb90cfd77fa4f5b1.tar.gz
Merge branch 'origin-maint'
-rw-r--r--lisp/ob-emacs-lisp.el14
-rw-r--r--testing/lisp/test-ob-emacs-lisp.el82
-rw-r--r--testing/lisp/test-ob.el2
3 files changed, 90 insertions, 8 deletions
diff --git a/lisp/ob-emacs-lisp.el b/lisp/ob-emacs-lisp.el
index afbc20d..c8af606 100644
--- a/lisp/ob-emacs-lisp.el
+++ b/lisp/ob-emacs-lisp.el
@@ -41,13 +41,13 @@
(result-params (cdr (assoc :result-params params)))
(print-level nil) (print-length nil)
(body (if (> (length vars) 0)
- (concat "(let ("
- (mapconcat
- (lambda (var)
- (format "%S" (print `(,(car var) ',(cdr var)))))
- vars "\n ")
- ")\n" body ")")
- body)))
+ (concat "(let ("
+ (mapconcat
+ (lambda (var)
+ (format "%S" (print `(,(car var) ',(cdr var)))))
+ vars "\n ")
+ ")\n" body "\n)")
+ (concat body "\n"))))
(if (or (member "code" result-params)
(member "pp" result-params))
(concat "(pp " body ")") body)))
diff --git a/testing/lisp/test-ob-emacs-lisp.el b/testing/lisp/test-ob-emacs-lisp.el
new file mode 100644
index 0000000..a83e8e9
--- /dev/null
+++ b/testing/lisp/test-ob-emacs-lisp.el
@@ -0,0 +1,82 @@
+;;; test-ob-emacs-lisp.el
+
+;; Copyright (c) 2012 Free Software Foundation, Inc.
+;; Authors: Eric Schulte, Martyn Jago
+
+;; Released under the GNU General Public License version 3
+;; see: http://www.gnu.org/licenses/gpl-3.0.html
+
+;;;; Comments:
+
+;; Org-mode tests for ob-emacs-lisp.el live here
+
+
+;;; Code:
+
+(let ((load-path (cons (expand-file-name
+ ".." (file-name-directory
+ (or load-file-name buffer-file-name)))
+ load-path)))
+ (require 'org-test)
+ (require 'org-test-ob-consts))
+
+
+;;; Tests
+
+(ert-deftest ob-emacs-lisp/commented-last-block-line-no-var ()
+ (org-test-with-temp-text-in-file "
+#+begin_src emacs-lisp
+;;
+#+end_src"
+ (progn
+ (org-babel-next-src-block)
+ (org-ctrl-c-ctrl-c)
+ (should (re-search-forward "results:" nil t))
+ (forward-line)
+ (should
+ (string=
+ ""
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
+ (org-test-with-temp-text-in-file "
+#+begin_src emacs-lisp
+\"some text\";;
+#+end_src"
+
+ (progn
+ (org-babel-next-src-block)
+ (org-ctrl-c-ctrl-c)
+ (should (re-search-forward "results:" nil t))
+ (forward-line)
+ (should
+ (string=
+ ": some text"
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))))
+
+(ert-deftest ob-emacs-lisp/commented-last-block-line-with-var ()
+ (org-test-with-temp-text-in-file "
+#+begin_src emacs-lisp :var a=1
+;;
+#+end_src"
+ (progn
+ (org-babel-next-src-block)
+ (org-ctrl-c-ctrl-c)
+ (re-search-forward "results" nil t)
+ (forward-line)
+ (should (string=
+ ""
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol))))))
+ (org-test-with-temp-text-in-file "
+#+begin_src emacs-lisp :var a=2
+2;;
+#+end_src"
+ (progn
+ (org-babel-next-src-block)
+ (org-ctrl-c-ctrl-c)
+ (re-search-forward "results" nil t)
+ (forward-line)
+ (should (string=
+ ": 2"
+ (buffer-substring-no-properties (point-at-bol) (point-at-eol)))))))
+(provide 'test-ob-emacs-lisp)
+
+ ;;; test-ob-emacs-lisp.el ends here
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index 5f42dbb..dac6866 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -247,7 +247,7 @@ this is simple"
(let ((test-point (point)))
(should (fboundp 'org-babel-get-inline-src-block-matches))
(should (re-search-forward "src_" nil t)) ;; 1
- (should (= (+ test-point 140) (match-end 0)))
+ (should (= (+ test-point 138) (match-end 0)))
(should (org-babel-get-inline-src-block-matches))
(should (re-search-forward "}" nil (point-at-bol))) ;; 1
(should-not (org-babel-get-inline-src-block-matches))