
@pradipbn has joined the channel

Hello!

How do I make raco test
run tests in a package test/
folder and only there?

Thanks!

@contact I’m not sure of the best way, but one way is raco test test/*.rkt
.

is there something like npm test
where npm test
essentially runs a few bash scripts like tape **/*.js \| tap-spec

@contact I haven’t heard of such a thing, but I’m only a beginner myself. What doesn’t raco test test/*.rkt
do that you need?

imagine you send the message test
to the package and then it does its things… you don’t have to remember one way for each package.

so, whatever the package, you just say: $ cd pkg; raco test

There may be a more Rackety way to do it, but what I do is make a Makefile. In each directory, you have a Makefile with a target called test
, like this. Then you can do $ cd pkg; make test
in each directory.

ok! thank you very much :slightly_smiling_face:

:smile: Actually, maybe this is the Rackety way to do it: it’s using a very simple DSL that perfectly fits what you’re trying to do.

BTW, have you used Makefiles before? Specifically, do you know that the line with raco test *.rkt
must start with a tab?

If a package is installed you can raco test -p <package-name>
.

@bkovitz yes! I would rather avoid any external tool as much as possible… @greg $ raco test package/
seems to work good enough :slightly_smiling_face:

Working on a problem from a textbook I found online. “define a procedure that takes three numbers as arguments and returns the sum of the squares of the two larger numbers”
I have this so far, but not all situations are correct.
(define (sum-of-squares x y z) (cond ((> x y z) (+ (* x x) (* y y))) ((< x y) (> x z) (> y z) (+ (* x x) (* y y))) ((< x y z) (+ (* y y) (* z z))) (else (+ (* x x) (* z z))))) (sum-of-squares 4 5 6) (sum-of-squares 4 6 5) (sum-of-squares 29 14 27) (sum-of-squares 3 4 1) (sum-of-squares 27 14 29)

the second method fails

It’s possible to solve the problem using your method.

But it is hard to see if all cases have been accounted for.

An alternative is to sum all squares and subtract the square of the smallest number.

If you have a helper called min
that computes the smallest number of three inputs,

then you can write:

(- (+ (square x) (square y) (square z)) (square (min x y z)))

ah that sounds like a good plan

let me try that

Btw - in the line ((< x y) (> x z) (> y z) (+ ( *x x) (* y y)))
I think you forgot an and
: ((and (< x y) (> x z) (> y z)) (+ ( *x x) (* y y)))

I’m not sure I am logical enough to be a programmer, to be honest. I’ve been trying unsuccessfully for years with only frustration. I like LISP because it’s fun and very different that what I’ve seen, but I might just go back to writing lol.

For the record - that problem is notorious.

Countless people gets stuck on that one.

@abbyrjones72 I hope you’ll be patient with yourself. Most of programming is getting accustomed to certain ways of mentally framing things so that good ideas usually come to mind quickly. In that respect, it’s just like playing a musical instrument, cooking, writing, and every other skill. I was a commercial programmer for about 15 years, very good at coming up with object-oriented and imperative ways of making programs. I’m now learning Racket and finding it pretty slow going even though understanding the semantics of the language is pretty easy. I’m just not accustomed to how things are done in Racket. I often have to go through several clumsy versions of even fairly elementary things before I find a way to make the program that’s simple and not error-prone.

How does with-handlers
break @greg’s convention?

@soegaard2 this problem is really an issue? Well I don’t feel so bad now.

@abbyrjones72 Oh yes. It’s much harder than it looks. And since it is in SICP it has been discussed here multiple times.

I’ll look into the helper method for sure

Note that raco test -p package
works no matter what your current directory is, and it’s what the package catalog build server does for all packages

Anyone know if there is a way to use my own error report procedures if I parse use brag (My parser knowledge is only limited within the book beautiful racket, brag suit my needs but I believe I can provide better error report)? Or maybe you guys can recommend me a parser framework which provides facilities for better parse error report? I’m trying to parse a very simple language that can be written in CFG. Appreciate any help!
(P.S. My statement is not very clear about ‘better parse error report’, an example would be: - not so good one: Encountered parsing error near … - better one: only … can be written after …)