home: hub: zuo

Download patch

ref: d25c17b544331ea7ef63cb92cff9f4f410e46b6d
parent: b5000406fb9352c7ded0e0c9bf80f64e0b31ed6a
author: Matthew Flatt <mflatt@racket-lang.org>
date: Tue Apr 12 14:56:57 CDT 2022

zuo: repairs

Repair tests, problem with `-B`, and a reader problem.

--- a/tests/file-handle.zuo
+++ b/tests/file-handle.zuo
@@ -15,7 +15,7 @@
 (check-arg-fail (fd-open-output 'stdin (hash)) "not a path string")
 (check-arg-fail (fd-open-input 'stdout) "not a path string")
 (check-arg-fail (fd-open-input 'stderr) "not a path string")
-(check-arg-fail (fd-open-output 'stdout (hash 'exists 'truncate)) "non-empty options")
+(check-arg-fail (fd-open-output 'stdout (hash 'exists 'truncate)) "unrecognized or unused option")
 
 (let ([out (fd-open-output (build-path tmp-dir "handle1.txt") :truncate)])
   (check (handle? out))
@@ -52,7 +52,7 @@
 (check-arg-fail (fd-close 'oops) "not an open input or output")
 
 (check-arg-fail (fd-open-output "file" 'oops) "not a hash table")
-(check-arg-fail (fd-open-output "file" (hash 'oops 'truncate)) "unrecognized option")
+(check-arg-fail (fd-open-output "file" (hash 'oops 'truncate)) "unrecognized or unused option")
 (check-arg-fail (fd-open-output "file" (hash 'exists 'oops)) "invalid exists mode")
 
 (check-arg-fail (fd-open-output ,(build-path tmp-dir "handle1.txt")
--- a/tests/image.zuo
+++ b/tests/image.zuo
@@ -20,9 +20,9 @@
   (run-zuo* (list "-X" "" "-B" image-file "")
             (~a "#lang " lang " 10")
             (lambda (status out err)
+              (check err "")
               (check (and (= status 0) lang) lang)
-              (check out "10\n")
-              (check err ""))))
+              (check out "10\n"))))
 
 (try-dump "zuo")
 (try-dump "zuo/hygienic")
--- a/tests/procedure.zuo
+++ b/tests/procedure.zuo
@@ -30,11 +30,12 @@
        10)
 (check-fail (call/cc 1) "not a procedure")
 
-(check (call/prompt (lambda () 10)) 10)
+(check (call/prompt (lambda () 10) 'tag) 10)
 (check (let ([k (call/prompt
                  (lambda ()
-                   (call/cc (lambda (k) k))))])
-         (+ 1 (call/prompt (lambda () (k 11)))))
+                   (call/cc (lambda (k) k)))
+                 'tag)])
+         (+ 1 (call/prompt (lambda () (k 11)) 'tag)))
        12)
 (check (let ([k (call/prompt
                  (lambda ()
@@ -43,20 +44,42 @@
                       (+ 1
                          (* 2
                             (call/cc
-                             (lambda (k) (esc k)))))))))])
-         (list (call/prompt (lambda () (k 3)))
-               (call/prompt (lambda () (k 4)))))
+                             (lambda (k) (esc k))))))))
+                 'tag)])
+         (list (call/prompt (lambda () (k 3)) 'tag)
+               (call/prompt (lambda () (k 4)) 'tag)))
        (list 7 9))
-(check-fail (call/prompt 1) "not a procedure")
+(check-fail (call/prompt 1 'tag) "not a procedure")
+(check-fail (call/prompt void 7) "not a symbol")
 
-(check (let ([k (call/prompt
-                 (lambda ()
-                   (call/cc
-                    (lambda (esc)
-                      (+ 1
-                         (* 2
-                            (call/comp esc)))))))])
-         (list (k 30)
-               (k 40)))
-       (list 61 81))
-(check-arg-fail (call/comp 1) "not a procedure")
+(check (continuation-prompt-available? 'tag) #f)
+(check (call/prompt (lambda ()
+                      (continuation-prompt-available? 'tag))
+                    'tag)
+       #t)
+(check (call/prompt (lambda ()
+                      (continuation-prompt-available? 'other))
+                    'tag)
+       #f)
+(check (call/prompt (lambda ()
+                      (call/prompt
+                       (lambda ()
+                         (continuation-prompt-available? 'tag))
+                       'other))
+                    'tag)
+       #f)
+(check (call/prompt (lambda ()
+                      (call/prompt
+                       (lambda ()
+                         (continuation-prompt-available? 'other))
+                       'other))
+                    'tag)
+       #t)
+(check (call/prompt (lambda ()
+                      (list (call/prompt
+                             (lambda ()
+                               (continuation-prompt-available? 'other))
+                             'other)
+                            (continuation-prompt-available? 'tag)))
+                    'tag)
+       '(#t #t))
--- a/zuo.c
+++ b/zuo.c
@@ -1851,7 +1851,7 @@
 }
 
 static int all_digits_before_delim(const unsigned char *s, zuo_int_t i) {
-  while (isdigit(s[i]) || isalpha(s[i]) || strchr(symbol_chars, s[i])) {
+  while (s[i] && (isdigit(s[i]) || isalpha(s[i]) || strchr(symbol_chars, s[i]))) {
     if (!isdigit(s[i]))
       return 0;
     i++;
@@ -6644,7 +6644,7 @@
 # endif
     if (boot_image) {
       /* The image supplies constants and tables */
-      zuo_raw_handle_t in = zuo_fd_open_input_handle(zuo_string(boot_image), z.o_empty_hash);
+      zuo_raw_handle_t in = zuo_fd_open_input_handle(zuo_string(boot_image), zuo_trie_node());
       zuo_t *dump = zuo_drain(in, -1);
       zuo_close_handle(in);
       zuo_fasl_restore(ZUO_STRING_PTR(dump), ZUO_STRING_LEN(dump));