dylan-lang / http

HTTP server and client for Dylan
https://opendylan.org/package/http
MIT License
22 stars 11 forks source link

http-common media type test #22

Closed fracek closed 11 years ago

fracek commented 11 years ago

Running the http-common test suite fails. The errors are:

  1. errors-test-suite not implemented
  2. test-match-media-types failed

The test suite expects

match-media-types(text/plain, make-media-type("text", "html"))
match-media-types(text/plain, make-media-type($mime-wild, "html"))

to be #f, but if we look at the definition of match-media-types we can read:

// Returns the degree to which the two media types match, or #f if they
// don't match at all.  Points are assigned as follows:
// * 100 - major mime type matches exactly (not a wildcard match)
// * 100 - mime subtype matches exactly (not a wildcard match)
// * 1 - wildcard match for type or subtype
// * 1 - for each attribute (excluding "q") that matches exactly
// Matching type/subtype trumps all else.

And indeed the first media type matches the mime type (and it gets a score of 100) while the second one matches the wildcard for the mime type (and it gets a score of 1).

So who should I trust? The test suite (and change the function accordingly) or the function (and change the test suite)?

waywardmonkeys commented 11 years ago

I would say the test is wrong, code is right. @cgay can confirm though.