2020-12-16 10:07:58 +01:00
|
|
|
fn show(a string) string {
|
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_function_interpolation() {
|
2021-03-27 18:29:57 +01:00
|
|
|
f := fn () (string, bool) {
|
|
|
|
return 'aaa', true
|
|
|
|
}
|
2020-12-16 10:07:58 +01:00
|
|
|
println(f)
|
|
|
|
assert '$f' == 'fn () (string, bool)'
|
|
|
|
|
|
|
|
println(show)
|
|
|
|
assert '$show' == 'fn (string) string'
|
|
|
|
}
|
2020-12-17 10:16:27 +01:00
|
|
|
|
|
|
|
struct Info {
|
2021-03-27 18:29:57 +01:00
|
|
|
aa fn () string
|
2020-12-17 10:16:27 +01:00
|
|
|
bb int
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_function_interpolation_in_struct() {
|
|
|
|
a := Info{
|
2021-03-27 18:29:57 +01:00
|
|
|
aa: fn () string {
|
|
|
|
return 'aaa'
|
|
|
|
}
|
2020-12-17 10:16:27 +01:00
|
|
|
bb: 22
|
|
|
|
}
|
|
|
|
println(a)
|
|
|
|
assert '$a'.contains(': fn () string')
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_function_interpolation_in_array() {
|
2021-03-27 18:29:57 +01:00
|
|
|
f := [fn () string {
|
|
|
|
return 'aaa'
|
|
|
|
}, fn () string {
|
|
|
|
return 'bbb'
|
|
|
|
}]
|
2020-12-17 10:16:27 +01:00
|
|
|
println(f)
|
|
|
|
assert '$f' == '[fn () string, fn () string]'
|
|
|
|
}
|
|
|
|
|
|
|
|
fn test_function_interpolation_in_map() {
|
2021-08-04 11:44:41 +02:00
|
|
|
m := {
|
2021-03-27 18:29:57 +01:00
|
|
|
'aaa': fn () string {
|
|
|
|
return 'aaa'
|
|
|
|
}
|
|
|
|
'bbb': fn () string {
|
|
|
|
return 'bbb'
|
|
|
|
}
|
|
|
|
}
|
2020-12-17 10:16:27 +01:00
|
|
|
println(m)
|
|
|
|
assert '$m'.contains(': fn () string')
|
|
|
|
}
|