[racket-users] Organizing tests in project

2020-03-17 Thread Siddhartha Kasivajhula
Hi,
I'm attempting to organize tests in my package into subfolders/modules
instead of having them in a giant main.rkt test submodule, but am running
into some issues and was hoping for some advice on the best way to do it. I
think the primary issue is related to source compilation order in raco, but
am also curious how other people organize their tests.

I've moved all of the tests into a tests/ subfolder in the main project
tree. When I build the project using raco setup, it builds both the project
files as well as the tests contained in the tests/ folder. At this point,
if I run the tests as is, they result in an error. If instead I first
delete the compiled/ subfolder in the tests folder, the tests then work
fine.

I think the tests may be getting compiled against the version of the
compiled collection which is immediately replaced by a fresh compilation
during raco setup. This is the error I'm seeing when I run the tests:

default-load-handler: expected a `module' declaration, but found something
else
  file:
/Users/siddhartha/work/lisp/racket/relation/tests/compiled/algebraic-test_rkt.dep
  context...:
   default-load-handler
   standard-module-name-resolver
   module-path-index-resolve
   module-declared?

I could add a make target to clean the test compiled folder prior to
running tests, but it seemed like there must be a better way. So my main
questions are:

1. Is there a way to exclude certain folders (such as tests) in the raco
setup stage? For reference, the command I'm using is raco setup --no-docs
--tidy --pkgs relation.
2. Is this a good way to organize tests? Are there any standard recommended
ways?

Would appreciate any input,
-Sid

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CACQBWF%3D5iwYRCOgwEmwNSh27QzpfE1pjFqvzzB_1KNs3zgHX5g%40mail.gmail.com.


[racket-users] [ANN] Template Macros: A Toolkit for the Practicing Language-Oriented Programmer

2020-03-17 Thread Eric Griffis
Hello,

I'm pleased to announce the initial release of *Template Macros*, a Racket
library that dramatically simplifies the generation of meta-program code.

https://github.com/dedbox/racket-template

Template macros infiltrate the spaces under-served by Racket's existing
pattern-based and procedural macros, such as the insides of literal data,

  > (with-template ([X 1] [Y 2]) (values XY3 "YX0" #rx"^X+Y$"))
>   123
>   "210"
>   #rx"^1+2$"
>

or in the various quoted forms;

  > (begin-template #'(untemplate (build-list 10 values)))
>   #
>

and when one template macro is used by another, the results are spliced in
place automatically.

  > (begin-template (list (for/template ([K (in-range 10)]) K)))
>   '(0 1 2 3 4 5 6 7 8 9)
>

Template macros eliminate common technical barriers to advanced Racket
meta-programming techniques by preempting the default macro expander. The
current API offers a lot more than I could jam into a release announcement,
and it's still evolving!

In the coming weeks and months, I'll try to post some topic-focused
tutorials that highlight the wealth of functionality template macros
provide to the practicing language-oriented Racket programmer.

But the next time you trip on a missing syntax-local-introduce,

  > (define-template (urlang-js modpath)
>   (let ()
> (local-require (only-in modpath the-javascript))
> (the-javascript)))
>

or find yourself facing a wall of format-id's,

  > (for*/template ([M (in-range 1 6)]
> [N (in-range 1 6)])
>   (define idMxN '((for/template ([I (in-range 1 (add1 M))])
> (vector (for/template ([J (in-range 1 (add1 N))])
>   (if-template (= I J) 1 0))
>   (when-template (= M N)
> (define idM idMxN)))
>   > id5
>   '((vector 1 0 0 0 0)
> (vector 0 1 0 0 0)
> (vector 0 0 1 0 0)
> (vector 0 0 0 1 0)
> (vector 0 0 0 0 1))
>

or struggle to interleave a medley

of functions with "syntax" in their names,

  > (define-template (hyphen-define* Names Args Body)
>   (define
> #,(string->symbol (string-join (map symbol->string 'Names) "-"))
> (λ Args Body)))
>   > (hyphen-define* (foo bar baz) (v) (* 2 v))
>   > (foo-bar-baz 50)
>   100
>

give template macros a try and let me know how it goes!

Eric

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAORuSUyQ0mU_GR4JgS%3De6Sh9W_Uefk_FxxZn2Z6whb6YyjwYPg%40mail.gmail.com.