3 (defun gds-test-execute-keys (keys &optional keys2
)
4 (execute-kbd-macro (apply 'vector
(listify-key-sequence keys
))))
6 (defvar gds-test-expecting nil
)
8 (defun gds-test-protocol-hook (form)
9 (message "[protocol: %s]" (car form
))
10 (if (eq (car form
) gds-test-expecting
)
11 (setq gds-test-expecting nil
)))
13 (defun gds-test-expect-protocol (proc &optional timeout
)
14 (message "[expect: %s]" proc
)
15 (setq gds-test-expecting proc
)
16 (while gds-test-expecting
17 (or (accept-process-output gds-debug-server
(or timeout
5))
18 (error "Timed out after %ds waiting for %s" (or timeout
5) proc
))))
20 (defun gds-test-check-buffer (name &rest strings
)
21 (let ((buf (or (get-buffer name
) (error "No %s buffer" name
))))
24 (goto-char (point-min))
26 (search-forward (car strings
))
27 (setq strings
(cdr strings
))))))
30 (message "TEST: %s" desc
))
32 ;; Make sure we take GDS elisp code from this code tree.
33 (setq load-path
(cons (concat default-directory
"emacs/") load-path
))
35 ;; Protect the tests so we can do some cleanups in case of error.
39 ;; Visit the tutorial.
40 (find-file "gds-tutorial.txt")
43 (search-forward "(require 'gds)")
44 (setq load-path
(cons (concat default-directory
"emacs/") load-path
))
45 (gds-test-execute-keys "\C-x\C-e")
47 ;; Install our testing hook.
48 (add-hook 'gds-protocol-hook
'gds-test-protocol-hook
)
51 (search-forward "(list-ref")
53 (gds-test-execute-keys "\C-hg\C-m")
54 (gds-test-expect-protocol 'eval-results
10)
55 (gds-test-check-buffer "*Guile Help*"
57 "is a primitive procedure in the (guile) module")
60 (re-search-forward "^with-output-to-s")
61 (gds-test-execute-keys "\e\C-i")
63 (or (looking-at "with-output-to-string")
64 (error "Expected completion `with-output-to-string' failed"))
67 (search-forward "(display z)")
68 (gds-test-execute-keys "\e\C-x")
69 (gds-test-expect-protocol 'eval-results
)
70 (gds-test-check-buffer "*Guile Evaluation*"
75 (TEST "Multiple values.")
76 (search-forward "(values 'a ")
77 (gds-test-execute-keys "\e\C-x")
78 (gds-test-expect-protocol 'eval-results
)
79 (gds-test-check-buffer "*Guile Evaluation*"
86 (TEST "Eval region with multiple expressions.")
87 (search-forward "(display \"Arctangent is: \")")
91 (gds-test-execute-keys "\C-c\C-r")
92 (gds-test-expect-protocol 'eval-results
)
93 (gds-test-check-buffer "*Guile Evaluation*"
94 "(display \"Arctangent is"
96 "=> no (or unspecified) value"
97 "ERROR: Unbound variable: z"
98 "=> error-in-evaluation"
99 "Evaluating expression 3"
100 "=> no (or unspecified) value")
102 (TEST "Eval syntactically unbalanced region.")
103 (search-forward "(let ((z (atan x y)))")
105 (push-mark nil nil t
)
107 (gds-test-execute-keys "\C-c\C-r")
108 (gds-test-expect-protocol 'eval-results
)
109 (gds-test-check-buffer "*Guile Evaluation*"
111 "Reading expressions to evaluate"
116 (TEST "Stepping through an evaluation.")
117 (search-forward "(for-each (lambda (x)")
119 (push-mark nil nil t
)
121 (gds-test-execute-keys "\C-u\e\C-x")
122 (gds-test-expect-protocol 'stack
)
123 (gds-test-execute-keys " ")
124 (gds-test-expect-protocol 'stack
)
125 (gds-test-execute-keys "o")
126 (gds-test-expect-protocol 'stack
)
127 (gds-test-execute-keys "o")
128 (gds-test-expect-protocol 'stack
)
129 (gds-test-execute-keys "o")
130 (gds-test-expect-protocol 'stack
)
131 (gds-test-execute-keys "o")
132 (gds-test-expect-protocol 'stack
)
133 (gds-test-execute-keys "o")
134 (gds-test-expect-protocol 'stack
)
135 (gds-test-execute-keys "o")
136 (gds-test-expect-protocol 'stack
)
137 (gds-test-execute-keys "o")
138 (gds-test-expect-protocol 'stack
)
139 (gds-test-execute-keys "o")
140 (gds-test-expect-protocol 'stack
)
141 (gds-test-execute-keys "o")
142 (gds-test-expect-protocol 'stack
)
143 (gds-test-execute-keys "o")
144 (gds-test-expect-protocol 'stack
)
145 (gds-test-execute-keys "g")
146 (gds-test-expect-protocol 'eval-results
)
147 (gds-test-check-buffer "*Guile Evaluation*"
149 "Evaluating in current module"
151 "=> no (or unspecified) value")
154 (message "====================================")
155 (message "gds-test.el completed without errors")
156 (message "====================================")
160 (switch-to-buffer "gds-debug")
161 (write-region (point-min) (point-max) "gds-test.debug")
163 (switch-to-buffer "*GDS Transcript*")
164 (write-region (point-min) (point-max) "gds-test.transcript")