Skip to content

Commit

Permalink
tests: add a test for short enum syntax across modules (related #12183)…
Browse files Browse the repository at this point in the history
… (#22210)
  • Loading branch information
yuyi98 authored Sep 13, 2024
1 parent 277e5eb commit cc7665f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/http_server.v
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module main

import net.http { CommonHeader, Request, Response, Server }
import net.http { Request, Response, Server }

struct ExampleHandler {}

fn (h ExampleHandler) handle(req Request) Response {
mut res := Response{
header: http.new_header_from_map({
CommonHeader.content_type: 'text/plain'
.content_type: 'text/plain'
})
}
mut status_code := 200
Expand Down
10 changes: 10 additions & 0 deletions vlib/v/tests/enums/short_enum_syntax_across_module_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import net.http

fn test_short_enum_syntax_across_module() {
header := http.new_header_from_map({
.content_type: 'application/json'
})

println(header)
assert true
}
4 changes: 2 additions & 2 deletions vlib/vweb/vweb.v
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ pub fn (mut ctx Context) send_response_to_client(mimetype string, res string) bo
}
// build the header after the potential modification of resp.body from above
header := http.new_header_from_map({
http.CommonHeader.content_type: mimetype
http.CommonHeader.content_length: resp.body.len.str()
.content_type: mimetype
.content_length: resp.body.len.str()
}).join(ctx.header)
resp.header = header.join(headers_close)

Expand Down

0 comments on commit cc7665f

Please sign in to comment.