diff --git a/test/regexp-fail.rkt b/test/regexp-fail.rkt index 81ca8e7..578d6c8 100644 --- a/test/regexp-fail.rkt +++ b/test/regexp-fail.rkt @@ -40,20 +40,34 @@ ;; --- can't handle starred groups (ann (regexp-match: "(a)*(b)" "b") (U #f (List String String))) -) (test-compile-error - #:require trivial/regexp - #:exn #rx"mutation not allowed" - ;; -- set! problems - (ann (let-regexp: ([a #rx"(b)(B)"]) - (set! a #rx"") - (regexp-match: a "hai")) - (List String String String)) - (let () - (define-regexp: a #rx"h(i)") - (set! a #rx"hi") - (regexp-match a "hi")) +) - (let-regexp: ([a #rx"h(i)"]) - (set! a #rx"(h)(i)") - (regexp-match a "hi")) -)) +(test-compile-error + #:require trivial/regexp racket/port + #:exn #rx"Type Checker" + ;; -- expected String, given Bytes + (with-input-from-string "hello" + (lambda () + (define m (regexp-match #rx#"lang" (current-input-port))) + (and m (string=? (car m) "lang")))) +) + +;; 2016-06-13 : these really should be errors, just no-opts +;(test-compile-error +; #:require trivial/regexp +; #:exn #rx"mutation not allowed" +; ;; -- set! problems +; (ann (let-regexp: ([a #rx"(b)(B)"]) +; (set! a #rx"") +; (regexp-match: a "hai")) +; (List String String String)) +; (let () +; (define-regexp: a #rx"h(i)") +; (set! a #rx"hi") +; (regexp-match a "hi")) +; +; (let-regexp: ([a #rx"h(i)"]) +; (set! a #rx"(h)(i)") +; (regexp-match a "hi")) +;) +) diff --git a/test/regexp-pass.rkt b/test/regexp-pass.rkt index 1e42ac8..4e25382 100644 --- a/test/regexp-pass.rkt +++ b/test/regexp-pass.rkt @@ -8,11 +8,18 @@ trivial/regexp typed/rackunit) - ;; -- TODO + ;; -- TODO (handle regexp . format) ; (define re:normal-name (regexp (format "~a*<([^>]*)>~a*" blank blank))) ;; -- regexps, from the world + (let ([str + + (let () ;; -- from klocker? anyway the unicode will segfault `unsafe-string-ref` + (check-equal? + (ann (regexp-match: #rx"⇒" "yolo") (U #f (List String))) + #f)) + (let ([str "dont care"]) ;; from `tests/racket/contract/multi-file.rkt` (check-equal? (ann diff --git a/trivial/private/parameters.rkt b/trivial/private/parameters.rkt index 37bab4c..ef01dc3 100644 --- a/trivial/private/parameters.rkt +++ b/trivial/private/parameters.rkt @@ -9,7 +9,7 @@ ;; ============================================================================= (: *TRIVIAL-LOG* (Parameterof Boolean)) -(define *TRIVIAL-LOG* (make-parameter #t)) +(define *TRIVIAL-LOG* (make-parameter #f)) (: *STOP-LIST* (Parameterof (Listof Identifier))) (define *STOP-LIST* (make-parameter '())) diff --git a/trivial/private/regexp.rkt b/trivial/private/regexp.rkt index e68a28f..949329d 100644 --- a/trivial/private/regexp.rkt +++ b/trivial/private/regexp.rkt @@ -34,7 +34,6 @@ typed/racket/base (only-in racket/list range) (only-in racket/format ~a) - (only-in racket/unsafe/ops unsafe-string-ref) syntax/parse trivial/private/common)) @@ -155,7 +154,7 @@ (define h-rev (for/fold ([hist (for/hasheq ([c (in-list c*)]) (values c '()))]) ([i (in-range L)]) - (define char (unsafe-string-ref str i)) + (define char (string-ref str i)) (cond [(unbox escaped?) (when (or (not (eq? #\\ char))