summaryrefslogtreecommitdiff
path: root/gr-run-waveform/guile
diff options
context:
space:
mode:
Diffstat (limited to 'gr-run-waveform/guile')
-rw-r--r--gr-run-waveform/guile/cat.scm15
-rw-r--r--gr-run-waveform/guile/readline.scm3
-rw-r--r--gr-run-waveform/guile/simple.scm60
3 files changed, 78 insertions, 0 deletions
diff --git a/gr-run-waveform/guile/cat.scm b/gr-run-waveform/guile/cat.scm
new file mode 100644
index 000000000..6a5a38acf
--- /dev/null
+++ b/gr-run-waveform/guile/cat.scm
@@ -0,0 +1,15 @@
+;;; This is non-idiomatic, but will exercise the port...
+(define (cat input-port)
+ (let loop ((ch (read-char input-port)))
+ (if (not (eof-object? ch))
+ (begin
+ (write-char ch (current-output-port))
+ (loop (read-char input-port))))))
+
+(define foo (make-gnuradio-port "ice-9/boot-9.scm"))
+;;(define foo (cat (make-gnuradio-port "ice-9/boot-9.scm")))
+
+;; # Then start guile and use it
+;; guile> (load "/tmp/cat.scm")
+;; guile> (cat (open-file "/etc/passwd" "r"))
+
diff --git a/gr-run-waveform/guile/readline.scm b/gr-run-waveform/guile/readline.scm
new file mode 100644
index 000000000..badfa92ae
--- /dev/null
+++ b/gr-run-waveform/guile/readline.scm
@@ -0,0 +1,3 @@
+(use-modules (ice-9 readline))
+(activate-readline)
+(read-char)
diff --git a/gr-run-waveform/guile/simple.scm b/gr-run-waveform/guile/simple.scm
new file mode 100644
index 000000000..ae8ef9b60
--- /dev/null
+++ b/gr-run-waveform/guile/simple.scm
@@ -0,0 +1,60 @@
+(define filename "ice-9/boot-9")
+
+;; System default path
+(define path %load-path)
+path
+;;
+(define path-with-xyzzy (cons "/-xyzzy-" path))
+path-with-xyzzy
+;;
+;; look for .scm or no extension
+(define extensions '(".scm" ""))
+
+;; Both of these return "/usr/share/guile/1.8/ice-9/boot-9.scm"
+(define expected "/usr/share/guile/1.8/ice-9/boot-9.scm")
+(define result1 (search-path path filename extensions))
+(if (string=? result1 expected)
+ (display "PASSED: xyzzy-search-path from guile\n")
+ (display "FAILED: xyzzy-search-path from guile\n"))
+
+(define result2 (search-path path-with-xyzzy filename extensions))
+(if (string=? result2 expected)
+ (display "PASSED: xyzzy-search-path from guile\n")
+ (display "FAILED: xyzzy-search-path from guile\n"))
+
+;; Should return "/usr/share/guile/1.8/ice-9/boot-9.scm"
+(define result3 (xyzzy-search-path path filename extensions))
+(if (string=? result3 expected)
+ (display "PASSED: xyzzy-search-path from guile\n")
+ (display "FAILED: xyzzy-search-path from guile\n"))
+
+;; Should return "/-xyzzy-/ice-9/boot-9.scm"
+(define expected "/-xyzzy-/ice-9/boot-9.scm")
+(define result4 (xyzzy-search-path path-with-xyzzy filename extensions))
+(if (string=? result4 expected)
+ (display "PASSED: xyzzy-search-path from guile\n")
+ (display "FAILED: xyzzy-search-path from guile\n"))
+
+;; (define result5 (primitive-load filename))
+
+;; (define result6 (xyzzy-primitive-load file))
+
+;; FIXME: not sure how to tell if this worked other than if the test doesn't crash
+(define result7 (xyzzy-primitive-load expected))
+(define result8 (xyzzy-primitive-load-path expected))
+
+;; This should return the full name, or #f if it fails.
+(define result9 (xyzzy-search-load-path filename))
+(if (boolean? result9)
+ (display "FAILED: xyzzy-search-load-path from guile\n")
+ (if (string=? result9 result1)
+ (display "PASSES: xyzzy-search-load-path from guile\n")
+ (display "FAILED: xyzzy-search-load-path from guile\n")))
+
+(define result10 (xyzzy-search-load-path expected))
+(if (boolean? result9)
+ (display "FAILED: xyzzy-search-load-path from guile\n")
+ (if (string=? result10 expected)
+ (display "PASSED: xyzzy-search-load-path from guile\n")
+ (display "FAILED: xyzzy-search-load-path from guile\n")))
+