From e3f7681e89a4f1bafd5fd349269c957b6c1d2624 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 13 Jul 2020 18:52:46 +0300 Subject: [PATCH] smtp_test: use `assert false return`, remove for loop --- vlib/net/smtp/smtp_test.v | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/vlib/net/smtp/smtp_test.v b/vlib/net/smtp/smtp_test.v index c115657429..371822b172 100644 --- a/vlib/net/smtp/smtp_test.v +++ b/vlib/net/smtp/smtp_test.v @@ -29,23 +29,20 @@ fn test_smtp() { body: 'Plain text' } - // This loop avoids `or { assert false return }` after each call; instead, it's replaced with - // `break`. There's an `assert false` after the loop, which will only be called if this loop - // is broken from. - for { - mut client := smtp.new_client(client_cfg) or { assert false break } - client.send(send_cfg) or { assert false break } - // client.send({ send_cfg | body_type: .html, body: '

HTML V email!

' }) or { break } - client.send({ send_cfg | from: 'alexander@vlang.io' }) or { assert false break } - client.send({ send_cfg | cc: 'alexander@vlang.io,joe@vlang.io', bcc: 'spytheman@vlang.io' }) or { assert false break } - client.send({ send_cfg | date: time.now().add_days(1000) }) or { assert false break } - client.quit() or { assert false break } - // This call should return an error, since the connection is closed - if !fn_errors(client, send_cfg) { assert false break } - client.reconnect() or { assert false break } - client.send(send_cfg) or { assert false break } - assert true - return - } - assert false + mut client := smtp.new_client(client_cfg) or { assert false return } + assert true + client.send(send_cfg) or { assert false return } + assert true + // client.send({ send_cfg | body_type: .html, body: '

HTML V email!

' }) or { assert false return } + client.send({ send_cfg | from: 'alexander@vlang.io' }) or { assert false return } + client.send({ send_cfg | cc: 'alexander@vlang.io,joe@vlang.io', bcc: 'spytheman@vlang.io' }) or { assert false return } + client.send({ send_cfg | date: time.now().add_days(1000) }) or { assert false return } + assert true + client.quit() or { assert false return } + assert true + // This call should return an error, since the connection is closed + if !fn_errors(client, send_cfg) { assert false return } + client.reconnect() or { assert false return } + client.send(send_cfg) or { assert false return } + assert true }