OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [go/] [printer/] [testdata/] [declarations.input] - Blame information for rev 747

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 747 jeremybenn
// Copyright 2009 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
4
 
5
package imports
6
 
7
import "io"
8
 
9
import (
10
        _ "io"
11
)
12
 
13
import _ "io"
14
 
15
import (
16
        "io"
17
        "io"
18
        "io"
19
)
20
 
21
import (
22
        "io"
23
        aLongRename "io"
24
 
25
        b "io"
26
)
27
 
28
import (
29
       "unrenamed"
30
       renamed "renameMe"
31
       . "io"
32
       _ "io"
33
       "io"
34
       . "os"
35
)
36
 
37
// no newlines between consecutive single imports, but
38
// respect extra line breaks in the source (at most one empty line)
39
import _ "io"
40
import _ "io"
41
import _ "io"
42
 
43
import _ "os"
44
import _ "os"
45
import _ "os"
46
 
47
 
48
import _ "fmt"
49
import _ "fmt"
50
import _ "fmt"
51
 
52
import "foo"  // a comment
53
import "bar"  // a comment
54
 
55
import (
56
        _ "foo"
57
        // a comment
58
        "bar"
59
        "foo"  // a comment
60
        "bar"  // a comment
61
)
62
 
63
// comments + renames
64
import (
65
       "unrenamed" // a comment
66
       renamed "renameMe"
67
       . "io" /* a comment */
68
       _ "io/ioutil" // a comment
69
       "io" // testing alignment
70
       . "os"
71
       // a comment
72
)
73
 
74
// a case that caused problems in the past (comment placement)
75
import (
76
        . "fmt"
77
        "io"
78
        "malloc"        // for the malloc count test only
79
        "math"
80
        "strings"
81
        "testing"
82
)
83
 
84
// more import examples
85
import (
86
        "xxx"
87
        "much longer name" // comment
88
        "short name" // comment
89
)
90
 
91
import (
92
        _ "xxx"
93
        "much longer name" // comment
94
)
95
 
96
import (
97
        mymath "math"
98
        "/foo/bar/long_package_path" // a comment
99
)
100
 
101
import (
102
        "package_a" // comment
103
        "package_b"
104
        my_better_c "package_c" // comment
105
        "package_d" // comment
106
        my_e "package_e" // comment
107
 
108
        "package_a"    // comment
109
        "package_bb"
110
        "package_ccc"  // comment
111
        "package_dddd" // comment
112
)
113
 
114
// at least one empty line between declarations of different kind
115
import _ "io"
116
var _ int
117
 
118
// at least one empty line between declarations of the same kind
119
// if there is associated documentation (was issue 2570)
120
type T1 struct{}
121
// T2 comment
122
type T2 struct {
123
} // should be a two-line struct
124
 
125
 
126
// T3 comment
127
type T2 struct {
128
 
129
 
130
} // should be a two-line struct
131
 
132
 
133
// printing of constant literals
134
const (
135
        _ = "foobar"
136
        _ = "aÛ°Û±Û¸"
137
        _ = "foo६४"
138
        _ = "bar9876"
139
        _ = 0
140
        _ = 1
141
        _ = 123456789012345678890
142
        _ = 01234567
143
        _ = 0xcafebabe
144
        _ = 0.
145
        _ = .0
146
        _ = 3.14159265
147
        _ = 1e0
148
        _ = 1e+100
149
        _ = 1e-100
150
        _ = 2.71828e-1000
151
        _ = 0i
152
        _ = 1i
153
        _ = 012345678901234567889i
154
        _ = 123456789012345678890i
155
        _ = 0.i
156
        _ = .0i
157
        _ = 3.14159265i
158
        _ = 1e0i
159
        _ = 1e+100i
160
        _ = 1e-100i
161
        _ = 2.71828e-1000i
162
        _ = 'a'
163
        _ = '\000'
164
        _ = '\xFF'
165
        _ = '\uff16'
166
        _ = '\U0000ff16'
167
        _ = `foobar`
168
        _ = `foo
169
---
170
---
171
bar`
172
)
173
 
174
 
175
func _() {
176
        type _ int
177
        type _ *int
178
        type _ []int
179
        type _ map[string]int
180
        type _ chan int
181
        type _ func() int
182
 
183
        var _ int
184
        var _ *int
185
        var _ []int
186
        var _ map[string]int
187
        var _ chan int
188
        var _ func() int
189
 
190
        type _ struct{}
191
        type _ *struct{}
192
        type _ []struct{}
193
        type _ map[string]struct{}
194
        type _ chan struct{}
195
        type _ func() struct{}
196
 
197
        type _ interface{}
198
        type _ *interface{}
199
        type _ []interface{}
200
        type _ map[string]interface{}
201
        type _ chan interface{}
202
        type _ func() interface{}
203
 
204
        var _ struct{}
205
        var _ *struct{}
206
        var _ []struct{}
207
        var _ map[string]struct{}
208
        var _ chan struct{}
209
        var _ func() struct{}
210
 
211
        var _ interface{}
212
        var _ *interface{}
213
        var _ []interface{}
214
        var _ map[string]interface{}
215
        var _ chan interface{}
216
        var _ func() interface{}
217
}
218
 
219
 
220
// don't lose blank lines in grouped declarations
221
const (
222
        _ int = 0
223
        _ float = 1
224
 
225
        _ string = "foo"
226
 
227
        _ = iota
228
        _
229
 
230
        // a comment
231
        _
232
 
233
        _
234
)
235
 
236
 
237
type (
238
        _ int
239
        _ struct {}
240
 
241
        _ interface{}
242
 
243
        // a comment
244
        _ map[string]int
245
)
246
 
247
 
248
var (
249
        _ int = 0
250
        _ float = 1
251
 
252
        _ string = "foo"
253
 
254
        _ bool
255
 
256
        // a comment
257
        _ bool
258
)
259
 
260
 
261
// don't lose blank lines in this struct
262
type _ struct {
263
        String struct {
264
                Str, Len int
265
        }
266
        Slice struct {
267
                Array, Len, Cap int
268
        }
269
        Eface struct {
270
                Typ, Ptr int
271
        }
272
 
273
        UncommonType struct {
274
                Name, PkgPath int
275
        }
276
        CommonType struct {
277
                Size, Hash, Alg, Align, FieldAlign, String, UncommonType int
278
        }
279
        Type struct {
280
                Typ, Ptr int
281
        }
282
        StructField struct {
283
                Name, PkgPath, Typ, Tag, Offset int
284
        }
285
        StructType struct {
286
                Fields int
287
        }
288
        PtrType struct {
289
                Elem int
290
        }
291
        SliceType struct {
292
                Elem int
293
        }
294
        ArrayType struct {
295
                Elem, Len int
296
        }
297
 
298
        Stktop struct {
299
                Stackguard, Stackbase, Gobuf int
300
        }
301
        Gobuf struct {
302
                Sp, Pc, G int
303
        }
304
        G struct {
305
                Stackbase, Sched, Status, Alllink int
306
        }
307
}
308
 
309
 
310
// no blank lines in empty structs and interfaces, but leave 1- or 2-line layout alone
311
type _ struct{            }
312
type _ struct {
313
 
314
}
315
 
316
type _ interface{            }
317
type _ interface {
318
 
319
}
320
 
321
 
322
// no tabs for single or ungrouped decls
323
func _() {
324
        const xxxxxx = 0
325
        type x int
326
        var xxx int
327
        var yyyy float = 3.14
328
        var zzzzz = "bar"
329
 
330
        const (
331
                xxxxxx = 0
332
        )
333
        type (
334
                x int
335
        )
336
        var (
337
                xxx int
338
        )
339
        var (
340
                yyyy float = 3.14
341
        )
342
        var (
343
                zzzzz = "bar"
344
        )
345
}
346
 
347
// tabs for multiple or grouped decls
348
func _() {
349
        // no entry has a type
350
        const (
351
                zzzzzz = 1
352
                z = 2
353
                zzz = 3
354
        )
355
        // some entries have a type
356
        const (
357
                xxxxxx = 1
358
                x = 2
359
                xxx = 3
360
                yyyyyyyy float = iota
361
                yyyy = "bar"
362
                yyy
363
                yy = 2
364
        )
365
}
366
 
367
func _() {
368
        // no entry has a type
369
        var (
370
                zzzzzz = 1
371
                z = 2
372
                zzz = 3
373
        )
374
        // no entry has a value
375
        var (
376
                _ int
377
                _ float
378
                _ string
379
 
380
                _ int  // comment
381
                _ float  // comment
382
                _ string  // comment
383
        )
384
        // some entries have a type
385
        var (
386
                xxxxxx int
387
                x float
388
                xxx string
389
                yyyyyyyy int = 1234
390
                y float = 3.14
391
                yyyy = "bar"
392
                yyy string = "foo"
393
        )
394
        // mixed entries - all comments should be aligned
395
        var (
396
                a, b, c int
397
                x = 10
398
                d int  // comment
399
                y = 20  // comment
400
                f, ff, fff, ffff int = 0, 1, 2, 3  // comment
401
        )
402
        // respect original line breaks
403
        var _ = []T {
404
                T{0x20, "Telugu"},
405
        }
406
        var _ = []T {
407
                // respect original line breaks
408
                T{0x20, "Telugu"},
409
        }
410
}
411
 
412
func _() {
413
        type (
414
                xxxxxx int
415
                x float
416
                xxx string
417
                xxxxx []x
418
                xx struct{}
419
                xxxxxxx struct {
420
                        _, _ int
421
                        _ float
422
                }
423
                xxxx chan<- string
424
        )
425
}
426
 
427
// alignment of "=" in consecutive lines (extended example from issue 1414)
428
const (
429
        umax uint                  = ^uint(0) // maximum value for a uint
430
        bpu  = 1 << (5 + umax>>63)            // bits per uint
431
        foo
432
        bar  = -1
433
)
434
 
435
// typical enum
436
const (
437
        a MyType = iota
438
        abcd
439
        b
440
        c
441
        def
442
)
443
 
444
// excerpt from godoc.go
445
var (
446
        goroot = flag.String("goroot", runtime.GOROOT(), "Go root directory")
447
        testDir = flag.String("testdir", "", "Go root subdirectory - for testing only (faster startups)")
448
        pkgPath = flag.String("path", "", "additional package directories (colon-separated)")
449
        filter = flag.String("filter", "", "filter file containing permitted package directory paths")
450
        filterMin = flag.Int("filter_minutes", 0, "filter file update interval in minutes; disabled if <= 0")
451
        filterDelay delayTime // actual filter update interval in minutes; usually filterDelay == filterMin, but filterDelay may back off exponentially
452
)
453
 
454
 
455
// formatting of structs
456
type _ struct{}
457
 
458
type _ struct{ /* this comment should be visible */ }
459
 
460
type _ struct{
461
        // this comment should be visible and properly indented
462
}
463
 
464
type _ struct {  // this comment must not change indentation
465
        f int
466
        f, ff, fff, ffff int
467
}
468
 
469
type _ struct {
470
        string
471
}
472
 
473
type _ struct {
474
        string  // comment
475
}
476
 
477
type _ struct {
478
        string "tag"
479
}
480
 
481
type _ struct {
482
        string "tag"  // comment
483
}
484
 
485
type _ struct {
486
        f int
487
}
488
 
489
type _ struct {
490
        f int  // comment
491
}
492
 
493
type _ struct {
494
        f int "tag"
495
}
496
 
497
type _ struct {
498
        f int "tag"  // comment
499
}
500
 
501
type _ struct {
502
        bool
503
        a, b, c int
504
        int "tag"
505
        ES // comment
506
        float "tag"  // comment
507
        f int  // comment
508
        f, ff, fff, ffff int  // comment
509
        g float "tag"
510
        h float "tag"  // comment
511
}
512
 
513
type _ struct { a, b,
514
c, d int  // this line should be indented
515
u, v, w, x float // this line should be indented
516
p, q,
517
r, s float // this line should be indented
518
}
519
 
520
 
521
// difficult cases
522
type _ struct {
523
        bool  // comment
524
        text []byte  // comment
525
}
526
 
527
 
528
// formatting of interfaces
529
type EI interface{}
530
 
531
type _ interface {
532
        EI
533
}
534
 
535
type _ interface {
536
        f()
537
        fffff()
538
}
539
 
540
type _ interface {
541
        EI
542
        f()
543
        fffffg()
544
}
545
 
546
type _ interface {  // this comment must not change indentation
547
        EI  // here's a comment
548
        f()  // no blank between identifier and ()
549
        fffff()  // no blank between identifier and ()
550
        gggggggggggg(x, y, z int) ()  // hurray
551
}
552
 
553
 
554
// formatting of variable declarations
555
func _() {
556
        type day struct { n int; short, long string }
557
        var (
558
                Sunday = day{ 0, "SUN", "Sunday" }
559
                Monday = day{ 1, "MON", "Monday" }
560
                Tuesday = day{ 2, "TUE", "Tuesday" }
561
                Wednesday = day{ 3, "WED", "Wednesday" }
562
                Thursday = day{ 4, "THU", "Thursday" }
563
                Friday = day{ 5, "FRI", "Friday" }
564
                Saturday = day{ 6, "SAT", "Saturday" }
565
        )
566
}
567
 
568
 
569
// formatting of multi-line variable declarations
570
var a1, b1, c1 int  // all on one line
571
 
572
var a2, b2,
573
c2 int  // this line should be indented
574
 
575
var (a3, b3,
576
c3, d3 int  // this line should be indented
577
a4, b4, c4 int  // this line should be indented
578
)
579
 
580
 
581
func _() {
582
        var privateKey2 = &Block{Type: "RSA PRIVATE KEY",
583
                                        Headers: map[string]string{},
584
                                        Bytes: []uint8{0x30, 0x82, 0x1, 0x3a, 0x2, 0x1, 0x0, 0x2,
585
                        0x41, 0x0, 0xb2, 0x99, 0xf, 0x49, 0xc4, 0x7d, 0xfa, 0x8c,
586
                        0xd4, 0x0, 0xae, 0x6a, 0x4d, 0x1b, 0x8a, 0x3b, 0x6a, 0x13,
587
                        0x64, 0x2b, 0x23, 0xf2, 0x8b, 0x0, 0x3b, 0xfb, 0x97, 0x79,
588
                },
589
        }
590
}
591
 
592
 
593
func _() {
594
        var Universe = Scope {
595
                Names: map[string]*Ident {
596
                        // basic types
597
                        "bool": nil,
598
                        "byte": nil,
599
                        "int8": nil,
600
                        "int16": nil,
601
                        "int32": nil,
602
                        "int64": nil,
603
                        "uint8": nil,
604
                        "uint16": nil,
605
                        "uint32": nil,
606
                        "uint64": nil,
607
                        "float32": nil,
608
                        "float64": nil,
609
                        "string": nil,
610
 
611
                        // convenience types
612
                        "int": nil,
613
                        "uint": nil,
614
                        "uintptr": nil,
615
                        "float": nil,
616
 
617
                        // constants
618
                        "false": nil,
619
                        "true": nil,
620
                        "iota": nil,
621
                        "nil": nil,
622
 
623
                        // functions
624
                        "cap": nil,
625
                        "len": nil,
626
                        "new": nil,
627
                        "make": nil,
628
                        "panic": nil,
629
                        "panicln": nil,
630
                        "print": nil,
631
                        "println": nil,
632
                },
633
        }
634
}
635
 
636
 
637
// alignment of map composite entries
638
var _ = map[int]int{
639
        // small key sizes: always align even if size ratios are large
640
        a: a,
641
        abcdefghabcdefgh: a,
642
        ab: a,
643
        abc: a,
644
        abcdefgabcdefg: a,
645
        abcd: a,
646
        abcde: a,
647
        abcdef: a,
648
 
649
        // mixed key sizes: align when key sizes change within accepted ratio
650
        abcdefgh: a,
651
        abcdefghabcdefg: a,
652
        abcdefghij: a,
653
        abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij: a, // outlier - do not align with previous line
654
        abcdefghijabcdefghijabcdefghijabcdefghijabcdefghijabcdefghij: a, // align with previous line
655
 
656
        ab: a, // do not align with previous line
657
        abcde: a, // align with previous line
658
}
659
 
660
 
661
func _() {
662
        var _ = T{
663
                a,      // must introduce trailing comma
664
        }
665
}
666
 
667
 
668
// formatting of function results
669
func _() func() {}
670
func _() func(int) { return nil }
671
func _() func(int) int { return nil }
672
func _() func(int) func(int) func() { return nil }
673
 
674
 
675
// formatting of consecutive single-line functions
676
func _() {}
677
func _() {}
678
func _() {}
679
 
680
func _() {}  // an empty line before this function
681
func _() {}
682
func _() {}
683
 
684
func _() { f(1, 2, 3) }
685
func _(x int) int { y := x; return y+1 }
686
func _() int { type T struct{}; var x T; return x }
687
 
688
// these must remain multi-line since they are multi-line in the source
689
func _() {
690
        f(1, 2, 3)
691
}
692
func _(x int) int {
693
        y := x; return y+1
694
}
695
func _() int {
696
        type T struct{}; var x T; return x
697
}
698
 
699
 
700
// making function declarations safe for new semicolon rules
701
func _() { /* multi-line func because of comment */ }
702
 
703
func _() {
704
/* multi-line func because block is on multiple lines */ }
705
 
706
 
707
// ellipsis parameters
708
func _(...int)
709
func _(...*int)
710
func _(...[]int)
711
func _(...struct{})
712
func _(bool, ...interface{})
713
func _(bool, ...func())
714
func _(bool, ...func(...int))
715
func _(bool, ...map[string]int)
716
func _(bool, ...chan int)
717
 
718
func _(b bool, x ...int)
719
func _(b bool, x ...*int)
720
func _(b bool, x ...[]int)
721
func _(b bool, x ...struct{})
722
func _(x ...interface{})
723
func _(x ...func())
724
func _(x ...func(...int))
725
func _(x ...map[string]int)
726
func _(x ...chan int)
727
 
728
 
729
// these parameter lists must remain multi-line since they are multi-line in the source
730
func _(bool,
731
int) {
732
}
733
func _(x bool,
734
y int) {
735
}
736
func _(x,
737
y bool) {
738
}
739
func _(bool, // comment
740
int) {
741
}
742
func _(x bool, // comment
743
y int) {
744
}
745
func _(x, // comment
746
y bool) {
747
}
748
func _(bool, // comment
749
// comment
750
int) {
751
}
752
func _(x bool, // comment
753
// comment
754
y int) {
755
}
756
func _(x, // comment
757
// comment
758
y bool) {
759
}
760
func _(bool,
761
// comment
762
int) {
763
}
764
func _(x bool,
765
// comment
766
y int) {
767
}
768
func _(x,
769
// comment
770
y bool) {
771
}
772
func _(x, // comment
773
y,// comment
774
z bool) {
775
}
776
func _(x, // comment
777
        y,// comment
778
        z bool) {
779
}
780
func _(x int,   // comment
781
        y float,        // comment
782
        z bool) {
783
}
784
 
785
 
786
// properly indent multi-line signatures
787
func ManageStatus(in <-chan *Status, req <-chan Request,
788
stat chan<- *TargetInfo,
789
TargetHistorySize int) {
790
}
791
 
792
func MultiLineSignature0(
793
a, b, c int,
794
) {}
795
 
796
func MultiLineSignature1(
797
a, b, c int,
798
u, v, w float,
799
) {}
800
 
801
func MultiLineSignature2(
802
a, b,
803
c int,
804
) {}
805
 
806
func MultiLineSignature3(
807
a, b,
808
c int, u, v,
809
w float,
810
                x ...int) {}
811
 
812
func MultiLineSignature4(
813
a, b, c int,
814
u, v,
815
w float,
816
                x ...int) {}
817
 
818
func MultiLineSignature5(
819
a, b, c int,
820
u, v, w float,
821
p, q,
822
r string,
823
                x ...int) {}
824
 
825
// make sure it also works for methods in interfaces
826
type _ interface {
827
MultiLineSignature0(
828
a, b, c int,
829
)
830
 
831
MultiLineSignature1(
832
a, b, c int,
833
u, v, w float,
834
)
835
 
836
MultiLineSignature2(
837
a, b,
838
c int,
839
)
840
 
841
MultiLineSignature3(
842
a, b,
843
c int, u, v,
844
w float,
845
                x ...int)
846
 
847
MultiLineSignature4(
848
a, b, c int,
849
u, v,
850
w float,
851
                x ...int)
852
 
853
MultiLineSignature5(
854
a, b, c int,
855
u, v, w float,
856
p, q,
857
r string,
858
                x ...int)
859
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.