aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/v/tests/fn_mut_arg_of_array_test.v
diff options
context:
space:
mode:
Diffstat (limited to 'v_windows/v/vlib/v/tests/fn_mut_arg_of_array_test.v')
-rw-r--r--v_windows/v/vlib/v/tests/fn_mut_arg_of_array_test.v24
1 files changed, 24 insertions, 0 deletions
diff --git a/v_windows/v/vlib/v/tests/fn_mut_arg_of_array_test.v b/v_windows/v/vlib/v/tests/fn_mut_arg_of_array_test.v
new file mode 100644
index 0000000..012d5bc
--- /dev/null
+++ b/v_windows/v/vlib/v/tests/fn_mut_arg_of_array_test.v
@@ -0,0 +1,24 @@
+fn test_fn_mut_arg_of_array() {
+ mut a := App{}
+ a.data << 1
+ a.do_something()
+ assert a.data.len == 2
+}
+
+struct App {
+pub mut:
+ data []int
+}
+
+fn (mut a App) do_something() {
+ assert a.data.len == 1
+ mut p := Proc{}
+ p.make_a(mut a.data)
+ assert a.data.len == 2
+}
+
+struct Proc {}
+
+fn (mut p Proc) make_a(mut data []int) {
+ data << 2
+}