1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

tools: format most examples and tutorials, add them to v test-cleancode (#9826)

This commit is contained in:
Lukas Neubert
2021-04-20 16:16:35 +02:00
committed by GitHub
parent dff50686d6
commit 16e79bc3ca
38 changed files with 471 additions and 433 deletions

View File

@ -1,12 +1,18 @@
struct App {}
fn (mut app App) method_one() {}
fn (mut app App) method_two() int { return 0 }
fn (mut app App) method_three(s string) string { return s }
fn (mut app App) method_two() int {
return 0
}
fn (mut app App) method_three(s string) string {
return s
}
fn main() {
$for method in App.methods {
$if method.typ is fn(string) string {
$if method.typ is fn (string) string {
println('$method.name IS `fn(string) string`')
} $else {
println('$method.name is NOT `fn(string) string`')
@ -17,12 +23,12 @@ fn main() {
println('$method.name DOES return `int`')
}
$if method.args[0].typ !is string {
println("${method.name}'s first arg is NOT `string`")
println("$method.name's first arg is NOT `string`")
} $else {
println("${method.name}'s first arg IS `string`")
println("$method.name's first arg IS `string`")
}
// TODO: Double inversion, should this even be allowed?
$if method.typ is fn() {
$if method.typ is fn () {
println('$method.name IS a void method')
} $else {
println('$method.name is NOT a void method')