: Matthias Felleisen [mailto:matth...@ccs.neu.edu]
Sent: Tuesday, August 27, 2013 8:11 PM
To: George Rudolph
Cc: users@racket-lang.org
Subject: Re: [racket] Help with exception raising and testing
If your students are beginners, I urge you to use teaching languages in
DrRacket instead. Like the
On Tue, 27 Aug 2013 22:35:06 +0200, Asumu Takikawa
wrote:
In addition, the test predicate should take an exception value so
`negative?` won't work. You probably want a predicate like
`(λ (e) (regexp-match #rx"negative?" (exn-message e)))` instead.
Slightly OT:
check-exn can directly take a re
>>why a thunk?
The inferential leap to be made is that Racket uses applicative order,
meaning the arguments of a procedure are each evaluated from left-to-right
before the procedure is itself evaluated
for example:
(+ 1 (+ 2 3))
is reduced to
(+ 1 5)
before being evaluated as
6
the procedur
George, Matthias's suggestion to have students use one of the teaching
languages is generally a good idea.
For experienced programmers and software test engineers, however, there
are a number of different test engines available. Below is your program
using the Overeasy test engine, which I li
dea here?
>
> George
>
> -Original Message-
> From: Asumu Takikawa [mailto:as...@ccs.neu.edu]
> Sent: Tuesday, August 27, 2013 4:35 PM
> To: George Rudolph
> Cc: users@racket-lang.org
> Subject: Re: [racket] Help with exception raising and testing
>
&
-
From: users-boun...@racket-lang.org [mailto:users-boun...@racket-lang.org] On
Behalf Of Galler
Sent: Tuesday, August 27, 2013 4:30 PM
To: users@racket-lang.org
Subject: Re: [racket] Help with exception raising and testing
Two issues:
1: wrap the function-under-test in a thunk
2. check for
: Re: [racket] Help with exception raising and testing
On 2013-08-27 14:33:54 -0400, George Rudolph wrote:
>#lang racket
>
>(require rackunit "mybasic.rkt")
>
>(test-exn "negative coin" negative? (sum-coins -1 3 5 7) )
There is a common mistak
Also, here's a small additional bit of code to demonstrate what test-exn is
actually checking.
(require rackunit)
;pass
(test-exn "negative coin" exn:fail:contract? (λ _ (sum-coins -1 3 5 7) ))
;fail -- "Wrong exception raised"
(test-exn "negative coin" exn:fail:filesystem? (λ _ (sum-coins -1 3
On 2013-08-27 14:33:54 -0400, George Rudolph wrote:
>#lang racket
>
>(require rackunit "mybasic.rkt")
>
>(test-exn "negative coin" negative? (sum-coins -1 3 5 7) )
There is a common mistake here that myself and other Racket programmers
frequently make. The various rackunit functions th
Two issues:
1: wrap the function-under-test in a thunk
2. check for exception type, here exn:fail:contract? which is raised by
raise-argument-error. the more general exn:fail? would also work.
(require rackunit)
(test-exn "negative coin" exn:fail:contract? (λ _ (sum-coins -1 3 5 7) ))
__
I am having trouble figuring out how to write code that raises an
argument error
and code that tests for that error using rackunit.
I have the following function, which raises and exception when
pennies is negative, in a file:
---
#lang racket
(define
11 matches
Mail list logo