mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: remove space in front of ? and ! (#14366)
This commit is contained in:
@@ -111,15 +111,15 @@ fn test_a_simple_tcp_client_html_page() {
|
||||
// net.http client based tests follow:
|
||||
fn assert_common_http_headers(x http.Response) ? {
|
||||
assert x.status() == .ok
|
||||
assert x.header.get(.server) ? == 'VWeb'
|
||||
assert x.header.get(.content_length) ?.int() > 0
|
||||
assert x.header.get(.connection) ? == 'close'
|
||||
assert x.header.get(.server)? == 'VWeb'
|
||||
assert x.header.get(.content_length)?.int() > 0
|
||||
assert x.header.get(.connection)? == 'close'
|
||||
}
|
||||
|
||||
fn test_http_client_index() ? {
|
||||
x := http.get('http://$localserver/') or { panic(err) }
|
||||
assert_common_http_headers(x) ?
|
||||
assert x.header.get(.content_type) ? == 'text/plain'
|
||||
assert_common_http_headers(x)?
|
||||
assert x.header.get(.content_type)? == 'text/plain'
|
||||
assert x.text == 'Welcome to VWeb'
|
||||
}
|
||||
|
||||
@@ -137,35 +137,35 @@ fn test_http_client_404() ? {
|
||||
|
||||
fn test_http_client_simple() ? {
|
||||
x := http.get('http://$localserver/simple') or { panic(err) }
|
||||
assert_common_http_headers(x) ?
|
||||
assert x.header.get(.content_type) ? == 'text/plain'
|
||||
assert_common_http_headers(x)?
|
||||
assert x.header.get(.content_type)? == 'text/plain'
|
||||
assert x.text == 'A simple result'
|
||||
}
|
||||
|
||||
fn test_http_client_html_page() ? {
|
||||
x := http.get('http://$localserver/html_page') or { panic(err) }
|
||||
assert_common_http_headers(x) ?
|
||||
assert x.header.get(.content_type) ? == 'text/html'
|
||||
assert_common_http_headers(x)?
|
||||
assert x.header.get(.content_type)? == 'text/html'
|
||||
assert x.text == '<h1>ok</h1>'
|
||||
}
|
||||
|
||||
fn test_http_client_settings_page() ? {
|
||||
x := http.get('http://$localserver/bilbo/settings') or { panic(err) }
|
||||
assert_common_http_headers(x) ?
|
||||
assert_common_http_headers(x)?
|
||||
assert x.text == 'username: bilbo'
|
||||
//
|
||||
y := http.get('http://$localserver/kent/settings') or { panic(err) }
|
||||
assert_common_http_headers(y) ?
|
||||
assert_common_http_headers(y)?
|
||||
assert y.text == 'username: kent'
|
||||
}
|
||||
|
||||
fn test_http_client_user_repo_settings_page() ? {
|
||||
x := http.get('http://$localserver/bilbo/gostamp/settings') or { panic(err) }
|
||||
assert_common_http_headers(x) ?
|
||||
assert_common_http_headers(x)?
|
||||
assert x.text == 'username: bilbo | repository: gostamp'
|
||||
//
|
||||
y := http.get('http://$localserver/kent/golang/settings') or { panic(err) }
|
||||
assert_common_http_headers(y) ?
|
||||
assert_common_http_headers(y)?
|
||||
assert y.text == 'username: kent | repository: golang'
|
||||
//
|
||||
z := http.get('http://$localserver/missing/golang/settings') or { panic(err) }
|
||||
@@ -187,7 +187,7 @@ fn test_http_client_json_post() ? {
|
||||
$if debug_net_socket_client ? {
|
||||
eprintln('/json_echo endpoint response: $x')
|
||||
}
|
||||
assert x.header.get(.content_type) ? == 'application/json'
|
||||
assert x.header.get(.content_type)? == 'application/json'
|
||||
assert x.text == json_for_ouser
|
||||
nuser := json.decode(User, x.text) or { User{} }
|
||||
assert '$ouser' == '$nuser'
|
||||
@@ -196,7 +196,7 @@ fn test_http_client_json_post() ? {
|
||||
$if debug_net_socket_client ? {
|
||||
eprintln('/json endpoint response: $x')
|
||||
}
|
||||
assert x.header.get(.content_type) ? == 'application/json'
|
||||
assert x.header.get(.content_type)? == 'application/json'
|
||||
assert x.text == json_for_ouser
|
||||
nuser2 := json.decode(User, x.text) or { User{} }
|
||||
assert '$ouser' == '$nuser2'
|
||||
@@ -221,7 +221,7 @@ $contents\r
|
||||
value: ct
|
||||
)
|
||||
data: data
|
||||
) ?
|
||||
)?
|
||||
$if debug_net_socket_client ? {
|
||||
eprintln('/form_echo endpoint response: $x')
|
||||
}
|
||||
@@ -292,8 +292,8 @@ $config.content'
|
||||
$if debug_net_socket_client ? {
|
||||
eprintln('sending:\n$message')
|
||||
}
|
||||
client.write(message.bytes()) ?
|
||||
read := io.read_all(reader: client) ?
|
||||
client.write(message.bytes())?
|
||||
read := io.read_all(reader: client)?
|
||||
$if debug_net_socket_client ? {
|
||||
eprintln('received:\n$read')
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ fn main() {
|
||||
global_config: config
|
||||
}
|
||||
eprintln('>> webserver: started on http://localhost:$app.port/ , with maximum runtime of $app.timeout milliseconds.')
|
||||
vweb.run_at(app, host: 'localhost', port: http_port, family: .ip) ?
|
||||
vweb.run_at(app, host: 'localhost', port: http_port, family: .ip)?
|
||||
}
|
||||
|
||||
// pub fn (mut app App) init_server() {
|
||||
|
Reference in New Issue
Block a user