Skip to content

Commit a782ae7

Browse files
committed
v2: vfmt
1 parent de8226d commit a782ae7

5 files changed

Lines changed: 387 additions & 181 deletions

File tree

‎cmd/v2/test.v‎

Lines changed: 83 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,6 @@ fn (h &TypeHolder) lookup_enum(name string) ?EnumType {
707707
return none
708708
}
709709

710-
711710
// ===================== MAIN TEST FUNCTION =====================
712711

713712
fn main() {
@@ -3274,12 +3273,12 @@ fn main() {
32743273
// Clone via nested selector (wrapper.holder.data.clone())
32753274
mut cloned_arr := wrap.holder.data.clone()
32763275
print_int(cloned_arr.len) // 3
3277-
print_int(cloned_arr[0]) // 10
3278-
print_int(cloned_arr[2]) // 30
3276+
print_int(cloned_arr[0]) // 10
3277+
print_int(cloned_arr[2]) // 30
32793278

32803279
// Verify clone is independent - modify cloned array
32813280
cloned_arr[0] = 99
3282-
print_int(cloned_arr[0]) // 99 (modified)
3281+
print_int(cloned_arr[0]) // 99 (modified)
32833282
print_int(wrap.holder.data[0]) // 10 (original unchanged)
32843283

32853284
// 60. Map indexing with push (map[key] << value)
@@ -3291,11 +3290,11 @@ fn main() {
32913290
pl.labels[5] << 100 // First push to key 5 - creates new array
32923291
pl.labels[5] << 200 // Second push to same key
32933292
pl.labels[10] << 50 // Push to different key
3294-
print_int(pl.labels[5].len) // 2
3295-
print_int(pl.labels[5][0]) // 100
3296-
print_int(pl.labels[5][1]) // 200
3293+
print_int(pl.labels[5].len) // 2
3294+
print_int(pl.labels[5][0]) // 100
3295+
print_int(pl.labels[5][1]) // 200
32973296
print_int(pl.labels[10].len) // 1
3298-
print_int(pl.labels[10][0]) // 50
3297+
print_int(pl.labels[10][0]) // 50
32993298

33003299
// ==================== 61. MUTABLE SLICE ARGUMENTS ====================
33013300
print_str('--- 61. Mutable slice arguments ---')
@@ -3371,7 +3370,10 @@ fn main() {
33713370
// if obj := container.method() { ... } - method returning optional
33723371

33733372
// 63.1 Method returning optional - found case
3374-
dc := DataContainer{value: 42, name: 'test'}
3373+
dc := DataContainer{
3374+
value: 42
3375+
name: 'test'
3376+
}
33753377
if val := dc.lookup('test') {
33763378
print_int(val) // 42
33773379
}
@@ -3384,7 +3386,10 @@ fn main() {
33843386
}
33853387

33863388
// 63.3 Nested method call with if-guard
3387-
dc2 := DataContainer{value: 777, name: 'found'}
3389+
dc2 := DataContainer{
3390+
value: 777
3391+
name: 'found'
3392+
}
33883393
mut result63 := 0
33893394
if v := dc2.lookup('found') {
33903395
result63 = v
@@ -3399,8 +3404,14 @@ fn main() {
33993404

34003405
// 64.1 Setup type_holder with struct and enum types
34013406
type_holder := TypeHolder{
3402-
struct_type: StructType{name: 'Point', fields: 2}
3403-
enum_type: EnumType{name: 'Color', variants: 3}
3407+
struct_type: StructType{
3408+
name: 'Point'
3409+
fields: 2
3410+
}
3411+
enum_type: EnumType{
3412+
name: 'Color'
3413+
variants: 3
3414+
}
34043415
}
34053416

34063417
// 64.2 lookup_struct - found case (asking for 'struct' returns the struct type)
@@ -3447,9 +3458,18 @@ fn main() {
34473458

34483459
// 65.1 Create map with pointer values
34493460
mut intervals := map[int]&Point{}
3450-
intervals[1] = &Point{x: 10, y: 100}
3451-
intervals[2] = &Point{x: 20, y: 200}
3452-
intervals[3] = &Point{x: 30, y: 300}
3461+
intervals[1] = &Point{
3462+
x: 10
3463+
y: 100
3464+
}
3465+
intervals[2] = &Point{
3466+
x: 20
3467+
y: 200
3468+
}
3469+
intervals[3] = &Point{
3470+
x: 30
3471+
y: 300
3472+
}
34533473

34543474
// 65.2 Iterate over map and collect pointer values
34553475
mut sum_x := 0
@@ -3539,7 +3559,10 @@ fn main() {
35393559
}
35403560

35413561
// 68.2 Basic is-check with Point variant
3542-
num2 := Number(Point{x: 10, y: 20})
3562+
num2 := Number(Point{
3563+
x: 10
3564+
y: 20
3565+
})
35433566
if num2 is Point {
35443567
print_int(num2.x) // 10 (smartcasted to Point, access field)
35453568
print_int(num2.y) // 20
@@ -3556,15 +3579,21 @@ fn main() {
35563579
}
35573580

35583581
// 68.4 Negative is-check - Point is not int
3559-
num4 := Number(Point{x: 5, y: 6})
3582+
num4 := Number(Point{
3583+
x: 5
3584+
y: 6
3585+
})
35603586
if num4 is int {
35613587
print_int(num4)
35623588
} else {
35633589
print_int(-200) // -200 (num4 is Point, not int)
35643590
}
35653591

35663592
// 68.5 Smartcast with computation
3567-
num5 := Number(Point{x: 3, y: 4})
3593+
num5 := Number(Point{
3594+
x: 3
3595+
y: 4
3596+
})
35683597
if num5 is Point {
35693598
sum := num5.x + num5.y
35703599
print_int(sum) // 7
@@ -3573,15 +3602,21 @@ fn main() {
35733602
// 68.6 Compound is-check with && and field access
35743603
// Tests: if x is Type && x.field == value { ... }
35753604
// This requires smartcast to be applied in compound conditions
3576-
num6 := Number(Point{x: 42, y: 100})
3605+
num6 := Number(Point{
3606+
x: 42
3607+
y: 100
3608+
})
35773609
if num6 is Point && num6.x == 42 {
35783610
print_int(num6.y) // 100 (smartcast applied in compound &&)
35793611
} else {
35803612
print_int(-1)
35813613
}
35823614

35833615
// 68.7 Compound is-check that fails the field check
3584-
num7 := Number(Point{x: 10, y: 20})
3616+
num7 := Number(Point{
3617+
x: 10
3618+
y: 20
3619+
})
35853620
if num7 is Point && num7.x == 999 {
35863621
print_int(-1) // Should not reach here
35873622
} else {
@@ -3651,7 +3686,10 @@ fn main() {
36513686
}
36523687

36533688
// 70.2 Match on Point variant with field access
3654-
num70b := Number(Point{x: 7, y: 8})
3689+
num70b := Number(Point{
3690+
x: 7
3691+
y: 8
3692+
})
36553693
match num70b {
36563694
int {
36573695
print_int(-1)
@@ -3663,7 +3701,10 @@ fn main() {
36633701
}
36643702

36653703
// 70.3 Match with computation on Point variant
3666-
num70c := Number(Point{x: 5, y: 5})
3704+
num70c := Number(Point{
3705+
x: 5
3706+
y: 5
3707+
})
36673708
match num70c {
36683709
int {
36693710
print_int(num70c + 1)
@@ -3687,7 +3728,10 @@ fn main() {
36873728
print_int(result70) // 198
36883729

36893730
// 70.5 Match on Point with result assignment
3690-
num70e := Number(Point{x: 3, y: 4})
3731+
num70e := Number(Point{
3732+
x: 3
3733+
y: 4
3734+
})
36913735
result70e := match num70e {
36923736
int {
36933737
-1
@@ -3723,7 +3767,10 @@ fn main() {
37233767
}
37243768

37253769
// 71.2 Nested smartcast: match outer, if-is inner (Point variant)
3726-
nested2 := NestedOuter(Number(Point{x: 7, y: 8}))
3770+
nested2 := NestedOuter(Number(Point{
3771+
x: 7
3772+
y: 8
3773+
}))
37273774
match nested2 {
37283775
Number {
37293776
// nested2 is smartcasted to Number
@@ -3755,7 +3802,10 @@ fn main() {
37553802
}
37563803

37573804
// 71.4 Nested smartcast with computation
3758-
nested4 := NestedOuter(Number(Point{x: 5, y: 6}))
3805+
nested4 := NestedOuter(Number(Point{
3806+
x: 5
3807+
y: 6
3808+
}))
37593809
match nested4 {
37603810
Number {
37613811
if nested4 is Point {
@@ -3883,7 +3933,10 @@ fn main() {
38833933
users76[3] = true
38843934
for user_id, _ in users76 {
38853935
if user_id > 1 {
3886-
errors76 << Error76{msg: 'user', val_id: user_id}
3936+
errors76 << Error76{
3937+
msg: 'user'
3938+
val_id: user_id
3939+
}
38873940
}
38883941
}
38893942
print_int(errors76.len) // 2 - two errors added
@@ -3915,7 +3968,10 @@ fn main() {
39153968
else {}
39163969
}
39173970

3918-
num77b := Number(Point{x: 10, y: 20})
3971+
num77b := Number(Point{
3972+
x: 10
3973+
y: 20
3974+
})
39193975
match num77b {
39203976
Point {
39213977
// num77b is smartcast to Point here, but process_number expects Number

0 commit comments

Comments
 (0)