Use unique type param names in test

This makes it clearer when changes in test results
are due to changes in the standard library.
This commit is contained in:
Owen Mansel-Chan
2024-08-20 16:26:01 +01:00
committed by Michael B. Gale
parent 3a8a7ea67d
commit 7589186583
6 changed files with 99 additions and 82 deletions

View File

@@ -1,8 +1,8 @@
| genericFunctions.go:25:2:25:33 | generic function instantiation expression | genericFunctions.go:25:2:25:28 | GenericFunctionOneTypeParam | 0 | genericFunctions.go:25:30:25:32 | int |
| genericFunctions.go:26:2:26:36 | generic function instantiation expression | genericFunctions.go:26:2:26:28 | GenericFunctionOneTypeParam | 0 | genericFunctions.go:26:30:26:35 | string |
| genericFunctions.go:44:6:44:48 | generic function instantiation expression | genericFunctions.go:44:6:44:33 | GenericFunctionTwoTypeParams | 0 | genericFunctions.go:44:35:44:40 | string |
| genericFunctions.go:44:6:44:48 | generic function instantiation expression | genericFunctions.go:44:6:44:33 | GenericFunctionTwoTypeParams | 1 | genericFunctions.go:44:43:44:47 | int64 |
| genericFunctions.go:45:6:45:50 | generic function instantiation expression | genericFunctions.go:45:6:45:33 | GenericFunctionTwoTypeParams | 0 | genericFunctions.go:45:35:45:40 | string |
| genericFunctions.go:45:6:45:50 | generic function instantiation expression | genericFunctions.go:45:6:45:33 | GenericFunctionTwoTypeParams | 1 | genericFunctions.go:45:43:45:49 | float64 |
| genericFunctions.go:141:6:141:41 | generic function instantiation expression | genericFunctions.go:141:6:141:33 | GenericFunctionInAnotherFile | 0 | genericFunctions.go:141:35:141:40 | string |
| genericFunctions.go:146:6:146:55 | generic function instantiation expression | genericFunctions.go:146:6:146:47 | selection of GenericFunctionInAnotherPackage | 0 | genericFunctions.go:146:49:146:54 | string |
| genericFunctions.go:27:2:27:33 | generic function instantiation expression | genericFunctions.go:27:2:27:28 | GenericFunctionOneTypeParam | 0 | genericFunctions.go:27:30:27:32 | int |
| genericFunctions.go:28:2:28:36 | generic function instantiation expression | genericFunctions.go:28:2:28:28 | GenericFunctionOneTypeParam | 0 | genericFunctions.go:28:30:28:35 | string |
| genericFunctions.go:46:6:46:48 | generic function instantiation expression | genericFunctions.go:46:6:46:33 | GenericFunctionTwoTypeParams | 0 | genericFunctions.go:46:35:46:40 | string |
| genericFunctions.go:46:6:46:48 | generic function instantiation expression | genericFunctions.go:46:6:46:33 | GenericFunctionTwoTypeParams | 1 | genericFunctions.go:46:43:46:47 | int64 |
| genericFunctions.go:47:6:47:50 | generic function instantiation expression | genericFunctions.go:47:6:47:33 | GenericFunctionTwoTypeParams | 0 | genericFunctions.go:47:35:47:40 | string |
| genericFunctions.go:47:6:47:50 | generic function instantiation expression | genericFunctions.go:47:6:47:33 | GenericFunctionTwoTypeParams | 1 | genericFunctions.go:47:43:47:49 | float64 |
| genericFunctions.go:143:6:143:41 | generic function instantiation expression | genericFunctions.go:143:6:143:33 | GenericFunctionInAnotherFile | 0 | genericFunctions.go:143:35:143:40 | string |
| genericFunctions.go:148:6:148:55 | generic function instantiation expression | genericFunctions.go:148:6:148:47 | selection of GenericFunctionInAnotherPackage | 0 | genericFunctions.go:148:49:148:54 | string |

View File

@@ -1,30 +1,45 @@
| E | Ordered |
| E | any |
| E | comparable |
| E | interface { } |
| E1 | interface { } |
| E2 | interface { } |
| Edge | EdgeConstraint |
| Edge | interface { } |
| E | interface { ~uint16 \| ~uint32 } |
| E1 | any |
| E2 | any |
| F | floaty |
| K | comparable |
| Node | NodeConstraint |
| Node | interface { } |
| S | interface { } |
| K | any |
| N | interface { int64 \| uint64 } |
| S | interface { ~[]E } |
| S1 | interface { ~[]E1 } |
| S2 | interface { ~[]E2 } |
| SF2 | interface { } |
| SG2 | interface { } |
| Slice | interface { ~[]E } |
| T | Ordered |
| T | any |
| T | comparable |
| T | interface { string \| []uint8 } |
| T | interface { } |
| T1 | interface { } |
| T2 | interface { } |
| TF1 | interface { } |
| TF2 | interface { } |
| TG1 | interface { } |
| TG2 | interface { } |
| U | interface { } |
| V | interface { int64 \| float64 } |
| T1 | any |
| T2 | any |
| TP101 | any |
| TP102 | comparable |
| TP103 | interface { int64 \| float64 } |
| TP104 | interface { } |
| TP105 | any |
| TP106 | any |
| TP107 | interface { } |
| TP108 | interface { } |
| TP109 | any |
| TP110 | any |
| TP111 | any |
| TP112 | any |
| TP113 | any |
| TP114 | any |
| TP115 | any |
| TP116 | any |
| TP117 | any |
| TP118 | NodeConstraint |
| TP119 | EdgeConstraint |
| TP120 | NodeConstraint |
| TP121 | EdgeConstraint |
| TP122 | NodeConstraint |
| TP123 | EdgeConstraint |
| TP200 | any |
| V | any |
| bytes | interface { []uint8 \| string } |

View File

@@ -2,18 +2,20 @@ package main
import "github.com/anotherpkg"
type T1 map[string][]string
type T2 T1
type DefinedType1 map[string][]string
type DefinedType2 DefinedType1
type AliasType1 = DefinedType2
type AliasType2 = AliasType1
// A generic function with one type parameter
func GenericFunctionOneTypeParam[T any](t T) T {
var r T
func GenericFunctionOneTypeParam[TP101 any](t TP101) TP101 {
var r TP101
return r
}
// A generic function with two type parameter
func GenericFunctionTwoTypeParams[K comparable, V int64 | float64](m map[K]V) V {
var s V
func GenericFunctionTwoTypeParams[TP102 comparable, TP103 int64 | float64](m map[TP102]TP103) TP103 {
var s TP103
for _, v := range m {
s += v
}
@@ -78,24 +80,24 @@ func generic_functions() {
aliasedMap["key"][0] = "new value"
}
type GenericStruct1[T any] struct {
type GenericStruct1[TP104 interface{}] struct {
}
type GenericStruct2[S, T any] struct {
type GenericStruct2[TP105, TP106 any] struct {
}
func (x GenericStruct1[TF1]) f1() TF1 {
var r TF1
func (x GenericStruct1[TP107]) f1() TP107 {
var r TP107
return r
}
func (x *GenericStruct1[TG1]) g1() {
func (x *GenericStruct1[TP108]) g1() {
}
func (x GenericStruct2[SF2, TF2]) f2() {
func (x GenericStruct2[TP109, TP110]) f2() {
}
func (x *GenericStruct2[SG2, TG2]) g2() {
func (x *GenericStruct2[TP111, TP112]) g2() {
}
func call_methods_with_generic_receiver() {
@@ -108,34 +110,34 @@ func call_methods_with_generic_receiver() {
x2.g2()
}
type Element[S any] struct {
list *List[S]
type Element[TP113 any] struct {
list *List[TP113]
}
type List[T any] struct {
root Element[T]
type List[TP114 any] struct {
root Element[TP114]
}
// Len is the number of elements in the list.
func (l *List[U]) MyLen() int {
func (l *List[TP115]) MyLen() int {
return 0
}
type NodeConstraint[Edge any] interface {
Edges() []Edge
type NodeConstraint[TP116 any] interface {
Edges() []TP116
}
type EdgeConstraint[Node any] interface {
Nodes() (from, to Node)
type EdgeConstraint[TP117 any] interface {
Nodes() (from, to TP117)
}
type Graph[Node NodeConstraint[Edge], Edge EdgeConstraint[Node]] struct{}
type Graph[TP118 NodeConstraint[TP119], TP119 EdgeConstraint[TP118]] struct{}
func New[Node NodeConstraint[Edge], Edge EdgeConstraint[Node]](nodes []Node) *Graph[Node, Edge] {
func New[TP120 NodeConstraint[TP121], TP121 EdgeConstraint[TP120]](nodes []TP120) *Graph[TP120, TP121] {
return nil
}
func (g *Graph[Node, Edge]) ShortestPath(from, to Node) []Edge { return []Edge{} }
func (g *Graph[TP122, TP123]) ShortestPath(from, to TP122) []TP123 { return []TP123{} }
func callFunctionsInAnotherFile() {
_ = GenericFunctionInAnotherFile[string]("world")

View File

@@ -1,6 +1,6 @@
package main
func GenericFunctionInAnotherFile[T any](t T) T {
var r T
func GenericFunctionInAnotherFile[TP200 any](t TP200) TP200 {
var r TP200
return r
}

View File

@@ -1,15 +1,15 @@
| genericFunctions2.go:3:6:3:33 | GenericFunctionInAnotherFile | 0 | genericFunctions2.go:3:42:3:42 | t |
| genericFunctions.go:9:6:9:32 | GenericFunctionOneTypeParam | 0 | genericFunctions.go:9:41:9:41 | t |
| genericFunctions.go:15:6:15:33 | GenericFunctionTwoTypeParams | 0 | genericFunctions.go:15:68:15:68 | m |
| genericFunctions.go:87:30:87:31 | f1 | -1 | genericFunctions.go:87:7:87:7 | x |
| genericFunctions.go:92:31:92:32 | g1 | -1 | genericFunctions.go:92:7:92:7 | x |
| genericFunctions.go:95:35:95:36 | f2 | -1 | genericFunctions.go:95:7:95:7 | x |
| genericFunctions.go:98:36:98:37 | g2 | -1 | genericFunctions.go:98:7:98:7 | x |
| genericFunctions.go:120:19:120:23 | MyLen | -1 | genericFunctions.go:120:7:120:7 | l |
| genericFunctions.go:134:6:134:8 | New | 0 | genericFunctions.go:134:64:134:68 | nodes |
| genericFunctions.go:138:29:138:40 | ShortestPath | 0 | genericFunctions.go:138:42:138:45 | from |
| genericFunctions.go:138:29:138:40 | ShortestPath | 1 | genericFunctions.go:138:48:138:49 | to |
| genericFunctions.go:138:29:138:40 | ShortestPath | -1 | genericFunctions.go:138:7:138:7 | g |
| genericFunctions2.go:3:6:3:33 | GenericFunctionInAnotherFile | 0 | genericFunctions2.go:3:46:3:46 | t |
| genericFunctions.go:11:6:11:32 | GenericFunctionOneTypeParam | 0 | genericFunctions.go:11:45:11:45 | t |
| genericFunctions.go:17:6:17:33 | GenericFunctionTwoTypeParams | 0 | genericFunctions.go:17:76:17:76 | m |
| genericFunctions.go:89:32:89:33 | f1 | -1 | genericFunctions.go:89:7:89:7 | x |
| genericFunctions.go:94:33:94:34 | g1 | -1 | genericFunctions.go:94:7:94:7 | x |
| genericFunctions.go:97:39:97:40 | f2 | -1 | genericFunctions.go:97:7:97:7 | x |
| genericFunctions.go:100:40:100:41 | g2 | -1 | genericFunctions.go:100:7:100:7 | x |
| genericFunctions.go:122:23:122:27 | MyLen | -1 | genericFunctions.go:122:7:122:7 | l |
| genericFunctions.go:136:6:136:8 | New | 0 | genericFunctions.go:136:68:136:72 | nodes |
| genericFunctions.go:140:31:140:42 | ShortestPath | 0 | genericFunctions.go:140:44:140:47 | from |
| genericFunctions.go:140:31:140:42 | ShortestPath | 1 | genericFunctions.go:140:50:140:51 | to |
| genericFunctions.go:140:31:140:42 | ShortestPath | -1 | genericFunctions.go:140:7:140:7 | g |
| main.go:7:6:7:7 | f1 | 0 | main.go:7:9:7:9 | x |
| main.go:9:12:9:13 | f2 | 0 | main.go:9:15:9:15 | x |
| main.go:9:12:9:13 | f2 | 1 | main.go:9:18:9:18 | y |

View File

@@ -1,15 +1,15 @@
| genericFunctions2.go:3:1:6:1 | function declaration | FuncDecl | 0 | genericFunctions2.go:3:35:3:39 | type parameter declaration | 0 | genericFunctions2.go:3:35:3:35 | T | genericFunctions2.go:3:37:3:39 | any | interface { } |
| genericFunctions.go:9:1:12:1 | function declaration | FuncDecl | 0 | genericFunctions.go:9:34:9:38 | type parameter declaration | 0 | genericFunctions.go:9:34:9:34 | T | genericFunctions.go:9:36:9:38 | any | interface { } |
| genericFunctions.go:15:1:21:1 | function declaration | FuncDecl | 0 | genericFunctions.go:15:35:15:46 | type parameter declaration | 0 | genericFunctions.go:15:35:15:35 | K | genericFunctions.go:15:37:15:46 | comparable | comparable |
| genericFunctions.go:15:1:21:1 | function declaration | FuncDecl | 1 | genericFunctions.go:15:49:15:65 | type parameter declaration | 0 | genericFunctions.go:15:49:15:49 | V | genericFunctions.go:15:51:15:65 | type set literal | interface { int64 \| float64 } |
| genericFunctions.go:81:6:82:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:81:21:81:25 | type parameter declaration | 0 | genericFunctions.go:81:21:81:21 | T | genericFunctions.go:81:23:81:25 | any | interface { } |
| genericFunctions.go:84:6:85:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:84:21:84:28 | type parameter declaration | 0 | genericFunctions.go:84:21:84:21 | S | genericFunctions.go:84:26:84:28 | any | interface { } |
| genericFunctions.go:84:6:85:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:84:21:84:28 | type parameter declaration | 1 | genericFunctions.go:84:24:84:24 | T | genericFunctions.go:84:26:84:28 | any | interface { } |
| genericFunctions.go:111:6:113:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:111:14:111:18 | type parameter declaration | 0 | genericFunctions.go:111:14:111:14 | S | genericFunctions.go:111:16:111:18 | any | interface { } |
| genericFunctions.go:115:6:117:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:115:11:115:15 | type parameter declaration | 0 | genericFunctions.go:115:11:115:11 | T | genericFunctions.go:115:13:115:15 | any | interface { } |
| genericFunctions.go:124:6:126:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:124:21:124:28 | type parameter declaration | 0 | genericFunctions.go:124:21:124:24 | Edge | genericFunctions.go:124:26:124:28 | any | interface { } |
| genericFunctions.go:128:6:130:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:128:21:128:28 | type parameter declaration | 0 | genericFunctions.go:128:21:128:24 | Node | genericFunctions.go:128:26:128:28 | any | interface { } |
| genericFunctions.go:132:6:132:73 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:132:12:132:36 | type parameter declaration | 0 | genericFunctions.go:132:12:132:15 | Node | genericFunctions.go:132:17:132:36 | generic type instantiation expression | NodeConstraint |
| genericFunctions.go:132:6:132:73 | type declaration specifier | TypeSpec | 1 | genericFunctions.go:132:39:132:63 | type parameter declaration | 0 | genericFunctions.go:132:39:132:42 | Edge | genericFunctions.go:132:44:132:63 | generic type instantiation expression | EdgeConstraint |
| genericFunctions.go:134:1:136:1 | function declaration | FuncDecl | 0 | genericFunctions.go:134:10:134:34 | type parameter declaration | 0 | genericFunctions.go:134:10:134:13 | Node | genericFunctions.go:134:15:134:34 | generic type instantiation expression | NodeConstraint |
| genericFunctions.go:134:1:136:1 | function declaration | FuncDecl | 1 | genericFunctions.go:134:37:134:61 | type parameter declaration | 0 | genericFunctions.go:134:37:134:40 | Edge | genericFunctions.go:134:42:134:61 | generic type instantiation expression | EdgeConstraint |
| genericFunctions2.go:3:1:6:1 | function declaration | FuncDecl | 0 | genericFunctions2.go:3:35:3:43 | type parameter declaration | 0 | genericFunctions2.go:3:35:3:39 | TP200 | genericFunctions2.go:3:41:3:43 | any | any |
| genericFunctions.go:11:1:14:1 | function declaration | FuncDecl | 0 | genericFunctions.go:11:34:11:42 | type parameter declaration | 0 | genericFunctions.go:11:34:11:38 | TP101 | genericFunctions.go:11:40:11:42 | any | any |
| genericFunctions.go:17:1:23:1 | function declaration | FuncDecl | 0 | genericFunctions.go:17:35:17:50 | type parameter declaration | 0 | genericFunctions.go:17:35:17:39 | TP102 | genericFunctions.go:17:41:17:50 | comparable | comparable |
| genericFunctions.go:17:1:23:1 | function declaration | FuncDecl | 1 | genericFunctions.go:17:53:17:73 | type parameter declaration | 0 | genericFunctions.go:17:53:17:57 | TP103 | genericFunctions.go:17:59:17:73 | type set literal | interface { int64 \| float64 } |
| genericFunctions.go:83:6:84:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:83:21:83:37 | type parameter declaration | 0 | genericFunctions.go:83:21:83:25 | TP104 | genericFunctions.go:83:27:83:37 | interface type | interface { } |
| genericFunctions.go:86:6:87:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:86:21:86:36 | type parameter declaration | 0 | genericFunctions.go:86:21:86:25 | TP105 | genericFunctions.go:86:34:86:36 | any | any |
| genericFunctions.go:86:6:87:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:86:21:86:36 | type parameter declaration | 1 | genericFunctions.go:86:28:86:32 | TP106 | genericFunctions.go:86:34:86:36 | any | any |
| genericFunctions.go:113:6:115:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:113:14:113:22 | type parameter declaration | 0 | genericFunctions.go:113:14:113:18 | TP113 | genericFunctions.go:113:20:113:22 | any | any |
| genericFunctions.go:117:6:119:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:117:11:117:19 | type parameter declaration | 0 | genericFunctions.go:117:11:117:15 | TP114 | genericFunctions.go:117:17:117:19 | any | any |
| genericFunctions.go:126:6:128:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:126:21:126:29 | type parameter declaration | 0 | genericFunctions.go:126:21:126:25 | TP116 | genericFunctions.go:126:27:126:29 | any | any |
| genericFunctions.go:130:6:132:1 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:130:21:130:29 | type parameter declaration | 0 | genericFunctions.go:130:21:130:25 | TP117 | genericFunctions.go:130:27:130:29 | any | any |
| genericFunctions.go:134:6:134:77 | type declaration specifier | TypeSpec | 0 | genericFunctions.go:134:12:134:38 | type parameter declaration | 0 | genericFunctions.go:134:12:134:16 | TP118 | genericFunctions.go:134:18:134:38 | generic type instantiation expression | NodeConstraint |
| genericFunctions.go:134:6:134:77 | type declaration specifier | TypeSpec | 1 | genericFunctions.go:134:41:134:67 | type parameter declaration | 0 | genericFunctions.go:134:41:134:45 | TP119 | genericFunctions.go:134:47:134:67 | generic type instantiation expression | EdgeConstraint |
| genericFunctions.go:136:1:138:1 | function declaration | FuncDecl | 0 | genericFunctions.go:136:10:136:36 | type parameter declaration | 0 | genericFunctions.go:136:10:136:14 | TP120 | genericFunctions.go:136:16:136:36 | generic type instantiation expression | NodeConstraint |
| genericFunctions.go:136:1:138:1 | function declaration | FuncDecl | 1 | genericFunctions.go:136:39:136:65 | type parameter declaration | 0 | genericFunctions.go:136:39:136:43 | TP121 | genericFunctions.go:136:45:136:65 | generic type instantiation expression | EdgeConstraint |