0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-09-14 11:09:54 +00:00

Reinstated force-results-to-vector: passing all tests in table.

This commit is contained in:
Dan Davison 2009-07-17 14:37:43 -04:00
parent c05ac759ac
commit 017d46e50f
2 changed files with 67 additions and 64 deletions

View file

@ -165,30 +165,30 @@ the header arguments specified at the source code block."
(unless (member lang org-babel-interpreters) (unless (member lang org-babel-interpreters)
(error "Language is not in `org-babel-interpreters': %s" lang)) (error "Language is not in `org-babel-interpreters': %s" lang))
(when arg (setq result-params (cons "silent" result-params))) (when arg (setq result-params (cons "silent" result-params)))
(setq result (setq result (multiple-value-bind (session vars result-params result-type) processed-params
(org-babel-process-result (funcall cmd body params)))
(multiple-value-bind (session vars result-params result-type) processed-params (if (eq result-type 'value)
(funcall cmd body params)) result-type)) (setq result (org-babel-process-result result result-params)))
(org-babel-insert-result result result-params) (org-babel-insert-result result result-params)
(case result-type (output nil) (value result)))) (case result-type (output nil) (value result))))
(defun org-babel-process-result (result result-type) (defun org-babel-process-result (result result-params)
"This doesn't do anything currently. "Process returned value for insertion in buffer.
You can see below the various fragments of results-processing Currently, this function forces to table output if :results
code that were present in the language-specific files. Out of vector has been supplied.
those fragments, I've moved the
org-babel-python-table-or-results and
org-babel-import-elisp-from-file functionality into the
org-babel-*-evaluate functions. I think those should only be
used in the :results value case, as in the 'output case we are
not concerned with creating elisp versions of results.
The rest of the functionality below, concerned with vectorising You can see below the various fragments of results-processing
or scalarising results is commented out, has not yet been code that were present in the language-specific files. Out of
replaced, and may need to be reinstated in this function. " those fragments, I've moved the org-babel-python-table-or-results
and org-babel-import-elisp-from-file functionality into the
org-babel-*-evaluate functions. I think those should only be used
in the :results value case, as in the 'output case we are not
concerned with creating elisp versions of results. "
result) (if (and (member "vector" result-params) (not (listp result)))
(list (list result))
result))
;; ;; ruby ;; ;; ruby
;; (if (member "scalar" result-params) ;; (if (member "scalar" result-params)
;; results ;; results

View file

@ -2512,53 +2512,56 @@ org-babel functionality.
of these tests may fail. of these tests may fail.
#+TBLNAME: org-babel-tests #+TBLNAME: org-babel-tests
| functionality | block | arg | expected | results | pass | | functionality | block | arg | expected | results | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| basic evaluation | | | | | pass | | basic evaluation | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| emacs lisp | basic-elisp | | 5 | 5 | pass | | emacs lisp | basic-elisp | | 5 | 5 | pass |
| shell | basic-shell | | 6 | 6 | pass | | shell | basic-shell | | 6 | 6 | pass |
| ruby | basic-ruby | | org-babel | org-babel | pass | | ruby | basic-ruby | | org-babel | org-babel | pass |
| python | basic-python | | hello world | hello world | pass | | python | basic-python | | hello world | hello world | pass |
| R | basic-R | | 13 | 13 | pass | | R | basic-R | | 13 | 13 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| tables | | | | | pass | | tables | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| emacs lisp | table-elisp | | 3 | 3 | pass | | emacs lisp | table-elisp | | 3 | 3 | pass |
| ruby | table-ruby | | 1-2-3 | 1-2-3 | pass | | ruby | table-ruby | | 1-2-3 | 1-2-3 | pass |
| python | table-python | | 5 | 5 | pass | | python | table-python | | 5 | 5 | pass |
| R | table-R | | 3.5 | 3.5 | pass | | R | table-R | | 3.5 | 3.5 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| source block references | | | | | pass | | source block references | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| all languages | chained-ref-last | | Array | Array | pass | | all languages | chained-ref-last | | Array | Array | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| source block functions | | | | | pass | | source block functions | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| emacs lisp | defun-fibb | | fibbd | fibbd | pass | | emacs lisp | defun-fibb | | fibbd | fibbd | pass |
| run over | Fibonacci | 0 | 1 | 1 | pass | | run over | Fibonacci | 0 | 1 | 1 | pass |
| a | Fibonacci | 1 | 1 | 1 | pass | | a | Fibonacci | 1 | 1 | 1 | pass |
| variety | Fibonacci | 2 | 2 | 2 | pass | | variety | Fibonacci | 2 | 2 | 2 | pass |
| of | Fibonacci | 3 | 3 | 3 | pass | | of | Fibonacci | 3 | 3 | 3 | pass |
| different | Fibonacci | 4 | 5 | 5 | pass | | different | Fibonacci | 4 | 5 | 5 | pass |
| arguments | Fibonacci | 5 | 8 | 8 | pass | | arguments | Fibonacci | 5 | 8 | 8 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| bugs and tasks | | | | | pass | | bugs and tasks | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| simple ruby arrays | ruby-array-test | | 3 | 3 | pass | | simple ruby arrays | ruby-array-test | | 3 | 3 | pass |
| R number evaluation | bug-R-number-evaluation | | 2 | 2 | pass | | R number evaluation | bug-R-number-evaluation | | 2 | 2 | pass |
| multi-line ruby blocks | multi-line-ruby-test | | 2 | 2 | pass | | multi-line ruby blocks | multi-line-ruby-test | | 2 | 2 | pass |
| forcing vector results | test-forced-vector-results | | Array | Fixnum | expected "Array" but was "Fixnum" | | forcing vector results | test-forced-vector-results | | Array | Array | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| sessions | | | | | pass | | sessions | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------| |-------------------------+----------------------------+-----+-------------+-------------+------|
| set ruby session | set-ruby-session-var | | :set | #ERROR | expected ":set" but was "#ERROR" | | set ruby session | set-ruby-session-var | | :set | :set | pass |
| get from ruby session | get-ruby-session-var | | 3 | #ERROR | expected "3" but was "#ERROR" | | get from ruby session | get-ruby-session-var | | 3 | 3 | pass |
| set python session | set-python-session-var | | set | set | pass | | set python session | set-python-session-var | | set | set | pass |
| get from python session | get-python-session-var | | 4 | 4 | pass | | get from python session | get-python-session-var | | 4 | 4 | pass |
| set R session | set-R-session-var | | set | set | pass | | set R session | set-R-session-var | | set | set | pass |
| get from R session | get-R-session-var | | 5 | 5 | pass | | get from R session | get-R-session-var | | 5 | 5 | pass |
#+TBLFM: $5='(if (= (length $3) 1) (progn (message (format "running %S" '(sbe $2 (n $3)))) (sbe $2 (n $3))) (sbe $2))::$6='(if (string= $4 $5) "pass" (format "expected %S but was %S" $4 $5)) #+TBLFM: $5='(if (= (length $3) 1) (progn (message (format "running %S" '(sbe $2 (n $3)))) (sbe $2 (n $3))) (sbe $2))::$6='(if (string= $4 $5) "pass" (format "expected %S but was %S" $4 $5))
#+TBLFM: $5=""::$6=""
The second line (followed by replacing '[]' with '') can be used to blank out the table results, in the absence of a better method.
** basic tests ** basic tests