summaryrefslogtreecommitdiffstats
path: root/tests/015
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2023-05-23 21:45:33 -0700
committerKaz Kylheku <kaz@kylheku.com>2023-05-23 21:45:33 -0700
commit0a9f9ae8d11a43108f0b8fffae954da4f9539b7f (patch)
tree2d3dd1f48ed6b5bd3a080170d7738a2e74330522 /tests/015
parent41263c972c2d2892f9bb65e439f1b744a26a271f (diff)
downloadtxr-0a9f9ae8d11a43108f0b8fffae954da4f9539b7f.tar.gz
txr-0a9f9ae8d11a43108f0b8fffae954da4f9539b7f.tar.bz2
txr-0a9f9ae8d11a43108f0b8fffae954da4f9539b7f.zip
awk: bug: fix ->> appending redirection operator.
* stdlib/awk.tl (awk-state ensure-stream): Fix missing handling for the :apf kind symbol used by appending. * tests/015/awk-redir.tl: New file.
Diffstat (limited to 'tests/015')
-rw-r--r--tests/015/awk-redir.tl42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/015/awk-redir.tl b/tests/015/awk-redir.tl
new file mode 100644
index 00000000..5359ea2b
--- /dev/null
+++ b/tests/015/awk-redir.tl
@@ -0,0 +1,42 @@
+(load "../common")
+
+(push-after-load
+ (each ((f '#"file1.out file2.out file3.out"))
+ (remove-path f)))
+
+(file-put-lines "file1.out" '("old"))
+(file-put-lines "file2.out" '("old"))
+
+(awk
+ (:begin (->> "file1.out" (prn "abc"))
+ (->> "file1.out" (prn "def"))))
+
+(test
+ (file-get-lines "file1.out")
+ #"old abc def")
+
+(awk
+ (:begin (-> "file2.out" (prn "abc"))
+ (-> "file2.out" (prn "def"))))
+
+(test
+ (file-get-lines "file2.out")
+ #"abc def")
+
+(test
+ (build
+ (awk
+ (:begin (<- "file1.out" (add (get-line)))
+ (<- "file1.out" (add (get-line))))))
+ #"old abc")
+
+
+(awk (:begin (!> "cat > file3.out" (prn "out"))))
+
+(test (file-get-string "file3.out") "out\n")
+
+(test
+ (build
+ (awk
+ (:begin (<! "cat file3.out" (add (get-line))))))
+ #"out")