golang-x-exp/145caa8ea1d065cbc846dfd1a5602c914b97f9d8.patch
Mikel Olasagasti Uranga b106216762 Remove event module, fix test. Closes rhbz#2171561
Nothing depends on `'golang(golang.org/x/exp/*)'` and module requires
old OpenTelemetry libraries, so by removing it we can update
OpenTelemetry libraries.

Also patch a couple of TestNormalTerms tests that fail with current
stack with an upstream accepted patch.
2023-06-22 16:40:11 +02:00

63 lines
2.3 KiB
Diff

From 145caa8ea1d065cbc846dfd1a5602c914b97f9d8 Mon Sep 17 00:00:00 2001
From: Robert Findley <rfindley@google.com>
Date: Tue, 6 Sep 2022 18:32:29 -0400
Subject: [PATCH] x/exp/typeparams: use regexp to match wanted result
This is a port of CL 428055 to the external x/exp/typeparams package.
Also fix a stale test error message.
Fixes golang/go#54903
Change-Id: Iafa0df489e1d2bf7ce43f2e7854d87b2635e1f42
Reviewed-on: https://go-review.googlesource.com/c/exp/+/428875
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
---
typeparams/normalize_test.go | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/typeparams/normalize_test.go b/typeparams/normalize_test.go
index dd47b57c..98f7ec46 100644
--- a/typeparams/normalize_test.go
+++ b/typeparams/normalize_test.go
@@ -9,6 +9,7 @@ import (
"go/parser"
"go/token"
"go/types"
+ "regexp"
"strings"
"testing"
@@ -36,7 +37,7 @@ func TestNormalTerms(t *testing.T) {
{"package emptyintersection; type T[P interface{ ~int; string }] int", "", "empty type set"},
{"package embedded0; type T[P interface{ I }] int; type I interface { int }", "int", ""},
- {"package embedded1; type T[P interface{ I | string }] int; type I interface{ int | ~string }", "int|~string", ""},
+ {"package embedded1; type T[P interface{ I | string }] int; type I interface{ int | ~string }", "int ?\\| ?~string", ""},
{"package embedded2; type T[P interface{ I; string }] int; type I interface{ int | ~string }", "string", ""},
{"package named; type T[P C] int; type C interface{ ~int|int }", "~int", ""},
@@ -50,7 +51,7 @@ type B interface{ int|string }
type C interface { ~string|~int }
type T[P interface{ A|B; C }] int
-`, "~string|int", ""},
+`, "~string ?\\| ?int", ""},
}
for _, test := range tests {
@@ -94,8 +95,9 @@ type T[P interface{ A|B; C }] int
qf := types.RelativeTo(pkg)
got = types.TypeString(NewUnion(terms), qf)
}
- if got != test.want {
- t.Errorf("StructuralTerms(%s) = %q, want %q", T, got, test.want)
+ want := regexp.MustCompile(test.want)
+ if !want.MatchString(got) {
+ t.Errorf("NormalTerms(%s) = %q, want matching %q", T, got, test.want)
}
})
}