mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: deprecate write_str and replace it with write_string (#9369)
This commit is contained in:
@@ -30,7 +30,7 @@ fn test_socket() {
|
||||
cleanup(mut server, mut client, mut socket)
|
||||
}
|
||||
message := 'Hello World'
|
||||
socket.write_str(message) or {
|
||||
socket.write_string(message) or {
|
||||
assert false
|
||||
return
|
||||
}
|
||||
@@ -62,7 +62,7 @@ fn test_socket_write_and_read() {
|
||||
cleanup(mut server, mut client, mut socket)
|
||||
}
|
||||
message1 := 'a message 1'
|
||||
socket.write_str(message1) or { assert false }
|
||||
socket.write_string(message1) or { assert false }
|
||||
mut rbuf := []byte{len: message1.len}
|
||||
client.read(mut rbuf) or {
|
||||
assert false
|
||||
@@ -82,7 +82,7 @@ fn test_socket_read_line() {
|
||||
}
|
||||
message1, message2 := 'message1', 'message2'
|
||||
message := '$message1\n$message2\n'
|
||||
socket.write_str(message) or { assert false }
|
||||
socket.write_string(message) or { assert false }
|
||||
assert true
|
||||
//
|
||||
line1 := reader.read_line() or {
|
||||
@@ -114,7 +114,7 @@ fn test_socket_write_fail_without_panic() {
|
||||
}
|
||||
// TODO: fix segfaulting on Solaris
|
||||
for i := 0; i < 3; i++ {
|
||||
socket.write_str(message2) or {
|
||||
socket.write_string(message2) or {
|
||||
println('write to a socket without a recipient should produce an option fail: $err | $message2')
|
||||
assert true
|
||||
}
|
||||
@@ -130,11 +130,11 @@ fn test_socket_read_line_long_line_without_eol() {
|
||||
cleanup(mut server, mut client, mut socket)
|
||||
}
|
||||
message := strings.repeat_string('123', 400)
|
||||
socket.write_str(message) or {
|
||||
socket.write_string(message) or {
|
||||
assert false
|
||||
return
|
||||
}
|
||||
socket.write_str('\n') or {
|
||||
socket.write_string('\n') or {
|
||||
assert false
|
||||
return
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ fn echo() ? {
|
||||
c.close() or { }
|
||||
}
|
||||
data := 'Hello from vlib/net!'
|
||||
c.write_str(data) ?
|
||||
c.write_string(data) ?
|
||||
mut buf := []byte{len: 4096}
|
||||
read := c.read(mut buf) ?
|
||||
assert read == data.len
|
||||
|
||||
@@ -54,7 +54,12 @@ pub fn (mut c UdpConn) write(buf []byte) ?int {
|
||||
return c.write_ptr(buf.data, buf.len)
|
||||
}
|
||||
|
||||
[deprecated: 'use UdpConn.write_string() instead']
|
||||
pub fn (mut c UdpConn) write_str(s string) ?int {
|
||||
return c.write_string(s)
|
||||
}
|
||||
|
||||
pub fn (mut c UdpConn) write_string(s string) ?int {
|
||||
return c.write_ptr(s.str, s.len)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ fn echo() ? {
|
||||
}
|
||||
data := 'Hello from vlib/net!'
|
||||
|
||||
c.write_str(data) ?
|
||||
c.write_string(data) ?
|
||||
|
||||
mut buf := []byte{len: 100, init: 0}
|
||||
read, addr := c.read(mut buf) ?
|
||||
|
||||
@@ -204,7 +204,13 @@ pub fn (mut c StreamConn) write(bytes []byte) ?int {
|
||||
}
|
||||
|
||||
// write_str blocks and attempts to write all data
|
||||
[deprecated: 'use StreamConn.write_string() instead']
|
||||
pub fn (mut c StreamConn) write_str(s string) ?int {
|
||||
return c.write_string(s)
|
||||
}
|
||||
|
||||
// write_string blocks and attempts to write all data
|
||||
pub fn (mut c StreamConn) write_string(s string) ?int {
|
||||
return c.write_ptr(s.str, s.len)
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ fn echo() ? {
|
||||
c.close() or { }
|
||||
}
|
||||
data := 'Hello from vlib/net!'
|
||||
c.write_str(data) ?
|
||||
c.write_string(data) ?
|
||||
mut buf := []byte{len: 4096}
|
||||
read := c.read(mut buf) ?
|
||||
assert read == data.len
|
||||
|
||||
Reference in New Issue
Block a user