diff --git a/vlib/builtin/js/array.js.v b/vlib/builtin/js/array.js.v index 2aa03edb17261d..ab882761190b47 100644 --- a/vlib/builtin/js/array.js.v +++ b/vlib/builtin/js/array.js.v @@ -424,7 +424,7 @@ pub interface JS.TypedArray { mut: byteLength JS.Number byteOffset JS.Number - length JS.Number + length JS.Number } pub interface JS.Uint8Array { diff --git a/vlib/builtin/js/builtin.v b/vlib/builtin/js/builtin.v index 62ad65c737df2a..d46780e1c6652c 100644 --- a/vlib/builtin/js/builtin.v +++ b/vlib/builtin/js/builtin.v @@ -16,7 +16,7 @@ pub fn panic(s string) { pub interface IError { // >> Hack to allow old style custom error implementations // TODO: remove once deprecation period for `IError` methods has ended - msg string + msg string code int // << msg() string code() int diff --git a/vlib/builtin/result.v b/vlib/builtin/result.v index 7629a029e7c27d..c96ac24d7fdb1c 100644 --- a/vlib/builtin/result.v +++ b/vlib/builtin/result.v @@ -7,7 +7,7 @@ module builtin pub interface IError { // >> Hack to allow old style custom error implementations // TODO: remove once deprecation period for `IError` methods has ended - msg string + msg string code int // << msg() string code() int diff --git a/vlib/js/dom/dom.js.v b/vlib/js/dom/dom.js.v index d361a9b158cda7..5427b8a1e56c0d 100644 --- a/vlib/js/dom/dom.js.v +++ b/vlib/js/dom/dom.js.v @@ -17,12 +17,12 @@ pub fn (settings CanvasRenderingContext2DSettings) to_js() JS.Any { pub interface JS.DOMMatrix2DInit { mut: - a JS.Number - b JS.Number - c JS.Number - d JS.Number - e JS.Number - f JS.Number + a JS.Number + b JS.Number + c JS.Number + d JS.Number + e JS.Number + f JS.Number m11 JS.Number m12 JS.Number m21 JS.Number @@ -48,7 +48,7 @@ mut: } pub interface JS.DOMMatrix { - is2D JS.Boolean + is2D JS.Boolean isIdentity JS.Boolean flipX() JS.DOMMatrix flipY() JS.DOMMatrix @@ -71,12 +71,12 @@ pub interface JS.DOMMatrix { scaleSelf(scaleX JS.Number, scaleY JS.Number, scaleZ JS.Number, originX JS.Number, originY JS.Number, originZ JS.Number) JS.DOMMatrix toString() JS.String mut: - a JS.Number - b JS.Number - c JS.Number - d JS.Number - e JS.Number - f JS.Number + a JS.Number + b JS.Number + c JS.Number + d JS.Number + e JS.Number + f JS.Number m11 JS.Number m12 JS.Number m13 JS.Number @@ -128,14 +128,14 @@ pub fn JS.DOMQuad.fromRect(other JS.DOMRect) JS.DOMRect pub interface JS.DOMRect { bottom JS.Number - left JS.Number - right JS.Number - top JS.Number + left JS.Number + right JS.Number + top JS.Number mut: height JS.Number - width JS.Number - x JS.Number - y JS.Number + width JS.Number + x JS.Number + y JS.Number } [use_new] @@ -182,17 +182,17 @@ pub interface JS.EventTarget { pub interface JS.Node { JS.EventTarget - baseURI JS.String - childNodes JS.Any - firstChild JS.ChildNode - isConnected JS.Boolean - lastChild JS.ChildNode - nextSibling JS.ChildNode - nodeName JS.String - nodeType JS.Number - ownerDocument JS.Document - parentElement JS.HTMLElement - parentNode JS.ParentNode + baseURI JS.String + childNodes JS.Any + firstChild JS.ChildNode + isConnected JS.Boolean + lastChild JS.ChildNode + nextSibling JS.ChildNode + nodeName JS.String + nodeType JS.Number + ownerDocument JS.Document + parentElement JS.HTMLElement + parentNode JS.ParentNode previousSibling JS.ChildNode appendChild(node JS.Node) JS.Node cloneNode(deep JS.Boolean) JS.Node @@ -208,7 +208,7 @@ pub interface JS.Node { removeChild(child JS.Node) JS.Node replaceChild(node JS.Node, child JS.Node) JS.Npde mut: - nodeValue JS.String + nodeValue JS.String textContent JS.String } @@ -223,32 +223,32 @@ pub interface JS.ChildNode { pub interface JS.ParentNode { JS.Node childElementCount JS.Number - children JS.HTMLCollection + children JS.HTMLCollection } pub type WindowProxy = JS.Window pub interface JS.Document { JS.Node - all JS.HTMLAllCollection - anchros JS.HTMLCollection - applets JS.HTMLCollection - characterSet JS.String - charset JS.String - compatMode JS.String - contentType JS.String - documentURI JS.String - documentElement JS.HTMLElement - hidden JS.Boolean - head JS.HTMLHeadElement + all JS.HTMLAllCollection + anchros JS.HTMLCollection + applets JS.HTMLCollection + characterSet JS.String + charset JS.String + compatMode JS.String + contentType JS.String + documentURI JS.String + documentElement JS.HTMLElement + hidden JS.Boolean + head JS.HTMLHeadElement fullscreenEnabled JS.Boolean - fullscreen JS.Boolean - lastModified JS.String - inputEncoding JS.String - implementation JS.DOMImplementation - doctype JS.DocumentType - embeds JS.HTMLCollection - forms JS.HTMLCollection + fullscreen JS.Boolean + lastModified JS.String + inputEncoding JS.String + implementation JS.DOMImplementation + doctype JS.DocumentType + embeds JS.HTMLCollection + forms JS.HTMLCollection getElementById(id JS.String) ?JS.HTMLElement adoptNode(node JS.Node) JS.Node close() @@ -277,13 +277,13 @@ pub interface JS.Document { requestPointerLock() requestFullScreen() JS.Promise mut: - bgColor JS.String - fgColor JS.String - body JS.HTMLElement - cookie JS.String - domain JS.String + bgColor JS.String + fgColor JS.String + body JS.HTMLElement + cookie JS.String + domain JS.String designMode JS.String - dir JS.String + dir JS.String vlinkColor JS.String } @@ -296,19 +296,19 @@ pub fn document_url(doc JS.Document) JS.String { pub interface JS.Element { JS.Node - classList JS.DOMTokenList - clientHeight JS.Number - clientLeft JS.Number - clientTop JS.Number - clientWidth JS.Number - localName JS.String - namespaceURI JS.String + classList JS.DOMTokenList + clientHeight JS.Number + clientLeft JS.Number + clientTop JS.Number + clientWidth JS.Number + localName JS.String + namespaceURI JS.String ownerDocument JS.Document - part JS.DOMTokenList - prefix JS.String - scrollHeight JS.Number - scrollWidth JS.Number - tagName JS.String + part JS.DOMTokenList + prefix JS.String + scrollHeight JS.Number + scrollWidth JS.Number + tagName JS.String closest(selector JS.String) ?JS.Element getAttribute(qualifiedName JS.String) ?JS.String getAttributeNS(namespace JS.String, localName JS.String) ?JS.String @@ -328,14 +328,14 @@ pub interface JS.Element { hasPointerCapture(pointerId JS.Number) JS.Boolean matches(selectors JS.String) JS.Boolean mut: - className JS.String - id JS.String + className JS.String + id JS.String onfullscreenchange fn (this JS.Element, ev JS.Event) JS.Any - onfullscreenerror fn (this JS.Element, ev JS.Event) JS.Any - outerHTML JS.String - scrollLeft JS.Number - scrollTop JS.Number - slot JS.String + onfullscreenerror fn (this JS.Element, ev JS.Event) JS.Any + outerHTML JS.String + scrollLeft JS.Number + scrollTop JS.Number + slot JS.String } pub const ( @@ -374,24 +374,24 @@ pub interface JS.HTMLCollection { pub interface JS.HTMLElement { JS.Element accessKeyLabel JS.String - offsetHeight JS.Number - offsetLeft JS.Number - offsetParent JS.Any - offsetTop JS.Number - offsetWidth JS.Number + offsetHeight JS.Number + offsetLeft JS.Number + offsetParent JS.Any + offsetTop JS.Number + offsetWidth JS.Number click() mut: - accessKey JS.String + accessKey JS.String autocapitalize JS.String - dir JS.String - draggable JS.Boolean - hidden JS.Boolean - innerText JS.String - lang JS.String - outerText JS.String - spellcheck JS.Boolean - title JS.String - translate JS.Boolean + dir JS.String + draggable JS.Boolean + hidden JS.Boolean + innerText JS.String + lang JS.String + outerText JS.String + spellcheck JS.Boolean + title JS.String + translate JS.Boolean } pub fn JS.HTMLElement.prototype.constructor() JS.HTMLElement @@ -399,10 +399,10 @@ pub fn JS.HTMLElement.prototype.constructor() JS.HTMLElement pub interface JS.HTMLEmbedElement { getSVGDocument() ?JS.Document mut: - align JS.String + align JS.String height JS.String - src JS.String - width JS.String + src JS.String + width JS.String } pub fn html_embed_type(embed JS.HTMLEmbedElement) JS.String { @@ -423,7 +423,7 @@ pub interface JS.HTMLCanvasElement { getContext(contextId JS.String, options JS.Any) ?CanvasContext mut: height JS.Number - width JS.Number + width JS.Number } pub type FillStyle = JS.CanvasGradient | JS.CanvasPattern | JS.String @@ -464,16 +464,16 @@ pub interface JS.CanvasRenderingContext2D { stroke() fillText(text JS.String, x JS.Number, y JS.Number) mut: - lineCap JS.String - lineDashOffset JS.Number - lineJoin JS.String - lineWidth JS.Number - miterLimit JS.Number - fillStyle FillStyle - strokeStyle FillStyle - globalAlpha JS.Number + lineCap JS.String + lineDashOffset JS.Number + lineJoin JS.String + lineWidth JS.Number + miterLimit JS.Number + fillStyle FillStyle + strokeStyle FillStyle + globalAlpha JS.Number globalCompositeOperation JS.String - font JS.String + font JS.String } pub interface JS.CanvasGradient { @@ -512,21 +512,21 @@ pub type AnimationFrameCallback = fn (JS.Number) pub interface JS.Window { JS.EventTarget - closed JS.Boolean + closed JS.Boolean devicePixelRatio JS.Number - document JS.Document - frameElement JS.Element - innerHeight JS.Number - innerWidth JS.Number - length JS.Number - outerHeight JS.Number - outerWidth JS.Number - screenLeft JS.Number - screenTop JS.Number - screenX JS.Number - screenY JS.Number - scrollX JS.Number - scrollY JS.Number + document JS.Document + frameElement JS.Element + innerHeight JS.Number + innerWidth JS.Number + length JS.Number + outerHeight JS.Number + outerWidth JS.Number + screenLeft JS.Number + screenTop JS.Number + screenX JS.Number + screenY JS.Number + scrollX JS.Number + scrollY JS.Number alert(message JS.Any) blur() cancelIdleCallback(handle JS.Number) @@ -546,9 +546,9 @@ pub interface JS.Window { scrollTo(x JS.Number, y JS.Number) requestAnimationFrame(callback AnimationFrameCallback) mut: - name string - opener JS.Any - ondevicemotion OnDeviceMotion + name string + opener JS.Any + ondevicemotion OnDeviceMotion ondeviceorientation OnDeviceOrientation } @@ -568,27 +568,27 @@ pub struct JS.DeviceMotionEventRotationRate { pub interface JS.DeviceMotionEvent { JS.Event - interval JS.Number - acceleration JS.DeviceMotionEventAcceleration + interval JS.Number + acceleration JS.DeviceMotionEventAcceleration accelerationIncludingGravity JS.DeviceMotionEventAcceleration - rotationRate JS.DeviceMotionEventRotationRate + rotationRate JS.DeviceMotionEventRotationRate } pub interface JS.DeviceOrientationEvent { JS.Event absolute JS.Boolean - alpha JS.Number - beta JS.Number - gamma JS.Number + alpha JS.Number + beta JS.Number + gamma JS.Number } pub interface JS.DocumentType { JS.Node JS.ChildNode - name JS.String + name JS.String ownerDocument JS.Document - publicId JS.String - systemId JS.String + publicId JS.String + systemId JS.String } [single_impl] @@ -616,9 +616,9 @@ pub interface JS.WebGLUniformLocation {} pub interface JS.WebGLVertexArrayObject {} pub interface JS.WebGLRenderingContext { - canvas JS.HTMLCanvasElement + canvas JS.HTMLCanvasElement drawingBufferHeight JS.Number - drawingBufferWidth JS.Number + drawingBufferWidth JS.Number activeTexture(texture JS.Number) attachShader(program JS.WebGLProgram, shader JS.WebGLProgram) linkProgram(program JS.WebGLProgram) @@ -811,15 +811,15 @@ pub fn gl_depth_test() JS.Number { // Event is an event which takes place in the DOM. pub interface JS.Event { JS.EventTarget - bubbles JS.Boolean - cancelable JS.Boolean - composed JS.Boolean - currentTarget JS.EventTarget + bubbles JS.Boolean + cancelable JS.Boolean + composed JS.Boolean + currentTarget JS.EventTarget defaultPrevented JS.Boolean - eventPhase JS.Number - isTrusted JS.Boolean - srcElement JS.EventTarget - timeStamp JS.DOMHighResTimeStamp // composedPath returns the invocation target objects of event's path. + eventPhase JS.Number + isTrusted JS.Boolean + srcElement JS.EventTarget + timeStamp JS.DOMHighResTimeStamp // composedPath returns the invocation target objects of event's path. composedPath() JS.Array initEvent(typ JS.String, bubbles JS.Boolean, cancelable JS.Boolean) preventDefault() @@ -845,11 +845,11 @@ pub fn create_event(typ string, bubbles bool, cancelable bool, composed bool) JS pub interface JS.ErrorEvent { JS.Event - colno JS.Number - error JS.Number + colno JS.Number + error JS.Number filename JS.Number - lineno JS.Number - message JS.String + lineno JS.Number + message JS.String } [use_new] @@ -858,7 +858,7 @@ pub fn JS.ErrorEvent.prototype.constructor(typ JS.String) JS.ErrorEvent pub interface JS.UIEvent { JS.Event detail JS.Number - view JS.Any + view JS.Any } [use_new] @@ -881,68 +881,68 @@ pub struct JS.UIEventInitDict { pub interface JS.MouseEvent { JS.UIEvent - altKey JS.Boolean - button JS.Number - buttons JS.Number - clientX JS.Number - clientY JS.Number - ctrlKey JS.Number - metaKey JS.Number - movementX JS.Number - movementY JS.Number - offsetX JS.Number - offsetY JS.Number - pageX JS.Number - pageY JS.Number + altKey JS.Boolean + button JS.Number + buttons JS.Number + clientX JS.Number + clientY JS.Number + ctrlKey JS.Number + metaKey JS.Number + movementX JS.Number + movementY JS.Number + offsetX JS.Number + offsetY JS.Number + pageX JS.Number + pageY JS.Number relatedTarget JS.Any - screenX JS.Number - screenY JS.Number - shiftKey JS.Boolean - x JS.Number - y JS.Number + screenX JS.Number + screenY JS.Number + shiftKey JS.Boolean + x JS.Number + y JS.Number getModifierState(keyArg JS.String) JS.Boolean } pub interface JS.WheelEvent { JS.MouseEvent - deltaX JS.Number - deltaY JS.Number - deltaZ JS.Number + deltaX JS.Number + deltaY JS.Number + deltaZ JS.Number deltaMode JS.Number } pub interface JS.PointerEvent { JS.MouseEvent - height JS.Number - isPrimary JS.Boolean - pointerId JS.Number - pointerType JS.String - pressure JS.Number + height JS.Number + isPrimary JS.Boolean + pointerId JS.Number + pointerType JS.String + pressure JS.Number tangentialPressure JS.Number - tiltX JS.Number - tiltY JS.Number - twist JS.Number - width JS.Number + tiltX JS.Number + tiltY JS.Number + twist JS.Number + width JS.Number getCoalescedEvents() JS.Array getPredictedEvents() JS.Array } pub interface JS.Gamepad { - axes JS.Array // Array - buttons JS.Array // Array - connected JS.Boolean + axes JS.Array // Array + buttons JS.Array // Array + connected JS.Boolean hapticActuators JS.Array // Array - id JS.String - index JS.Number - mapping JS.String - timestamp JS.Number + id JS.String + index JS.Number + mapping JS.String + timestamp JS.Number } [single_impl] pub interface JS.GamepadButton { pressed JS.Boolean touched JS.Boolean - value JS.Number + value JS.Number } [single_impl] @@ -962,11 +962,11 @@ pub interface JS.HashChangeEvent { pub interface JS.MessageEvent { JS.Event - data JS.Any + data JS.Any lastEventId JS.String - origin JS.String - ports JS.Array - source JS.Any + origin JS.String + ports JS.Array + source JS.Any } pub interface JS.MessagePort { @@ -988,20 +988,20 @@ pub interface JS.PopStateEvent { pub interface JS.ProgressEvent { lenghtComputable JS.Boolean - loaded JS.Number - target JS.Any - total JS.Number + loaded JS.Number + target JS.Any + total JS.Number } pub interface JS.KeyboardEvent { JS.UIEvent - altKey JS.Boolean - code JS.String - ctrlKey JS.Boolean + altKey JS.Boolean + code JS.String + ctrlKey JS.Boolean isComposing JS.Boolean - key JS.String - location JS.Number - metaKey JS.Boolean - repeat JS.Boolean - shiftKey JS.Boolean + key JS.String + location JS.Number + metaKey JS.Boolean + repeat JS.Boolean + shiftKey JS.Boolean } diff --git a/vlib/js/js.js.v b/vlib/js/js.js.v index 76cf777c962e69..a23708d3c2ff85 100644 --- a/vlib/js/js.js.v +++ b/vlib/js/js.js.v @@ -5,7 +5,7 @@ import js.promise pub fn JS.fetch(input JS.String, init JS.Object) JS.Promise pub interface JS.Body { - body JS.Uint8Array + body JS.Uint8Array bodyUse JS.Boolean blob() JS.Promise json() JS.Promise @@ -14,11 +14,11 @@ pub interface JS.Body { pub interface JS.Response { JS.Body - ok JS.Boolean + ok JS.Boolean redirected JS.Boolean - status JS.Number + status JS.Number statusText JS.String - url JS.String + url JS.String clone() JS.Response } diff --git a/vlib/os/notify/notify.v b/vlib/os/notify/notify.v index e8bab1f902b713..6c0f8f2c4ebaf8 100644 --- a/vlib/os/notify/notify.v +++ b/vlib/os/notify/notify.v @@ -13,7 +13,7 @@ mut: } pub interface FdEvent { - fd int + fd int kind FdEventType } diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 8a562269ab3af9..7def39487bc9e1 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1351,9 +1351,22 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) { } } + mut field_aligns := []AlignInfo{} + mut comment_aligns := []AlignInfo{} + mut default_expr_aligns := []AlignInfo{} + mut field_types := []string{cap: node.fields.len} + + // Calculate the alignments first + f.calculate_alignment(node.fields, mut field_aligns, mut comment_aligns, mut default_expr_aligns, mut + field_types) + + mut field_align_i := 0 // TODO: alignment, comments, etc. for field in immut_fields { - f.interface_field(field) + if field_aligns[field_align_i].line_nr < field.pos.line_nr { + field_align_i++ + } + f.interface_field(field, field_aligns[field_align_i]) } for method in immut_methods { f.interface_method(method) @@ -1361,7 +1374,10 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) { if mut_fields.len + mut_methods.len > 0 { f.writeln('mut:') for field in mut_fields { - f.interface_field(field) + if field_aligns[field_align_i].line_nr < field.pos.line_nr { + field_align_i++ + } + f.interface_field(field, field_aligns[field_align_i]) } for method in mut_methods { f.interface_method(method) @@ -1370,24 +1386,59 @@ pub fn (mut f Fmt) interface_decl(node ast.InterfaceDecl) { f.writeln('}\n') } -pub fn (mut f Fmt) interface_field(field ast.StructField) { +pub fn (mut f Fmt) calculate_alignment(fields []ast.StructField, mut field_aligns []AlignInfo, mut comment_aligns []AlignInfo, mut default_expr_aligns []AlignInfo, mut field_types []string) { + // Calculate the alignments first + for i, field in fields { + ft := f.no_cur_mod(f.table.type_to_str_using_aliases(field.typ, f.mod2alias)) + // Handle anon structs recursively + field_types << ft + attrs_len := inline_attrs_len(field.attrs) + end_pos := field.pos.pos + field.pos.len + for comment in field.comments { + if comment.pos.pos >= end_pos { + if comment.pos.line_nr == field.pos.line_nr { + comment_aligns.add_info(attrs_len, field_types[i].len, comment.pos.line_nr, + use_threshold: true + ) + } + continue + } + } + field_aligns.add_info(field.name.len, ft.len, field.pos.line_nr) + if field.has_default_expr { + default_expr_aligns.add_info(attrs_len, field_types[i].len, field.pos.line_nr, + use_threshold: true + ) + } + } +} + +pub fn (mut f Fmt) interface_field(field ast.StructField, field_align AlignInfo) { ft := f.no_cur_mod(f.table.type_to_str_using_aliases(field.typ, f.mod2alias)) before_comments := field.comments.filter(it.pos.pos < field.pos.pos) end_comments := field.comments.filter(it.pos.pos > field.pos.pos) + before_len := f.line_len if before_comments.len > 0 { f.comments(before_comments, level: .indent) } + comments_len := f.line_len - before_len + sym := f.table.sym(field.typ) if sym.info is ast.Struct { if sym.info.is_anon { f.write('\t${field.name} ') f.write_anon_struct_field_decl(field.typ, ast.StructDecl{ fields: sym.info.fields }) } else { - f.write('\t${field.name} ${ft}') + f.write('\t${field.name} ') } } else { - f.write('\t${field.name} ${ft}') + f.write('\t${field.name} ') } + if !(sym.info is ast.Struct && sym.info.is_anon) { + f.write(strings.repeat(` `, field_align.max_len - field.name.len - comments_len)) + f.write(ft) + } + if end_comments.len > 0 { f.comments(end_comments, level: .indent) } else { diff --git a/vlib/v/fmt/struct.v b/vlib/v/fmt/struct.v index 2fd22943d03106..0d68d817c34b8a 100644 --- a/vlib/v/fmt/struct.v +++ b/vlib/v/fmt/struct.v @@ -32,29 +32,8 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl, is_anon bool) { mut default_expr_aligns := []AlignInfo{} mut field_types := []string{cap: node.fields.len} // Calculate the alignments first - for i, field in node.fields { - ft := f.no_cur_mod(f.table.type_to_str_using_aliases(field.typ, f.mod2alias)) - // Handle anon structs recursively - field_types << ft - attrs_len := inline_attrs_len(field.attrs) - end_pos := field.pos.pos + field.pos.len - for comment in field.comments { - if comment.pos.pos >= end_pos { - if comment.pos.line_nr == field.pos.line_nr { - comment_aligns.add_info(attrs_len, field_types[i].len, comment.pos.line_nr, - use_threshold: true - ) - } - continue - } - } - field_aligns.add_info(field.name.len, ft.len, field.pos.line_nr) - if field.has_default_expr { - default_expr_aligns.add_info(attrs_len, field_types[i].len, field.pos.line_nr, - use_threshold: true - ) - } - } + f.calculate_alignment(node.fields, mut field_aligns, mut comment_aligns, mut default_expr_aligns, mut + field_types) f.writeln(' {') if node.pre_comments.len > 0 { f.comments_before_field(node.pre_comments) diff --git a/vlib/v/fmt/tests/interface_declaration_comments_keep.vv b/vlib/v/fmt/tests/interface_declaration_comments_keep.vv index c74c3a66081cb0..16e99b0296b7df 100644 --- a/vlib/v/fmt/tests/interface_declaration_comments_keep.vv +++ b/vlib/v/fmt/tests/interface_declaration_comments_keep.vv @@ -32,11 +32,11 @@ interface Bar { interface TestsRunner { mut: - fn_passes u64 - fn_fails u64 + fn_passes u64 + fn_fails u64 assert_passes u64 - assert_fails u64 - test_fn_info &TestFnMetaInfo // filled in by generated code, before .fn_start() is called. + assert_fails u64 + test_fn_info &TestFnMetaInfo // filled in by generated code, before .fn_start() is called. start(ntests int) // called before all tests, you can initialise private data here. ntests is the number of test functions in the _test.v file. finish() // called after all tests are finished, you should free all the private data here. // diff --git a/vlib/v/fmt/tests/interface_field_expected.vv b/vlib/v/fmt/tests/interface_field_expected.vv new file mode 100644 index 00000000000000..d46f84192bc8a0 --- /dev/null +++ b/vlib/v/fmt/tests/interface_field_expected.vv @@ -0,0 +1,18 @@ +interface Hex { + a int + ab int + abc int + abcd int + abcde int +mut: + aaaaaaaaaaaaaaaaaa string + b f64 +} + +struct Hex2 { + a int + ab int + abc int + abcd int + abcde int +} diff --git a/vlib/v/fmt/tests/interface_field_input.vv b/vlib/v/fmt/tests/interface_field_input.vv new file mode 100644 index 00000000000000..d46f84192bc8a0 --- /dev/null +++ b/vlib/v/fmt/tests/interface_field_input.vv @@ -0,0 +1,18 @@ +interface Hex { + a int + ab int + abc int + abcd int + abcde int +mut: + aaaaaaaaaaaaaaaaaa string + b f64 +} + +struct Hex2 { + a int + ab int + abc int + abcd int + abcde int +} diff --git a/vlib/v/preludes/test_runner.v b/vlib/v/preludes/test_runner.v index 84f83d7653f1da..0ea31f30fe0d40 100644 --- a/vlib/v/preludes/test_runner.v +++ b/vlib/v/preludes/test_runner.v @@ -12,13 +12,13 @@ __global test_runner TestRunner interface TestRunner { mut: - file_test_info VTestFileMetaInfo // filled in by generated code, before .start() is called. - fn_test_info VTestFnMetaInfo // filled in by generated code, before .fn_start() is called. - fn_assert_passes u64 // reset this to 0 in .fn_start(), increase it in .assert_pass() - fn_passes u64 // increase this in .fn_pass() - fn_fails u64 // increase this in .fn_fails() + file_test_info VTestFileMetaInfo // filled in by generated code, before .start() is called. + fn_test_info VTestFnMetaInfo // filled in by generated code, before .fn_start() is called. + fn_assert_passes u64 // reset this to 0 in .fn_start(), increase it in .assert_pass() + fn_passes u64 // increase this in .fn_pass() + fn_fails u64 // increase this in .fn_fails() total_assert_passes u64 // increase this in .assert_pass() - total_assert_fails u64 // increase this in .assert_fail() + total_assert_fails u64 // increase this in .assert_fail() start(ntests int) // called before all tests, you can initialise private data here. ntests is the number of test functions in the _test.v file. finish() // called after all tests are finished, you can print some stats if you want here. exit_code() int // called right after finish(), it should return the exit code, that the test program will exit with. diff --git a/vlib/v/tests/array_as_interface_test.v b/vlib/v/tests/array_as_interface_test.v index ba4d0417116934..614c41a0f0480a 100644 --- a/vlib/v/tests/array_as_interface_test.v +++ b/vlib/v/tests/array_as_interface_test.v @@ -1,10 +1,10 @@ interface Source { element_size int - data voidptr - offset int - len int - cap int - flags ArrayFlags + data voidptr + offset int + len int + cap int + flags ArrayFlags } fn test_array_as_interface() { diff --git a/vlib/v/tests/bench/math_big_gcd/bench_euclid.v b/vlib/v/tests/bench/math_big_gcd/bench_euclid.v index 7c48acdc384f94..6993850cb38d4b 100644 --- a/vlib/v/tests/bench/math_big_gcd/bench_euclid.v +++ b/vlib/v/tests/bench/math_big_gcd/bench_euclid.v @@ -11,7 +11,7 @@ import v.tests.bench.math_big_gcd.prime { } interface TestDataI { - r big.Integer + r big.Integer aa big.Integer bb big.Integer } diff --git a/vlib/v/tests/interface_fn_return_with_struct_init_test.v b/vlib/v/tests/interface_fn_return_with_struct_init_test.v index 440de4c975ba70..02fbfbcdfcff38 100644 --- a/vlib/v/tests/interface_fn_return_with_struct_init_test.v +++ b/vlib/v/tests/interface_fn_return_with_struct_init_test.v @@ -6,8 +6,8 @@ pub mut: interface Adoptable { class_name string - age int - test int + age int + test int } struct Cat { diff --git a/vlib/v/tests/option_struct_init_interface_test.v b/vlib/v/tests/option_struct_init_interface_test.v index c5f4c7aa73485a..5e389e0370894c 100644 --- a/vlib/v/tests/option_struct_init_interface_test.v +++ b/vlib/v/tests/option_struct_init_interface_test.v @@ -1,6 +1,6 @@ interface IPerson { name string - age int + age int } struct PersonImpl {