0
0
Fork 1
mirror of https://git.savannah.gnu.org/git/emacs/org-mode.git synced 2024-08-30 05:13:04 +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)
(error "Language is not in `org-babel-interpreters': %s" lang))
(when arg (setq result-params (cons "silent" result-params)))
(setq result
(org-babel-process-result
(multiple-value-bind (session vars result-params result-type) processed-params
(funcall cmd body params)) result-type))
(setq result (multiple-value-bind (session vars result-params result-type) processed-params
(funcall cmd body params)))
(if (eq result-type 'value)
(setq result (org-babel-process-result result result-params)))
(org-babel-insert-result result result-params)
(case result-type (output nil) (value result))))
(defun org-babel-process-result (result result-type)
"This doesn't do anything currently.
(defun org-babel-process-result (result result-params)
"Process returned value for insertion in buffer.
You can see below the various fragments of results-processing
code that were present in the language-specific files. Out of
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.
Currently, this function forces to table output if :results
vector has been supplied.
The rest of the functionality below, concerned with vectorising
or scalarising results is commented out, has not yet been
replaced, and may need to be reinstated in this function. "
You can see below the various fragments of results-processing
code that were present in the language-specific files. Out of
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
;; (if (member "scalar" result-params)
;; results

View file

@ -2512,53 +2512,56 @@ org-babel functionality.
of these tests may fail.
#+TBLNAME: org-babel-tests
| functionality | block | arg | expected | results | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| basic evaluation | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| emacs lisp | basic-elisp | | 5 | 5 | pass |
| shell | basic-shell | | 6 | 6 | pass |
| ruby | basic-ruby | | org-babel | org-babel | pass |
| python | basic-python | | hello world | hello world | pass |
| R | basic-R | | 13 | 13 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| tables | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| emacs lisp | table-elisp | | 3 | 3 | pass |
| ruby | table-ruby | | 1-2-3 | 1-2-3 | pass |
| python | table-python | | 5 | 5 | pass |
| R | table-R | | 3.5 | 3.5 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| source block references | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| all languages | chained-ref-last | | Array | Array | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| source block functions | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| emacs lisp | defun-fibb | | fibbd | fibbd | pass |
| run over | Fibonacci | 0 | 1 | 1 | pass |
| a | Fibonacci | 1 | 1 | 1 | pass |
| variety | Fibonacci | 2 | 2 | 2 | pass |
| of | Fibonacci | 3 | 3 | 3 | pass |
| different | Fibonacci | 4 | 5 | 5 | pass |
| arguments | Fibonacci | 5 | 8 | 8 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| bugs and tasks | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| simple ruby arrays | ruby-array-test | | 3 | 3 | pass |
| R number evaluation | bug-R-number-evaluation | | 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" |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| sessions | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
| set ruby session | set-ruby-session-var | | :set | #ERROR | expected ":set" but was "#ERROR" |
| get from ruby session | get-ruby-session-var | | 3 | #ERROR | expected "3" but was "#ERROR" |
| set python session | set-python-session-var | | set | set | pass |
| get from python session | get-python-session-var | | 4 | 4 | pass |
| set R session | set-R-session-var | | set | set | pass |
| get from R session | get-R-session-var | | 5 | 5 | pass |
| functionality | block | arg | expected | results | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| basic evaluation | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| emacs lisp | basic-elisp | | 5 | 5 | pass |
| shell | basic-shell | | 6 | 6 | pass |
| ruby | basic-ruby | | org-babel | org-babel | pass |
| python | basic-python | | hello world | hello world | pass |
| R | basic-R | | 13 | 13 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| tables | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| emacs lisp | table-elisp | | 3 | 3 | pass |
| ruby | table-ruby | | 1-2-3 | 1-2-3 | pass |
| python | table-python | | 5 | 5 | pass |
| R | table-R | | 3.5 | 3.5 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| source block references | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| all languages | chained-ref-last | | Array | Array | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| source block functions | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| emacs lisp | defun-fibb | | fibbd | fibbd | pass |
| run over | Fibonacci | 0 | 1 | 1 | pass |
| a | Fibonacci | 1 | 1 | 1 | pass |
| variety | Fibonacci | 2 | 2 | 2 | pass |
| of | Fibonacci | 3 | 3 | 3 | pass |
| different | Fibonacci | 4 | 5 | 5 | pass |
| arguments | Fibonacci | 5 | 8 | 8 | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| bugs and tasks | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| simple ruby arrays | ruby-array-test | | 3 | 3 | pass |
| R number evaluation | bug-R-number-evaluation | | 2 | 2 | pass |
| multi-line ruby blocks | multi-line-ruby-test | | 2 | 2 | pass |
| forcing vector results | test-forced-vector-results | | Array | Array | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| sessions | | | | | pass |
|-------------------------+----------------------------+-----+-------------+-------------+------|
| set ruby session | set-ruby-session-var | | :set | :set | pass |
| get from ruby session | get-ruby-session-var | | 3 | 3 | pass |
| set python session | set-python-session-var | | set | set | pass |
| get from python session | get-python-session-var | | 4 | 4 | pass |
| set R session | set-R-session-var | | set | set | 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=""::$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