diff options
Diffstat (limited to 'v_windows/v/vlib/v/tests/struct_map_method_test.v')
-rw-r--r-- | v_windows/v/vlib/v/tests/struct_map_method_test.v | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/v_windows/v/vlib/v/tests/struct_map_method_test.v b/v_windows/v/vlib/v/tests/struct_map_method_test.v new file mode 100644 index 0000000..0dd6524 --- /dev/null +++ b/v_windows/v/vlib/v/tests/struct_map_method_test.v @@ -0,0 +1,35 @@ +type Foo = int + +fn (a Foo) map(add int) string { + return (a + add).str() +} + +fn test_map_one_arg() { + a := Foo(0) + assert a.map(1) == '1' + assert Foo(3).map(3) == '6' +} + +type Bar = int + +fn (b Bar) map() int { + return b + 1 +} + +fn test_map_no_arg() { + b := Bar(0) + assert b.map() == 1 + assert Bar(1).map() == 2 +} + +type Baz = int + +fn (b Baz) map(a int, c int) int { + return b + (a - c) +} + +fn test_map_more_args() { + b := Baz(0) + assert b.map(5, 2) == 3 + assert Baz(3).map(2, 5) == 0 +} |