[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 16ea9f84f6 5/8: Refactor ob-shell/bash-uses-assoc-a
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 16ea9f84f6 5/8: Refactor ob-shell/bash-uses-assoc-arrays |
Date: |
Wed, 11 Jan 2023 14:57:59 -0500 (EST) |
branch: externals/org
commit 16ea9f84f650a96ed248b555bd0cb312a8778330
Author: Matt Trzcinski <matt@excalamus.com>
Commit: Matthew Trzcinski <matt@excalamus.com>
Refactor ob-shell/bash-uses-assoc-arrays
* testing/lisp/test-ob-shell.el (ob-shell/bash-uses-assoc-arrays):
Split test cases into separate tests,
`test-ob-shell/bash-uses-assoc-arrays' and
`test-ob-shell/bash-uses-assoc-arrays-with-lists'. Rename prefix from
"ob-shell" to "test-ob-shell".
(ob-shell/bash-uses-assoc-arrays): Move comments from
testing/examples/ob-shell-test.org to docstrings.
(ob-shell/bash-uses-assoc-arrays): Remove dependency on
testing/examples/ob-shell-test.org.
---
testing/lisp/test-ob-shell.el | 53 +++++++++++++++++++++++++++++++------------
1 file changed, 38 insertions(+), 15 deletions(-)
diff --git a/testing/lisp/test-ob-shell.el b/testing/lisp/test-ob-shell.el
index a39c99d9f3..78267880b5 100644
--- a/testing/lisp/test-ob-shell.el
+++ b/testing/lisp/test-ob-shell.el
@@ -118,21 +118,44 @@ echo ${table}
(equal "bread 2 kg spaghetti 20 cm milk 50 dl"
(org-trim (org-babel-execute-src-block))))))
-(ert-deftest ob-shell/bash-uses-assoc-arrays ()
- "Bash associative arrays"
- (should
- (equal "two"
- (org-test-at-id
- "bec1a5b0-4619-4450-a8c0-2a746b44bf8d"
- (org-babel-next-src-block 2)
- (org-trim (org-babel-execute-src-block)))))
- ;; Bash associative arrays as strings for the row.
- (should
- (equal "20 cm"
- (org-test-at-id
- "82320a48-3409-49d7-85c9-5de1c6d3ff87"
- (org-babel-next-src-block 2)
- (org-trim (org-babel-execute-src-block))))))
+(ert-deftest test-ob-shell/bash-uses-assoc-arrays ()
+ "Bash shell: support for associative arrays
+
+Bash will see a table that contains the first column as the
+'index' of the associative array, and the second column as the
+value. "
+ (org-test-with-temp-text
+ "#+NAME: sample_mapping_table
+| first | one |
+| second | two |
+| third | three |
+
+#+begin_src bash :exports :results output results :var
table=sample_mapping_table
+echo ${table[second]}
+<point>
+#+end_src "
+ (should
+ (equal "two"
+ (org-trim (org-babel-execute-src-block))))))
+
+(ert-deftest test-ob-shell/bash-uses-assoc-arrays-with-lists ()
+ "Bash shell: support for associative arrays with lists
+
+Bash will see an associative array that contains each row as a single
+string. Bash cannot handle lists in associative arrays."
+ (org-test-with-temp-text
+ "#+NAME: sample_big_table
+| bread | 2 | kg |
+| spaghetti | 20 | cm |
+| milk | 50 | dl |
+
+#+begin_src bash :exports results :results output :var table=sample_big_table
+echo ${table[spaghetti]}
+<point>
+#+end_src"
+ (should
+ (equal "20 cm"
+ (org-trim (org-babel-execute-src-block))))))
(ert-deftest ob-shell/simple-list ()
"Test list variables in shell."
- [elpa] externals/org updated (4f319088ba -> bcca8819c3), ELPA Syncer, 2023/01/11
- [elpa] externals/org 875845de1b 2/8: test-ob-shell.el: Split test-ob-shell/dont-error-on-empty-results, ELPA Syncer, 2023/01/11
- [elpa] externals/org 16ea9f84f6 5/8: Refactor ob-shell/bash-uses-assoc-arrays,
ELPA Syncer <=
- [elpa] externals/org 597ecaa5c1 1/8: Revert "Merge branch 'ob-shell-cleanup-tests'", ELPA Syncer, 2023/01/11
- [elpa] externals/org c61112c850 4/8: test-ob-shell.el: Refactor ob-shell/generic-uses-no-assoc-arrays, ELPA Syncer, 2023/01/11
- [elpa] externals/org ccd5977f62 7/8: ob-shell-test.org: Remove ob-shell-test.org, ELPA Syncer, 2023/01/11
- [elpa] externals/org bcca8819c3 8/8: test-ob-shell.el: Organize tests, ELPA Syncer, 2023/01/11
- [elpa] externals/org d7ff5b2462 6/8: test-ob-shell.el: Refactor test names and kill test buffers, ELPA Syncer, 2023/01/11
- [elpa] externals/org 2ddbee5e63 3/8: test-ob-shell.el: Refactor test-ob-shell/session, ELPA Syncer, 2023/01/11