* [babel] Export problem (Wrong type argument: consp, nil)
@ 2011-09-08 15:15 Sebastien Vauban
2011-09-08 17:33 ` Eric Schulte
0 siblings, 1 reply; 8+ messages in thread
From: Sebastien Vauban @ 2011-09-08 15:15 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi,
#+TITLE: Export problem
#+AUTHOR: Seb Vauban
#+DATE: 2011-09-08
#+LANGUAGE: en
* Works OK
#+source: square(x=6)
#+begin_src python
return x*x
#+end_src
* Does not work
If there is no value assigned to the code block...
#+source: circle(x)
#+begin_src python
return x*x
#+end_src
... there is no an error when exporting:
#+begin_src text
Debugger entered--Lisp error: (wrong-type-argument consp nil)
setcdr(nil "nil=x")
(setf (cddr (nth variable-index vars)) (concat (symbol-name ...) "=" (cdr pair)))
(prog1 (setf (cddr ...) (concat ... "=" ...)) (incf variable-index))
(if name (setq vars (append ... ...)) (prog1 (setf ... ...) (incf variable-index)))
(let ((name ...)) (if name (setq vars ...) (prog1 ... ...)))
(cond ((eql ... ...) (let ... ...)) ((eql ... ...) (setq results ...)) ((eql ... ...) (when ... ... ... ...)) ((eql ... ...) (setq exports ...)) ((eql ... ...) (setq tangle ...)) ((eql ... ...) (setq noweb ...)) ((eql ... ...) (setq cache ...)) ((eql ... ...) (setq padline ...)) ((eql ... ...) (setq shebang ...)) ((eql ... ...) (setq comments ...)) (t (setq params ...)))
(case (car pair) (:var (let ... ...)) (:results (setq results ...)) (:file (when ... ... ... ...)) (:exports (setq exports ...)) (:tangle (setq tangle ...)) (:noweb (setq noweb ...)) (:cache (setq cache ...)) (:padline (setq padline ...)) (:shebang (setq shebang ...)) (:comments (setq comments ...)) (t (setq params ...)))
(lambda (pair) (case (car pair) (:var ...) (:results ...) (:file ...) (:exports ...) (:tangle ...) (:noweb ...) (:cache ...) (:padline ...) (:shebang ...) (:comments ...) (t ...)))((:var . "x"))
mapc((lambda (pair) (case (car pair) (:var ...) (:results ...) (:file ...) (:exports ...) (:tangle ...) (:noweb ...) (:cache ...) (:padline ...) (:shebang ...) (:comments ...) (t ...))) ((:var . "x")))
(lambda (plist) (mapc (lambda ... ...) plist))(((:var . "x")))
mapc((lambda (plist) (mapc (lambda ... ...) plist)) (((:var . "x")) ((:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:padnewline . "yes") (:hlines . "no") (:session . "none"))))
(progn (fset (quote e-merge) (function* ...)) (mapc (lambda ... ...) plists))
(unwind-protect (progn (fset ... ...) (mapc ... plists)) (if --cl-letf-bound-- (fset ... --cl-letf-save--) (fmakunbound ...)))
(let* ((--cl-letf-bound-- ...) (--cl-letf-save-- ...)) (unwind-protect (progn ... ...) (if --cl-letf-bound-- ... ...)))
(letf ((... ...)) (mapc (lambda ... ...) plists))
(letf* ((... ...)) (mapc (lambda ... ...) plists))
(flet ((e-merge ... ...)) (mapc (lambda ... ...) plists))
(let ((results-exclusive-groups ...) (exports-exclusive-groups ...) (variable-index 0) params results exports tangle noweb cache vars shebang comments padline) (flet (...) (mapc ... plists)) (setq vars (reverse vars)) (while vars (setq params ...)) (mapc (lambda ... ...) (quote ...)) params)
org-babel-merge-params(((:var . "x")) ((:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:padnewline . "yes") (:hlines . "no") (:session . "none")))
(setcar (nthcdr 2 info) (org-babel-merge-params (mapcar ... ...) (nth 2 info)))
(setf (nth 2 info) (org-babel-merge-params (mapcar ... ...) (nth 2 info)))
(progn (setf (nth 2 info) (org-babel-merge-params ... ...)))
(if (match-string 6) (progn (setf ... ...)))
(when (match-string 6) (setf (nth 2 info) (org-babel-merge-params ... ...)))
(progn (setq name (org-babel-clean-text-properties ...)) (when (match-string 6) (setf ... ...)))
#+end_src
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [babel] Export problem (Wrong type argument: consp, nil)
2011-09-08 15:15 [babel] Export problem (Wrong type argument: consp, nil) Sebastien Vauban
@ 2011-09-08 17:33 ` Eric Schulte
2011-09-14 8:52 ` Sebastien Vauban
0 siblings, 1 reply; 8+ messages in thread
From: Eric Schulte @ 2011-09-08 17:33 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: emacs-orgmode
Hi Seb,
All variables must be given a default value, which is why it is an error
to write a code block like the following.
#+source: circle(x)
#+begin_src python
return x*x
#+end_src
I've just pushed up a change which provides a better error message in
this case.
Best -- Eric
"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:
> Hi,
>
> #+TITLE: Export problem
> #+AUTHOR: Seb Vauban
> #+DATE: 2011-09-08
> #+LANGUAGE: en
>
> * Works OK
>
> #+source: square(x=6)
> #+begin_src python
> return x*x
> #+end_src
>
> * Does not work
>
> If there is no value assigned to the code block...
>
> #+source: circle(x)
> #+begin_src python
> return x*x
> #+end_src
>
> ... there is no an error when exporting:
>
> #+begin_src text
> Debugger entered--Lisp error: (wrong-type-argument consp nil)
> setcdr(nil "nil=x")
> (setf (cddr (nth variable-index vars)) (concat (symbol-name ...) "=" (cdr pair)))
> (prog1 (setf (cddr ...) (concat ... "=" ...)) (incf variable-index))
> (if name (setq vars (append ... ...)) (prog1 (setf ... ...) (incf variable-index)))
> (let ((name ...)) (if name (setq vars ...) (prog1 ... ...)))
> (cond ((eql ... ...) (let ... ...)) ((eql ... ...) (setq results ...)) ((eql ... ...) (when ... ... ... ...)) ((eql ... ...) (setq exports ...)) ((eql ... ...) (setq tangle ...)) ((eql ... ...) (setq noweb ...)) ((eql ... ...) (setq cache ...)) ((eql ... ...) (setq padline ...)) ((eql ... ...) (setq shebang ...)) ((eql ... ...) (setq comments ...)) (t (setq params ...)))
> (case (car pair) (:var (let ... ...)) (:results (setq results ...)) (:file (when ... ... ... ...)) (:exports (setq exports ...)) (:tangle (setq tangle ...)) (:noweb (setq noweb ...)) (:cache (setq cache ...)) (:padline (setq padline ...)) (:shebang (setq shebang ...)) (:comments (setq comments ...)) (t (setq params ...)))
> (lambda (pair) (case (car pair) (:var ...) (:results ...) (:file ...) (:exports ...) (:tangle ...) (:noweb ...) (:cache ...) (:padline ...) (:shebang ...) (:comments ...) (t ...)))((:var . "x"))
> mapc((lambda (pair) (case (car pair) (:var ...) (:results ...) (:file ...) (:exports ...) (:tangle ...) (:noweb ...) (:cache ...) (:padline ...) (:shebang ...) (:comments ...) (t ...))) ((:var . "x")))
> (lambda (plist) (mapc (lambda ... ...) plist))(((:var . "x")))
> mapc((lambda (plist) (mapc (lambda ... ...) plist)) (((:var . "x")) ((:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:padnewline . "yes") (:hlines . "no") (:session . "none"))))
> (progn (fset (quote e-merge) (function* ...)) (mapc (lambda ... ...) plists))
> (unwind-protect (progn (fset ... ...) (mapc ... plists)) (if --cl-letf-bound-- (fset ... --cl-letf-save--) (fmakunbound ...)))
> (let* ((--cl-letf-bound-- ...) (--cl-letf-save-- ...)) (unwind-protect (progn ... ...) (if --cl-letf-bound-- ... ...)))
> (letf ((... ...)) (mapc (lambda ... ...) plists))
> (letf* ((... ...)) (mapc (lambda ... ...) plists))
> (flet ((e-merge ... ...)) (mapc (lambda ... ...) plists))
> (let ((results-exclusive-groups ...) (exports-exclusive-groups ...) (variable-index 0) params results exports tangle noweb cache vars shebang comments padline) (flet (...) (mapc ... plists)) (setq vars (reverse vars)) (while vars (setq params ...)) (mapc (lambda ... ...) (quote ...)) params)
> org-babel-merge-params(((:var . "x")) ((:comments . "") (:shebang . "") (:cache . "no") (:padline . "") (:noweb . "no") (:tangle . "no") (:exports . "code") (:results . "replace") (:padnewline . "yes") (:hlines . "no") (:session . "none")))
> (setcar (nthcdr 2 info) (org-babel-merge-params (mapcar ... ...) (nth 2 info)))
> (setf (nth 2 info) (org-babel-merge-params (mapcar ... ...) (nth 2 info)))
> (progn (setf (nth 2 info) (org-babel-merge-params ... ...)))
> (if (match-string 6) (progn (setf ... ...)))
> (when (match-string 6) (setf (nth 2 info) (org-babel-merge-params ... ...)))
> (progn (setq name (org-babel-clean-text-properties ...)) (when (match-string 6) (setf ... ...)))
> #+end_src
>
> Best regards,
> Seb
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [babel] Export problem (Wrong type argument: consp, nil)
2011-09-08 17:33 ` Eric Schulte
@ 2011-09-14 8:52 ` Sebastien Vauban
2011-09-14 11:44 ` Martyn Jago
2011-09-15 15:10 ` Eric Schulte
0 siblings, 2 replies; 8+ messages in thread
From: Sebastien Vauban @ 2011-09-14 8:52 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Eric,
Eric Schulte wrote:
> "Sebastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org> writes:
>> If there is no value assigned to the code block...
>> ... there is no an error when exporting:
>>
>> #+begin_src text
>> Debugger entered--Lisp error: (wrong-type-argument consp nil)
>> setcdr(nil "nil=x")
>> #+end_src
>
> All variables must be given a default value, which is why it is an error
> to write a code block like the following.
>
> #+source: circle(x)
> #+begin_src python
> return x*x
> #+end_src
>
> I've just pushed up a change which provides a better error message in
> this case.
It works OK. Thanks a lot for that.
Remark: This did correct a problem that I had with my local LOB, and which
appeared a couple of months ago. I tried to find the post back, but I
couldn't. At that time, you tried my example, but you couldn't reproduce it.
Anyway, I now could check that it was because of this, now that the message is
a lot clearer than "consp, nil".
Question: Would it be possible to add the src-name in the error message? You
know, in my LOB, I have so many times the same var name coming back again,
that having the name of the source block would be of a great help. I tried
looking into the code to see if I could do it myself, but I must admit it's
still too hard for me. I have the impression many functions must be extended
in order to pass the src-name down to where the error is thrown...
Other thing, I tried to add a test for checking your fix never will be
regressed. This is what I currently have:
* Does not work
:PROPERTIES:
:ID: f2df5ba6-75fa-4e6b-8441-65ed84963627
:END:
If there is no value assigned to the code block, a proper error should be
thrown.
#+source: carre(x)
#+begin_src python
return x*x
#+end_src
* Test
#+begin_src emacs-lisp
(ert-deftest test-org-babel/no-defaut-value-for-var ()
"Test that the absence of a default value for a variable does throw a proper
error."
(org-test-at-id "f2df5ba6-75fa-4e6b-8441-65ed84963627"
(org-babel-next-src-block)
(should-error (org-babel-execute-src-block))
:type 'error))
#+end_src
Though, I have 2 questions:
- How can I differentiate between the clean error (with a message) and the one
which wasn't correctly trapped? Based on the first line of a backtrace
(string comparison) or on the type of the error? In the latter case, how
can I know what's the type of the current error thrown, and the one of the
error before your fix?
- I wonder why we need twice the =org-babel-next-src-block= call, and not only
once in the =should-error= form.
Thanks.
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [babel] Export problem (Wrong type argument: consp, nil)
2011-09-14 8:52 ` Sebastien Vauban
@ 2011-09-14 11:44 ` Martyn Jago
2011-09-15 15:10 ` Eric Schulte
1 sibling, 0 replies; 8+ messages in thread
From: Martyn Jago @ 2011-09-14 11:44 UTC (permalink / raw)
To: emacs-orgmode
Hi Sebastien
"Sebastien Vauban"
<wxhgmqzgwmuf@spammotel.com> writes:
> Hi Eric,
>
> Eric Schulte wrote:
>> "Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:
>>> If there is no value assigned to the code block...
>>> ... there is no an error when exporting:
>>>
>>> #+begin_src text
>>> Debugger entered--Lisp error: (wrong-type-argument consp nil)
>>> setcdr(nil "nil=x")
>>> #+end_src
>>
>> All variables must be given a default value, which is why it is an error
>> to write a code block like the following.
>>
>> #+source: circle(x)
>> #+begin_src python
>> return x*x
>> #+end_src
>>
>> I've just pushed up a change which provides a better error message in
>> this case.
>
> It works OK. Thanks a lot for that.
>
> Remark: This did correct a problem that I had with my local LOB, and which
> appeared a couple of months ago. I tried to find the post back, but I
> couldn't. At that time, you tried my example, but you couldn't reproduce it.
> Anyway, I now could check that it was because of this, now that the message is
> a lot clearer than "consp, nil".
>
> Question: Would it be possible to add the src-name in the error message? You
> know, in my LOB, I have so many times the same var name coming back again,
> that having the name of the source block would be of a great help. I tried
> looking into the code to see if I could do it myself, but I must admit it's
> still too hard for me. I have the impression many functions must be extended
> in order to pass the src-name down to where the error is thrown...
>
> Other thing, I tried to add a test for checking your fix never will be
> regressed. This is what I currently have:
>
> * Does not work
> :PROPERTIES:
> :ID: f2df5ba6-75fa-4e6b-8441-65ed84963627
> :END:
>
> If there is no value assigned to the code block, a proper error should be
> thrown.
>
> #+source: carre(x)
> #+begin_src python
> return x*x
> #+end_src
>
> * Test
>
> #+begin_src emacs-lisp
> (ert-deftest test-org-babel/no-defaut-value-for-var ()
> "Test that the absence of a default value for a variable does throw a proper
> error."
> (org-test-at-id "f2df5ba6-75fa-4e6b-8441-65ed84963627"
> (org-babel-next-src-block)
> (should-error (org-babel-execute-src-block))
> :type 'error))
> #+end_src
>
> Though, I have 2 questions:
>
> - How can I differentiate between the clean error (with a message) and the one
> which wasn't correctly trapped? Based on the first line of a backtrace
> (string comparison) or on the type of the error? In the latter case, how
> can I know what's the type of the current error thrown, and the one of the
> error before your fix?
I can help with the error question. You can test the specific error
message as follows:
--8<---------------cut here---------------start------------->8---
(ert-deftest test-org-babel/no-defaut-value-for-var ()
(org-test-at-id "f2df5ba6-75fa-4e6b-8441-65ed84963627"
(org-babel-next-src-block)
(let ((err
(should-error (org-babel-execute-src-block)
:type 'error)))
(should (equal '(error "variable \"x\" must be assigned a default value") err)))))
--8<---------------cut here---------------end--------------->8---
>
> - I wonder why we need twice the =org-babel-next-src-block= call, and not only
> once in the =should-error= form.
>
> Thanks.
>
> Best regards,
> Seb
Best, Martyn
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [babel] Export problem (Wrong type argument: consp, nil)
2011-09-14 8:52 ` Sebastien Vauban
2011-09-14 11:44 ` Martyn Jago
@ 2011-09-15 15:10 ` Eric Schulte
2011-09-16 9:57 ` Sebastien Vauban
2011-09-16 10:12 ` Sebastien Vauban
1 sibling, 2 replies; 8+ messages in thread
From: Eric Schulte @ 2011-09-15 15:10 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: emacs-orgmode
>
> Question: Would it be possible to add the src-name in the error
> message?
Unfortunately the code block name is not known to the function (namely
`org-babel-merge-params') which throws errors when variables are not
assigned default values. In fact this function may be called when there
are no code blocks present. I think that this is why you ran into
problems trying to thread the code block info down into this error
message.
Another option may be to check when a code block is initially parsed to
ensure that all variables are assigned default parameters. If the
checking is done initially then the code block name and position will be
known and could be included into the error message. There exists a
function for checking code blocks (namely `org-babel-check-src-block'),
I've added a TODO to this function to add a check that all variables are
initialized.
>
> * Test
>
> #+begin_src emacs-lisp
> (ert-deftest test-org-babel/no-defaut-value-for-var ()
> "Test that the absence of a default value for a variable does throw a proper
> error."
> (org-test-at-id "f2df5ba6-75fa-4e6b-8441-65ed84963627"
> (org-babel-next-src-block)
> (should-error (org-babel-execute-src-block))
> :type 'error))
> #+end_src
>
> Though, I have 2 questions:
>
> - How can I differentiate between the clean error (with a message) and the one
> which wasn't correctly trapped? Based on the first line of a backtrace
> (string comparison) or on the type of the error? In the latter case, how
> can I know what's the type of the current error thrown, and the one of the
> error before your fix?
>
I believe Martyn answered this question
>
> - I wonder why we need twice the =org-babel-next-src-block= call, and
> not only once in the =should-error= form.
>
I only see a single call to org-babel-next-src-block in the above test.
Thanks for working on this test, I look forward to adding it once it is
completed.
Cheers -- Eric
>
> Thanks.
>
> Best regards,
> Seb
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [babel] Export problem (Wrong type argument: consp, nil)
2011-09-15 15:10 ` Eric Schulte
@ 2011-09-16 9:57 ` Sebastien Vauban
2011-09-16 10:12 ` Sebastien Vauban
1 sibling, 0 replies; 8+ messages in thread
From: Sebastien Vauban @ 2011-09-16 9:57 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Eric,
Eric Schulte wrote:
>> Question: Would it be possible to add the src-name in the error
>> message?
>
> Unfortunately the code block name is not known to the function (namely
> `org-babel-merge-params') which throws errors when variables are not
> assigned default values. In fact this function may be called when there
> are no code blocks present. I think that this is why you ran into
> problems trying to thread the code block info down into this error
> message.
>
> Another option may be to check when a code block is initially parsed to
> ensure that all variables are assigned default parameters. If the
> checking is done initially then the code block name and position will be
> known and could be included into the error message. There exists a
> function for checking code blocks (namely `org-babel-check-src-block'),
> I've added a TODO to this function to add a check that all variables are
> initialized.
OK. Thanks.
>> * Test
>>
>> #+begin_src emacs-lisp
>> (ert-deftest test-org-babel/no-defaut-value-for-var ()
>> "Test that the absence of a default value for a variable does throw a proper
>> error."
>> (org-test-at-id "f2df5ba6-75fa-4e6b-8441-65ed84963627"
>> (org-babel-next-src-block)
>> (should-error (org-babel-execute-src-block))
>> :type 'error))
>> #+end_src
>>
>> Though, I have 2 questions:
>>
>> - How can I differentiate between the clean error (with a message) and the one
>> which wasn't correctly trapped? Based on the first line of a backtrace
>> (string comparison) or on the type of the error? In the latter case, how
>> can I know what's the type of the current error thrown, and the one of the
>> error before your fix?
>
> I believe Martyn answered this question
Yes, he did. Thanks Martyn.
>> - I wonder why we need twice the =org-babel-next-src-block= call, and
>> not only once in the =should-error= form.
>
> I only see a single call to org-babel-next-src-block in the above test.
OK, I misread `org-babel-next-src-block' and `org-babel-execute-src-block'. It
was late, I guess. Sorry for the noise.
> Thanks for working on this test, I look forward to adding it once it is
> completed.
With Martyn's patch, updated with the brand new source name figuring in the
error message, the completed version becomes:
* Code block with no default value for vars
:PROPERTIES:
:ID: f2df5ba6-75fa-4e6b-8441-65ed84963627
:END:
There is no default value assigned to =x= variable. This is not permitted
anymore.
#+source: carre(x)
#+begin_src python
return x*x
#+end_src
* Test
#+begin_src emacs-lisp
(ert-deftest test-org-babel/no-defaut-value-for-var ()
"Test that the absence of a default value for a variable DOES THROW an
error."
(org-test-at-id "f2df5ba6-75fa-4e6b-8441-65ed84963627"
(org-babel-next-src-block)
(let ((err
(should-error (org-babel-execute-src-block) :type 'error)))
(should (equal '(error "variable \"x\" in block \"carre\" must be assigned a default value") err)))))
#+end_src
I'll send you a patch for this.
Best regards,
Seb
--
Sebastien Vauban
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [babel] Export problem (Wrong type argument: consp, nil)
2011-09-15 15:10 ` Eric Schulte
2011-09-16 9:57 ` Sebastien Vauban
@ 2011-09-16 10:12 ` Sebastien Vauban
2011-09-16 15:25 ` Eric Schulte
1 sibling, 1 reply; 8+ messages in thread
From: Sebastien Vauban @ 2011-09-16 10:12 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
[-- Attachment #1: Type: text/plain, Size: 481 bytes --]
Hi Eric,
Eric Schulte wrote:
> Thanks for working on this test, I look forward to adding it once it is
> completed.
As promised, a patch for checking that vars with no default value will
generate an error with a full explanation.
I edited 2 files:
- lisp/test-ob.el
- examples/babel.org
Tell me if this is following your expected way of receiving patches. I believe
so, but tell me anything that would not have been done correctly...
Best regards,
Seb
--
Sebastien Vauban
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-test-checking-that-any-variable-declared-with-no.patch --]
[-- Type: text/x-patch, Size: 1379 bytes --]
From 453c0d5e54544ef5812098817746b4280375f5e4 Mon Sep 17 00:00:00 2001
From: Sebastien Vauban <sva-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
Date: Fri, 16 Sep 2011 12:06:21 +0200
Subject: [PATCH] Add test checking that any variable declared with no default
value will generate a proper error message.
---
testing/lisp/test-ob.el | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index 2e71a59..f78ca98 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -1,6 +1,6 @@
;;; test-ob.el --- tests for ob.el
-;; Copyright (c) 2010 Eric Schulte
+;; Copyright (c) 2010, 2011 Eric Schulte
;; Authors: Eric Schulte, Martyn Jago
;; Released under the GNU General Public License version 3
@@ -421,6 +421,15 @@
(next-result)
(should (not (org-babel-in-example-or-verbatim))))))
+(ert-deftest test-org-babel/no-defaut-value-for-var ()
+ "Test that the absence of a default value for a variable DOES THROW
+ a proper error."
+ (org-test-at-id "f2df5ba6-75fa-4e6b-8441-65ed84963627"
+ (org-babel-next-src-block)
+ (let ((err
+ (should-error (org-babel-execute-src-block) :type 'error)))
+ (should (equal '(error "variable \"x\" in block \"carre\" must be assigned a default value") err)))))
+
(provide 'test-ob)
;;; test-ob ends here
--
1.7.5.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0001-Add-test-checking-that-any-variable-declared-with-no.patch --]
[-- Type: text/x-patch, Size: 957 bytes --]
From 3e04371aa9a7afcacf5c26877328a829b8067830 Mon Sep 17 00:00:00 2001
From: Sebastien Vauban <sva-D0wtAvR13HarG/iDocfnWg@public.gmane.org>
Date: Fri, 16 Sep 2011 12:07:19 +0200
Subject: [PATCH] Add test checking that any variable declared with no default
value will generate a proper error message.
---
testing/examples/babel.org | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/testing/examples/babel.org b/testing/examples/babel.org
index b892124..82dd8ee 100644
--- a/testing/examples/babel.org
+++ b/testing/examples/babel.org
@@ -307,3 +307,16 @@ src_sh{echo 2} blocks on the src_emacs-lisp{"same"} line
#+results:
[[file:./cv.cls]]
+
+* no default value for vars
+ :PROPERTIES:
+ :ID: f2df5ba6-75fa-4e6b-8441-65ed84963627
+ :END:
+
+There is no default value assigned to =x= variable. This is not permitted
+anymore.
+
+#+source: carre(x)
+#+begin_src python
+ return x*x
+#+end_src
--
1.7.5.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [babel] Export problem (Wrong type argument: consp, nil)
2011-09-16 10:12 ` Sebastien Vauban
@ 2011-09-16 15:25 ` Eric Schulte
0 siblings, 0 replies; 8+ messages in thread
From: Eric Schulte @ 2011-09-16 15:25 UTC (permalink / raw)
To: Sebastien Vauban; +Cc: emacs-orgmode
Hi
"Sebastien Vauban" <wxhgmqzgwmuf@spammotel.com> writes:
> Hi Eric,
>
> Eric Schulte wrote:
>> Thanks for working on this test, I look forward to adding it once it is
>> completed.
>
> As promised, a patch for checking that vars with no default value will
> generate an error with a full explanation.
>
> I edited 2 files:
> - lisp/test-ob.el
> - examples/babel.org
>
Great! Thanks for contributing these test cases. They are now applied
and are passing.
>
> Tell me if this is following your expected way of receiving patches. I believe
> so, but tell me anything that would not have been done correctly...
>
Yes, I do prefer these format of patch (i.e., generated using git
format-patch), however I would prefer if you only sent a single patch
for all changed files, rather than splitting the commit up into two
patches.
Thanks -- Eric
>
> Best regards,
> Seb
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-09-16 15:57 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-08 15:15 [babel] Export problem (Wrong type argument: consp, nil) Sebastien Vauban
2011-09-08 17:33 ` Eric Schulte
2011-09-14 8:52 ` Sebastien Vauban
2011-09-14 11:44 ` Martyn Jago
2011-09-15 15:10 ` Eric Schulte
2011-09-16 9:57 ` Sebastien Vauban
2011-09-16 10:12 ` Sebastien Vauban
2011-09-16 15:25 ` Eric Schulte
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).