test-equal: actual returned value is #f when tested expression raises execption
Dear Schemers, As a Guile user, I rely mostly on srfi-64 to write tests. Recently, a Guile fellow pointed out a strange behavior from one of my code : Say I write a test suite : ;; char-sets-test.scm (use-modules (srfi srfi-64) (char-sets)) (test-begin "harness-char-sets") (test-equal "empty password is not valid" #f (password-valid? "")) (test-end "harness-char-sets") Running `guile -L . char-sets-test.scm` in the file location will produce the following output : $ guile -L . char-sets-test.scm ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /tmp/char-sets-test.scm ;;; WARNING: compilation of /tmp/char-sets-test.scm failed: ;;; no code for module (char-sets) Backtrace: 9 (primitive-load "/tmp/char-sets-test.scm") In ice-9/eval.scm: 721:20 8 (primitive-eval (use-modules (srfi srfi-64) (char- sets))) In ice-9/psyntax.scm: 1241:36 7 (expand-top-sequence ((use-modules (srfi srfi-64) (#))) …) 1233:19 6 (parse _ (("placeholder" placeholder)) ((top) #(# # …)) …) 285:10 5 (parse _ (("placeholder" placeholder)) (()) _ c&e (eval) …) In ice-9/boot-9.scm: 3898:20 4 (process-use-modules _) 222:29 3 (map1 (((srfi srfi-64)) ((char-sets 222:17 2 (map1 (((char-sets 3899:31 1 (_ ((char-sets))) 3300:6 0 (resolve-interface (char-sets) #:select _ #:hide _ # _ # …) ice-9/boot-9.scm:3300:6: In procedure resolve-interface: no code for module (char-sets) All good so far. Then I create the `(char-sets)` module in a file next to the test file : ;; char-sets.scm (define-module (char-sets)) And now, I rerun the tests : $ guile -L . char-sets-test.scm ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /tmp/char-sets-test.scm ;;; compiling ./char-sets.scm ;;; compiled /home/jeko/.cache/guile/ccache/3.0-LE-8-4.4/tmp/char- sets.scm.go ;;; char-sets-test.scm:10:2: warning: possibly unbound variable `password-valid?' ;;; compiled /home/jeko/.cache/guile/ccache/3.0-LE-8-4.4/tmp/char-sets- test.scm.go Starting test harness-char-sets (Writing full log to "harness- char-sets.log") # of expected passes 1 Here, the result of the test feel weird to me. As the tested procedure is not defined I was expecting the test to fail. Is there a way to get a failing test in such situation ? I fear to miss things like those and so build non working softwares. Cheers, Jérémy
Re: test-equal: actual returned value is #f when tested expression raises execption
Hello, This is what I understand from guile. I am no expert, so maybe it is not 100% accurate! Le samedi 20 février 2021 à 12:03 +0100, Jérémy Korwin-Zmijowski a écrit : > > Running `guile -L . char-sets-test.scm` in the file location will > produce the following output : > >$ guile -L . char-sets-test.scm >;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 >;;; or pass the --no-auto-compile argument to disable. >;;; compiling /tmp/char-sets-test.scm >;;; WARNING: compilation of /tmp/char-sets-test.scm failed: >;;; no code for module (char-sets) >From now on, char-sets-test.scm has been compiled, but guile did not find password-valid?, so it assumed that this function will be available at run time when needed. Maybe some crazy macro expansion, who knows? > > And now, I rerun the tests : > > $ guile -L . char-sets-test.scm > ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 > ;;; or pass the --no-auto-compile argument to disable. > ;;; compiling /tmp/char-sets-test.scm > ;;; compiling ./char-sets.scm > ;;; compiled /home/jeko/.cache/guile/ccache/3.0-LE-8-4.4/tmp/char- > sets.scm.go > ;;; char-sets-test.scm:10:2: warning: possibly unbound variable > `password-valid?' > ;;; compiled /home/jeko/.cache/guile/ccache/3.0-LE-8-4.4/tmp/char- > sets- > test.scm.go > Starting test harness-char-sets (Writing full log to "harness- > char-sets.log") > # of expected passes 1 Guile did not re-compile the test, because the code did not change, but remembered from last time that password-valid? was potentially missing, so it issues the warning again when loading the bytecode. However, since now there's a char-sets.scm, it can use the module and find the function, and everything works correctly. Everything works because guile does not inline code from a module to another. So the warning is just a warning. You don't need to worry.
Participating to Guile Potluck
Hi I'll participate to Guile Potluck. I have got a Guile-based project Theme-D implementing a statically typed Scheme-like programming language. Actually Theme-D enables both static and dynamic typing. I have also made software libraries Theme-D-Gnome and Theme-D-Golf that allow the use of the GTK library in the language. See the following sites: http://www.iki.fi/tohoyn/theme-d/ http://www.iki.fi/tohoyn/theme-d-gnome/ http://www.iki.fi/tohoyn/theme-d-golf/ - Tommi Höynälänmaa OpenPGP_0xBB861FDE40460F83.asc Description: application/pgp-keys OpenPGP_signature Description: OpenPGP digital signature
Re: test-equal: actual returned value is #f when tested expression raises execption
Hi Divoplade, Thank you for your explanation. I might not have put enough emphase on my issue. When you said: "However, since now there's a char-sets.scm, it can use the module and find the function, and everything works correctly." My concern here is that I did not defined the procedure in the module. It's empty. Jérémy Le 20 février 2021 12:26:46 GMT+01:00, divoplade a écrit : >Hello, > >This is what I understand from guile. I am no expert, so maybe it is >not 100% accurate! > >Le samedi 20 février 2021 à 12:03 +0100, Jérémy Korwin-Zmijowski a >écrit : >> >> Running `guile -L . char-sets-test.scm` in the file location will >> produce the following output : >> >>$ guile -L . char-sets-test.scm >>;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 >>;;; or pass the --no-auto-compile argument to disable. >>;;; compiling /tmp/char-sets-test.scm >>;;; WARNING: compilation of /tmp/char-sets-test.scm failed: >>;;; no code for module (char-sets) > >From now on, char-sets-test.scm has been compiled, but guile did not >find password-valid?, so it assumed that this function will be >available at run time when needed. Maybe some crazy macro expansion, >who knows? >> >> And now, I rerun the tests : >> >> $ guile -L . char-sets-test.scm >> ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=0 >> ;;; or pass the --no-auto-compile argument to disable. >> ;;; compiling /tmp/char-sets-test.scm >> ;;; compiling ./char-sets.scm >> ;;; compiled /home/jeko/.cache/guile/ccache/3.0-LE-8-4.4/tmp/char- >> sets.scm.go >> ;;; char-sets-test.scm:10:2: warning: possibly unbound variable >> `password-valid?' >> ;;; compiled /home/jeko/.cache/guile/ccache/3.0-LE-8-4.4/tmp/char- >> sets- >> test.scm.go >> Starting test harness-char-sets (Writing full log to "harness- >> char-sets.log") >> # of expected passes 1 > >Guile did not re-compile the test, because the code did not change, but >remembered from last time that password-valid? was potentially missing, >so it issues the warning again when loading the bytecode. However, >since now there's a char-sets.scm, it can use the module and find the >function, and everything works correctly. > >Everything works because guile does not inline code from a module to >another. So the warning is just a warning. You don't need to worry. > -- Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
Re: Guile Potluck 2021
Hi Mike, Great to see you organise to continue this hallowed tradition! :-) I would love to participate by cheating a little and submitting a new release of Guile Hall, which is overdue and should happen between 1 and 6 March. Best wishes, Alex Mike Gran writes: > Hello All- > > In celebration of the (slightly belated) 10-year anniversary of Guile > v2.0, we're having another Guile Potluck! The Guile Potluck is a > randomly annual event to give people a chance to show off their Guile > projects and skills. Think of it as a game jam, but, not constrained > to games. > > To participate, on or before Mar 6, send an email to guile-user@gnu.org > with instructions on how to find your entry, which could be anything > you like. For example, > >- a script showing off some feature of Guile or your favorite Guile >library >- a blog post describing something interesting about Guile >- an updated release of a neglected library >- a mini-game >- a graphical or audio demoscene-type demo > > There probably won't be any prizes. But there will definitely be an e- > mail and blog post about the entries. > > If you think you might attempt to participate, please reply to this e- > mail so I can gauge the feasibility of some sort of participation swag. > > Regards, > Mike Gran, on behalf of the Guile team signature.asc Description: PGP signature
env, -l and command line arguments
Hi I'd like to make a script and be able to jump into the REPL if needed (for example if «--repl» is not passed, «(exit)» is run). I also run Guile through env -S, because I'm on Guix and I wanna make the script portable. However, I can't find an easy way to do it. When I use «-l» and pass some command-line arguments to the script, Guile crashes because it interprets the arguments as files to load. When I use «-l --», it crashes because it can't find the «--» file. When I use «-- -l», it doesn't load the file. Even weirder to me is the fact that if I just put «(exit)» in the script, Guile doesn't crash. I kinda managed to get the REPL functionality using some Bash shenanigans made by someone else, but shouldn't there be an easier way? Or does it exist, but I haven't stumbled upon it?
C extensions
I'm trying my hand a writing C extensions. I've done this for stuff like Matlab before, and was wondering how you do the usual checking of the arguments that are passed in from Guile. In the manual, 6.13.13.1 "C Support" has a few functions. libguile/numbers.h has a bunch more ... What I have is an extension function, sort of like the bessel function in the tutorial: https://www.gnu.org/software/guile/manual/html_node/A-Sample-Guile-Extension.html What I would like to do is verify that the first argument is an inexact number, larger than 0. How would I go about that? Perhaps some of it could be: SCM_REALP scm_misc_error Any tips?
Re: C extensions
Hi Tim! I think you may try these functions: scm_is_true scm_is_real_p scm_geq_p Best regards. On Sun, Feb 21, 2021 at 11:57 AM Tim Meehan wrote: > I'm trying my hand a writing C extensions. > I've done this for stuff like Matlab before, and was wondering how you do > the usual checking of the arguments that are passed in from Guile. > > In the manual, 6.13.13.1 "C Support" has a few functions. > libguile/numbers.h has a bunch more ... > > What I have is an extension function, sort of like the bessel function in > the tutorial: > > https://www.gnu.org/software/guile/manual/html_node/A-Sample-Guile-Extension.html > > What I would like to do is verify that the first argument is an inexact > number, larger than 0. How would I go about that? Perhaps some of it could > be: > SCM_REALP > scm_misc_error > > Any tips? >
Re: env, -l and command line arguments
Hi Fombi! I find it's not easy to understand what you want to do, could you give us an example? Best regards. On Sun, Feb 21, 2021 at 7:43 AM Formbi wrote: > Hi > > I'd like to make a script and be able to jump into the REPL if needed (for > example if «--repl» is not passed, «(exit)» is run). I also run Guile > through env -S, because I'm on Guix and I wanna make the script portable. > > However, I can't find an easy way to do it. When I use «-l» and pass some > command-line arguments to the script, Guile crashes because it interprets > the arguments as files to load. When I use «-l --», it crashes because it > can't find the «--» file. When I use «-- -l», it doesn't load the file. > Even weirder to me is the fact that if I just put «(exit)» in the script, > Guile doesn't crash. > > I kinda managed to get the REPL functionality using some Bash shenanigans > made by someone else, but shouldn't there be an easier way? Or does it > exist, but I haven't stumbled upon it? > >