Przeglądaj źródła

now really passing all basic tests

Eric Schulte 16 lat temu
rodzic
commit
d41466e5bc
3 zmienionych plików z 47 dodań i 40 usunięć
  1. 9 1
      lisp/langs/org-babel-python.el
  2. 1 1
      lisp/org-babel.el
  3. 37 38
      org-babel.org

+ 9 - 1
lisp/langs/org-babel-python.el

@@ -138,11 +138,19 @@ last statement in BODY."
       ;; split results with `comint-prompt-regexp'
       (setq results (delete org-babel-python-eoe-indicator
                             (cdr (member org-babel-python-eoe-indicator
-                                         (reverse (mapcar #'org-babel-trim (split-string string-buffer comint-prompt-regexp)))))))
+                                         (reverse (mapcar #'org-babel-trim
+                                                          (split-string string-buffer comint-prompt-regexp)))))))
+      (setq results (mapcar #'org-babel-python-read-string results))
       (org-babel-trim (case result-type
                         (output (mapconcat #'identity (reverse (cdr results)) "\n"))
                         (value (car results))
                         (t (reverse results)))))))
 
+(defun org-babel-python-read-string (string)
+  "Strip 's from around ruby string"
+  (if (string-match "'\\([^\000]+\\)'" string)
+      (match-string 1 string)
+    string))
+
 (provide 'org-babel-python)
 ;;; org-babel-python.el ends here

+ 1 - 1
lisp/org-babel.el

@@ -350,7 +350,7 @@ This is taken almost directly from `org-read-prop'."
       (if (org-babel-number-p cell)
           (string-to-number cell)
         (if (or (equal "(" (substring cell 0 1))
-                (equal "'" (substring cell 0 1)))
+                (equal "'" (substring cell 0 2)))
             (read cell)
           (progn (set-text-properties 0 (length cell) nil cell) cell)))
     cell))

+ 37 - 38
org-babel.org

@@ -1972,43 +1972,43 @@ 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 |       Array | 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 |      #ERROR | expected "13" but was "#ERROR"    |
+|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
+| 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 |      #ERROR | expected "3.5" but was "#ERROR"   |
+|-------------------------+----------------------------+-----+-------------+-------------+-----------------------------------|
+| 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 |      #ERROR | expected "2" but was "#ERROR"     |
+| multi-line ruby blocks  | multi-line-ruby-test       |     |           2 |      #ERROR | expected "2" but was "#ERROR"     |
+| forcing vector results  | test-forced-vector-results |     |       Array |      #ERROR | expected "Array" but was "#ERROR" |
 #+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))
 
 ** basic tests
@@ -2110,7 +2110,6 @@ and Check that it is still a list
 table.class.name
 #+end_src
 
-
 ** source blocks as functions
 
 #+srcname: defun-fibb