tests: add a test for short enum syntax across modules (related #12183) (#22210)

This commit is contained in:
yuyi 2024-09-13 22:07:01 +08:00 committed by GitHub
parent 277e5eb253
commit cc7665ff32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 14 additions and 4 deletions

View File

@ -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

View File

@ -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
}

View File

@ -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)