mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
74 lines
807 B
V
74 lines
807 B
V
struct Foo {
|
|
a int
|
|
b int
|
|
c int
|
|
}
|
|
|
|
fn test_stdout() {
|
|
print('Hello ')
|
|
println('World')
|
|
}
|
|
|
|
fn test_booleans() {
|
|
println(true)
|
|
println(false)
|
|
}
|
|
|
|
fn test_numbers() {
|
|
println(123)
|
|
}
|
|
|
|
fn test_oof() {
|
|
println(__offsetof(Foo, a))
|
|
println(__offsetof(Foo, b))
|
|
println(__offsetof(Foo, c))
|
|
}
|
|
|
|
fn test_stderr() {
|
|
eprint('2(Hello)')
|
|
eprintln('2(World)')
|
|
}
|
|
|
|
fn test_idents() {
|
|
// signed integer
|
|
|
|
x := 0
|
|
println(x)
|
|
|
|
y := 5
|
|
println(y)
|
|
|
|
z := -8
|
|
println(z)
|
|
|
|
a := 123
|
|
println(a)
|
|
|
|
b := -456
|
|
println(b)
|
|
|
|
// booleans
|
|
|
|
bool_true := true
|
|
println(bool_true)
|
|
|
|
bool_false := false
|
|
println(bool_false)
|
|
|
|
// strings
|
|
|
|
str := 'string blah blah blah'
|
|
println(str)
|
|
|
|
unicode := '😀😆😎💻🌎'
|
|
println(unicode)
|
|
}
|
|
|
|
fn main() {
|
|
test_stdout()
|
|
test_stderr()
|
|
test_numbers()
|
|
test_oof()
|
|
test_idents()
|
|
}
|