Skip to content

Conversation

@MarcKaufmann
Copy link
Contributor

Correcting the bug where only input-group had the #:wrap parameter, but not radio-group.

Again, didn't test it, as I need to figure out how to test my local branch.

@samth
Copy link
Member

samth commented Feb 14, 2016

@jeapostrophe thoughts on this? I'm likely to merge this soon to fix the test failures.

@samth
Copy link
Member

samth commented Feb 15, 2016

This still seems to have an error:

--------------------
Web Server > Formlets > Input > radio-group
radio-group
ERROR
radio-group: contract violation
  received: unexpected keyword argument #:wrap
  in: (->*
       (sequence?)
       (#:attributes
        (->
         any/c
         (listof (list/c symbol? string?)))
        #:checked?
        (-> any/c boolean?)
        #:display
        (-> any/c pretty-xexpr/c))
       (->
        integer?
        (values
         (listof pretty-xexpr/c)
         (-> (listof binding?) any/c)
         integer?)))
  contract from: 
      <pkgs>/web-server-lib/web-server/formlets/input.rkt
  blaming: <pkgs>/web-server-test/tests/web-server/formlets-test.rkt
   (assuming the contract is correct)
  at: <pkgs>/web-server-lib/web-server/formlets/input.rkt:355.2
  context...:
   /home/samth/sw/plt/racket/collects/racket/contract/private/blame.rkt:156:0: raise-blame-error16
   /home/samth/sw/plt/racket/collects/racket/contract/private/arrow.rkt:511:13: for-loop
   /home/samth/sw/plt/racket/collects/racket/contract/private/arrow.rkt:493:11: kwd-checker
   /home/samth/sw/plt/racket/collects/racket/private/kw.rkt:1585:36
   .../more-scheme.rkt:261:28
   .../more-scheme.rkt:261:28
   /home/samth/sw/plt/extra-pkgs/rackunit/rackunit-lib/rackunit/private/result.rkt:99:3
   /home/samth/sw/plt/extra-pkgs/rackunit/rackunit-lib/rackunit/private/test-suite.rkt:28:2
   the-tests
   /home/samth/sw/plt/extra-pkgs/rackunit/rackunit-lib/rackunit/private/test-suite.rkt:60:0: apply-test-suite
   run/inner
   the-tests
   /home/samth/sw/plt/extra-pkgs/rackunit/rackunit-lib/rackunit/private/test-suite.rkt:60:0: apply-test-suite
   run/inner
   the-tests
   /home/samth/sw/plt/extra-pkgs/rackunit/rackunit-lib/rackunit/private/test-suite.rkt:60:0: apply-test-suite

By the way, to run the tests, just go to the web-server-test directory of your git checkout of this repository, and run raco test .

@samth
Copy link
Member

samth commented Feb 15, 2016

Looks like the problem is that the contract for radio-group needs to change.

@MarcKaufmann
Copy link
Contributor Author

Hi Sam,

so I ran the tests (previously I drilled down to formlets and ran the tests directly, but that didn't seem to work, pulling in my local install of racket rather than the changed code). I see no errors in any of the tests, except that I have lots of "collection not found for module path tests/eli-tester" and then the whole suites seem to exit.

As for contracts, I have indeed not rewritten them, since I didn't realize this. I will try and look into this tonight (EST time), but since I have never written a contract before, I may not succeed. Will let you know.

Sorry for the extra work and thanks for catching.

Marc

@MarcKaufmann
Copy link
Contributor Author

I changed the contract of radio-group, but my tests (running raco test . in the web-server-test directory) didn't show anything wrong before or after, so clearly something is wrong with them (since the contract really was wrong). So I hope that this solves the problem, but don't know.

jeapostrophe added a commit that referenced this pull request Feb 16, 2016
Add #:wrap to radio-group (was added in input-group)
@jeapostrophe jeapostrophe merged commit 1d340ba into racket:master Feb 16, 2016
@jeapostrophe
Copy link
Contributor

Thanks Marc!

@samth
Copy link
Member

samth commented Feb 16, 2016

Unfortunately this now has a different error:

Web Server > Formlets > Input > radio-group
radio-group
ERROR
radio-group: contract violation;
 Not an Xexpr. Expected a symbol as the element name, given "1"

Context:
'("1" (input ((name "input_0") (type "radio") (value "0") (plus-one "2"))))
  in: the range of
      the #:wrap argument of
      (->*
       (sequence?)
       (#:attributes
        (->
         any/c
         (listof (list/c symbol? string?)))
        #:checked?
        (-> any/c boolean?)
        #:display
        (-> any/c pretty-xexpr/c)
        #:wrap
        (-> any/c any/c pretty-xexpr/c))
       (->
        integer?
        (values
         (listof pretty-xexpr/c)
         (-> (listof binding?) any/c)
         integer?)))
  contract from: 
      <pkgs>/web-server-lib/web-server/formlets/input.rkt
  blaming: <pkgs>/web-server-test/tests/web-server/formlets-test.rkt
   (assuming the contract is correct)
  at: <pkgs>/web-server-lib/web-server/formlets/input.rkt:355.2
  context...:
   /home/samth/sw/plt/extra-pkgs/web-server/web-server-lib/web-server/private/xexpr.rkt:22:5
   /home/samth/sw/plt/racket/collects/racket/contract/private/arrow-higher-order.rkt:382:33
   /home/samth/sw/plt/extra-pkgs/web-server/web-server-lib/web-server/formlets/input.rkt:161:13: for-loop
   /home/samth/sw/plt/extra-pkgs/web-server/web-server-lib/web-server/formlets/input.rkt:159:4
   /home/samth/sw/plt/extra-pkgs/web-server/web-server-lib/web-server/formlets/input.rkt:22:2
   ...higher-order.rkt:378:33
   /home/samth/sw/plt/extra-pkgs/web-server/web-server-lib/web-server/formlets/lib.rkt:17:2
   ...higher-order.rkt:378:33
   /home/samth/sw/plt/extra-pkgs/web-server/web-server-lib/web-server/formlets/lib.rkt:61:0: formlet-display
   /home/samth/sw/plt/racket/collects/racket/contract/private/arrow-val-first.rkt:363:18
   .../more-scheme.rkt:261:28
   /home/samth/sw/plt/extra-pkgs/web-server/web-server-test/tests/web-server/run-all-tests.rkt: [running body]

@samth
Copy link
Member

samth commented Feb 16, 2016

Looking at this more, I don't see how this can work. In particular, the default for #:wrap is (lambda (x y) (list x y)) and the function is supposed to produce an xexpr/c. But just combining two x-exprs in a list doesn't produce a new x-expr, in general.

-> (xexpr? 1)
#t
-> (xexpr? (list 1 1))
#f

The function passed to #:wrap in the test case is (lambda (x y) (list y x)) which has the same problem.

@jeapostrophe
Copy link
Contributor

Yes sorry for missing that. It should return an xexpr-forest/c. That's what all the formlet functions return and that's what wrap should return also.

@MarcKaufmann
Copy link
Contributor Author

OK, I created a new pull request #11 , this time the contract states (listof pretty-xexpr/c) which I hope is correct.

I will try to figure out a way to run tests on my local branch (some seem to run, but others fail when trying to load various modules - maybe I just need to install them). Sorry that it led to so much back and forth on a tiny issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants