v2 / vlib / v / fmt / tests / vfmt_off_vfmt_on_keep.vv
96 lines · 87 sloc · 2.38 KB · b52b8429d4456df3070c39681ad010d33801bcf4
Raw
1// This file checks that using a single comment line like this: `// vfmt off`
2// should turn off the formatting that vfmt does, *till the end of the file*
3// or till it encounters a single comment line like this: `// vfmt on` .
4//
5// NOTE: all lines after a `// vfmt off` line, should be copied 1:1 from the
6// input source code, without any changes to the spacing/formatting.
7import sokol.sgl
8
9struct Abc {
10 b string
11}
12
13// vfmt off
14 struct St { a int }
15// vfmt on
16
17fn xyz() {
18 println('hi')
19}
20
21// vfmt off
22fn abc() {
23 println('hello')
24 println('another')
25}
26// vfmt on
27
28fn main() {
29 println('hi')
30 // vfmt off
31 println( 'unformatted' )
32
33 // some ASCII art here
34
35 code( )
36 another( )
37 // vfmt on
38 println('end')
39}
40
41// vertex specification for a cube with colored sides and texture coords
42fn cube() {
43 sgl.begin_quads()
44 {
45 // edge color
46 sgl.c3f(1.0, 0.0, 0.0)
47 // edge coord
48 // x,y,z, texture cord: u,v
49 // vfmt off
50 sgl.v3f_t2f(-1.0, 1.0, -1.0, -1.0, 1.0)
51 sgl.v3f_t2f( 1.0, 1.0, -1.0, 1.0, 1.0)
52 sgl.v3f_t2f( 1.0, -1.0, -1.0, 1.0, -1.0)
53 sgl.v3f_t2f(-1.0, -1.0, -1.0, -1.0, -1.0)
54 sgl.c3f(0.0, 1.0, 0.0)
55 sgl.v3f_t2f(-1.0, -1.0, 1.0, -1.0, 1.0)
56 sgl.v3f_t2f( 1.0, -1.0, 1.0, 1.0, 1.0)
57 sgl.v3f_t2f( 1.0, 1.0, 1.0, 1.0, -1.0)
58 sgl.v3f_t2f(-1.0, 1.0, 1.0, -1.0, -1.0)
59 sgl.c3f(0.0, 0.0, 1.0)
60 sgl.v3f_t2f(-1.0, -1.0, 1.0, -1.0, 1.0)
61 sgl.v3f_t2f(-1.0, 1.0, 1.0, 1.0, 1.0)
62 sgl.v3f_t2f(-1.0, 1.0, -1.0, 1.0, -1.0)
63 sgl.v3f_t2f(-1.0, -1.0, -1.0, -1.0, -1.0)
64 sgl.c3f(1.0, 0.5, 0.0)
65 sgl.v3f_t2f(1.0, -1.0, 1.0, -1.0, 1.0)
66 sgl.v3f_t2f(1.0, -1.0, -1.0, 1.0, 1.0)
67 sgl.v3f_t2f(1.0, 1.0, -1.0, 1.0, -1.0)
68 sgl.v3f_t2f(1.0, 1.0, 1.0, -1.0, -1.0)
69 sgl.c3f(0.0, 0.5, 1.0)
70 sgl.v3f_t2f( 1.0, -1.0, -1.0, -1.0, 1.0)
71 sgl.v3f_t2f( 1.0, -1.0, 1.0, 1.0, 1.0)
72 sgl.v3f_t2f(-1.0, -1.0, 1.0, 1.0, -1.0)
73 sgl.v3f_t2f(-1.0, -1.0, -1.0, -1.0, -1.0)
74 sgl.c3f(1.0, 0.0, 0.5)
75 sgl.v3f_t2f(-1.0, 1.0, -1.0, -1.0, 1.0)
76 sgl.v3f_t2f(-1.0, 1.0, 1.0, 1.0, 1.0)
77 sgl.v3f_t2f( 1.0, 1.0, 1.0, 1.0, -1.0)
78 sgl.v3f_t2f( 1.0, 1.0, -1.0, -1.0, -1.0)
79 // vfmt on
80 }
81 sgl.end()
82}
83
84fn a_matrix_whose_formatting_vfmt_will_not_destroy() {
85 // vfmt off
86 indices := [
87 u16(0), 1, 2, 0, 2, 3,
88 6, 5, 4, 7, 6, 4,
89 8, 9, 10, 8, 10, 11,
90 14, 13, 12, 15, 14, 12,
91 16, 17, 18, 16, 18, 19,
92 22, 21, 20, 23, 22, 20,
93 ]
94 // vfmt on
95 println(indices)
96}
97