2019-07-02 02:49:15 +03:00
|
|
|
// 1 line comment
|
|
|
|
|
|
|
|
/* 1 line comment */
|
|
|
|
|
|
|
|
/*
|
|
|
|
multi line comment (1)
|
|
|
|
multi line comment (2)
|
|
|
|
multi line comment (3)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
multi line comment (1)
|
|
|
|
/*
|
|
|
|
nested comment
|
|
|
|
*/
|
|
|
|
/*nested comment*/
|
|
|
|
/*nested comment
|
|
|
|
*/
|
|
|
|
/* nested comment */
|
|
|
|
/* /* nested comment */ */
|
|
|
|
multi line comment (2)
|
|
|
|
*/
|
|
|
|
|
2019-06-27 15:28:12 +03:00
|
|
|
type myfn fn (int) string
|
|
|
|
|
|
|
|
type myfn2 fn (a int, b int) int
|
|
|
|
|
|
|
|
type myfn3 fn (int, int)
|
|
|
|
|
|
|
|
fn myfn4(string)
|
|
|
|
|
|
|
|
fn foobar()
|
|
|
|
|
|
|
|
fn slopediv(num u32, den u32) int
|
|
|
|
|
|
|
|
type f1 fn ()
|
|
|
|
|
|
|
|
type f2 fn (voidptr)
|
|
|
|
|
|
|
|
type f3 fn (voidptr, voidptr)
|
|
|
|
|
|
|
|
type f4 fn (voidptr) int
|
|
|
|
|
|
|
|
type f5 fn (int, int) int
|
|
|
|
|
|
|
|
type f6 fn (int, int)
|
|
|
|
|
|
|
|
fn C.atoi(byteptr) int
|
|
|
|
|
|
|
|
fn foo() {
|
|
|
|
}
|
|
|
|
|
|
|
|
type actionf_v fn ()
|
|
|
|
|
|
|
|
type actionf_p1 fn (voidptr)
|
|
|
|
|
|
|
|
type actionf_p2 fn (voidptr, voidptr)
|
|
|
|
|
|
|
|
fn myprint(s string, ..) {
|
|
|
|
println('my print')
|
2019-07-02 02:49:15 +03:00
|
|
|
println('// comment')
|
|
|
|
println('/* comment */')
|
|
|
|
println('/* /* comment */ */')
|
2019-06-27 15:28:12 +03:00
|
|
|
}
|
|
|
|
|
2019-07-24 14:04:57 +03:00
|
|
|
fn modify_array(a mut []int) {
|
|
|
|
a[0] = 10
|
|
|
|
for i in 0..a.len {
|
|
|
|
a[i] = a[i] * 2
|
|
|
|
}
|
|
|
|
a << 888
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_mut() {
|
|
|
|
mut nums := [1, 2, 3]
|
|
|
|
modify_array(mut nums)
|
|
|
|
assert nums.len == 4
|
|
|
|
assert nums[0] == 20
|
|
|
|
assert nums[1] == 4
|
|
|
|
assert nums[2] == 6
|
|
|
|
assert nums[3] == 888
|
|
|
|
}
|
|
|
|
|
2019-06-27 15:28:12 +03:00
|
|
|
fn test_fns() {
|
|
|
|
// no asserts for now, just test function declarations above
|
|
|
|
}
|
|
|
|
|