Hi there,

I am writing a simple macro `if-let` that tried to bind the condition to a 
variable.

```
(define-simple-macro (if-let (~describe "binding pairs" [binding:expr 
value:expr])
                             (~describe "\"then\" clause" then:expr)
                             (~describe "\"else\" clause" else:expr))
  (let ([val value])
    (if val (match-let ([binding val]) then) else)))
```

I finished the macro and start to write unit tests for it. Then I realized that
the "binding" should not working in "else" statement. That means:

```
(if-let [it #f]
  'true
  it   ; <- should report "unbound identifier".
)
```

However when I tried the following code:

```
(check-exn exn:fail?
           (lambda ()
             (if-let [it #f]
                     (fail "if-let: wrong-branch")
                     it)))

```

It gives error:

```
 it: unbound identifier in module
```

So the question is how to catch the "unbound identifier" exception for unit 
test?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to