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

Subversion Repositories openrisc

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

powered by: WebSVN 2.1.0

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