Re: [racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread Ryan Culpepper
On 2/23/18 3:36 PM, 'Paulo Matos' via Racket Users wrote: On 23/02/18 15:13, 'Paulo Matos' via Racket Users wrote: That's true, thanks for pointing it out. I only just noticed you could generate test-suites and test-cases at runtime with make-testcase and make-testsuite. Therefore I will

Re: [racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread 'Paulo Matos' via Racket Users
On 23/02/18 15:13, 'Paulo Matos' via Racket Users wrote: > That's true, thanks for pointing it out. I only just noticed you could > generate test-suites and test-cases at runtime with make-testcase and > make-testsuite. Therefore I will actually be doing this without a macro. > However, it's

Re: [racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread 'Paulo Matos' via Racket Users
On 23/02/18 15:20, Philip McGrath wrote: > The "Introduction" from the syntax/parse docs > (http://docs.racket-lang.org/syntax/stxparse-intro.html), is very good > in the spirit of the Racket Guide and also explains why you want to use > syntax/parse. Between that and the "Examples" section, I

Re: [racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread Philip McGrath
The "Introduction" from the syntax/parse docs ( http://docs.racket-lang.org/syntax/stxparse-intro.html), is very good in the spirit of the Racket Guide and also explains why you want to use syntax/parse. Between that and the "Examples" section, I found I could handle many of the cases I wanted to

Re: [racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread 'Paulo Matos' via Racket Users
On 23/02/18 15:07, Philip McGrath wrote: > > I also used syntax-parse to conveniently check that n really is a > nonnegative integer literal, though of course you could write such a > check with syntax-case if you really wanted to. > Thanks for the code snippet which goes in the same

Re: [racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread 'Paulo Matos' via Racket Users
On 23/02/18 14:56, Matthew Butterick wrote: > >> On Feb 23, 2018, at 5:11 AM, 'Paulo Matos' via Racket Users >> wrote: >> >> This fails because the i in the body of the test case does not exist at >> run-time. I understand why this is failing. However if I try

Re: [racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread Philip McGrath
Here is a version that works, with explanation following: #lang racket (require rackunit rackunit/text-ui (for-syntax syntax/parse)) (define-syntax gen-testsuite (syntax-parser [(_ n:exact-nonnegative-integer) #`(test-suite "Automated suite"

Re: [racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread Matthew Butterick
> On Feb 23, 2018, at 5:11 AM, 'Paulo Matos' via Racket Users > wrote: > > This fails because the i in the body of the test case does not exist at > run-time. I understand why this is failing. However if I try to replace > the i by #,(syntax->datum #'i) it also

[racket-users] Generating automatic testsuites using a macro

2018-02-23 Thread 'Paulo Matos' via Racket Users
Hi, I am trying to get a macro working to generate an automatic testsuite. I have shrank my example to: #lang racket (define-syntax (gen-testsuite stx) (syntax-case stx () [(_ n) #`(test-suite "Automated suite" #,@(for/list ([i (syntax->datum #'n)])