From 5b900056f3000dac463584c7f8c6c899ac98c276 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Thu, 2 Jul 2020 17:50:21 +0300 Subject: [PATCH] vfmt: add _keep.vv tests for the recent fixes, to prevent regressions --- vlib/v/fmt/tests/c_struct_init_keep.vv | 30 ++++++++++++++++++++++++++ vlib/v/fmt/tests/enum_comments_keep.vv | 17 +++++++++++++++ vlib/v/fmt/tests/ref_type_cast_keep.vv | 9 ++++++++ 3 files changed, 56 insertions(+) create mode 100644 vlib/v/fmt/tests/c_struct_init_keep.vv create mode 100644 vlib/v/fmt/tests/enum_comments_keep.vv create mode 100644 vlib/v/fmt/tests/ref_type_cast_keep.vv diff --git a/vlib/v/fmt/tests/c_struct_init_keep.vv b/vlib/v/fmt/tests/c_struct_init_keep.vv new file mode 100644 index 0000000000..f5c93e16b8 --- /dev/null +++ b/vlib/v/fmt/tests/c_struct_init_keep.vv @@ -0,0 +1,30 @@ +module main + +fn abc() { + desc := C.sapp_desc{ + width: a.width + height: a.height + user_data: &a + init_userdata_cb: init + frame_userdata_cb: frame + event_userdata_cb: event + window_title: title.str + html5_canvas_name: title.str + cleanup_userdata_cb: cleanup + } +} + +fn init(user_data voidptr) { + desc := C.sg_desc{ + mtl_device: sapp.metal_get_device() + mtl_renderpass_descriptor_cb: sapp.metal_get_renderpass_descriptor + mtl_drawable_cb: sapp.metal_get_drawable + d3d11_device: sapp.d3d11_get_device() + d3d11_device_context: sapp.d3d11_get_device_context() + d3d11_render_target_view_cb: sapp.d3d11_get_render_target_view + d3d11_depth_stencil_view_cb: sapp.d3d11_get_depth_stencil_view + } + sgl_desc := C.sgl_desc_t{ + max_vertices: 50 * 65536 + } +} diff --git a/vlib/v/fmt/tests/enum_comments_keep.vv b/vlib/v/fmt/tests/enum_comments_keep.vv new file mode 100644 index 0000000000..f46208b7bf --- /dev/null +++ b/vlib/v/fmt/tests/enum_comments_keep.vv @@ -0,0 +1,17 @@ +module main + +// Top level comment +enum EnumType { + // comment for the enum + abc + xyz // comment for the enum field +} + +// Another top level comment +enum PacketType { + // Regular data packet + data // abc def + // xyz + // another comment + abcd // jklmn +} diff --git a/vlib/v/fmt/tests/ref_type_cast_keep.vv b/vlib/v/fmt/tests/ref_type_cast_keep.vv new file mode 100644 index 0000000000..aba9e547fc --- /dev/null +++ b/vlib/v/fmt/tests/ref_type_cast_keep.vv @@ -0,0 +1,9 @@ +module main + +fn cleanup(user_data voidptr) { + abc := App(user_data) + xyz := &App(user_data) + // + mut app := App(user_data) + mut ref := &App(user_data) +}