aboutsummaryrefslogtreecommitdiff
path: root/test/interface
AgeCommit message (Collapse)Author
2020-12-14[dev.typeparams] merge: merge branch 'dev.regabi' into 'dev.typeparams'Robert Griesemer
The following files had merge conflicts and were merged manually: src/cmd/compile/fmtmap_test.go src/cmd/compile/internal/gc/noder.go src/go/parser/error_test.go test/assign.go test/chan/perm.go test/fixedbugs/issue22822.go test/fixedbugs/issue4458.go test/init.go test/interface/explicit.go test/map1.go test/method2.go The following files had manual changes to make tests pass: test/run.go test/used.go src/cmd/compile/internal/types2/stdlib_test.go Change-Id: Ia495aaaa80ce321ee4ec2a9105780fbe913dbd4c
2020-12-07[dev.regabi] cmd/compile: silence errors about missing blank methodsMatthew Dempsky
If an interface contains a blank method, that's already an error. No need for useless follow-up error messages about not implementing them. Fixes #42964. Change-Id: I5bf53a8f27d75d4c86c61588c5e2e3e95563d320 Reviewed-on: https://go-review.googlesource.com/c/go/+/275294 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2020-12-03[dev.typeparams] test: adjust more test cases to match compiler -G outputRobert Griesemer
With this CL, the first ~500 errorcheck tests pass when running go run run.go -v -G in the $GOROOT/test directory (the log output includes a few dozen tests that are currently skipped). Change-Id: I9eaa2319fb39a090df54f8699ddc29ffe58b1bf1 Reviewed-on: https://go-review.googlesource.com/c/go/+/274975 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-11-28test: match gofrontend error messagesIan Lance Taylor
These changes match the following gofrontend error messages: blank1.go:16:1: error: may not define methods on non-local type chan/perm.go:28:9: error: expected channel chan/perm.go:29:11: error: left operand of ‘<-’ must be channel chan/perm.go:69:9: error: argument must be channel complit1.go:25:16: error: attempt to slice object that is not array, slice, or string complit1.go:26:16: error: attempt to slice object that is not array, slice, or string complit1.go:27:17: error: attempt to slice object that is not array, slice, or string complit1.go:49:41: error: may only omit types within composite literals of slice, array, or map type complit1.go:50:14: error: expected struct, slice, array, or map type for composite literal convlit.go:24:9: error: invalid type conversion (cannot use type unsafe.Pointer as type string) convlit.go:25:9: error: invalid type conversion (cannot use type unsafe.Pointer as type float64) convlit.go:26:9: error: invalid type conversion (cannot use type unsafe.Pointer as type int) ddd1.go:63:9: error: invalid use of ‘...’ calling non-variadic function fixedbugs/bug176.go:12:18: error: index expression is not integer constant fixedbugs/bug332.go:17:10: error: use of undefined type ‘T’ fixedbugs/issue4232.go:22:16: error: integer constant overflow fixedbugs/issue4232.go:33:16: error: integer constant overflow fixedbugs/issue4232.go:44:25: error: integer constant overflow fixedbugs/issue4232.go:55:16: error: integer constant overflow fixedbugs/issue4458.go:19:14: error: type has no method ‘foo’ fixedbugs/issue5172.go:24:14: error: too many expressions for struct init.go:17:9: error: reference to undefined name ‘runtime’ initializerr.go:26:29: error: duplicate value for index 1 interface/explicit.go:60:14: error: type assertion only valid for interface types label.go:64:9: error: reference to undefined label ‘go2’ label1.go:18:97: error: continue statement not within for label1.go:22:97: error: continue statement not within for label1.go:106:89: error: continue statement not within for label1.go:108:26: error: invalid continue label ‘on’ label1.go:111:118: error: break statement not within for or switch or select label1.go:113:23: error: invalid break label ‘dance’ map1.go:64:9: error: not enough arguments map1.go:65:9: error: not enough arguments map1.go:67:9: error: argument 1 must be a map method2.go:36:11: error: reference to undefined field or method ‘val’ method2.go:37:11: error: reference to undefined field or method ‘val’ method2.go:41:12: error: method requires pointer (use ‘(*T).g’) syntax/chan1.go:13:19: error: send statement used as value; use select for non-blocking send syntax/chan1.go:17:11: error: send statement used as value; use select for non-blocking send Change-Id: I98047b60a376e3d2788836300f7fcac3f2c285cb Reviewed-on: https://go-review.googlesource.com/c/go/+/273527 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2019-11-06test: add tests for runtime.itab.initDmitry Vyukov
We seem to lack any tests for some corner cases of itab.init (multiple methods with the same name, breaking itab.init doesn't seem to fail any tests). We also lack tests that fix text of panics. Add more tests for itab.init. Change-Id: Id6b536179ba6b0d45c3cb9dc1c66b9311d0ab85e Reviewed-on: https://go-review.googlesource.com/c/go/+/202451 Run-TryBot: Dmitry Vyukov <dvyukov@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-04-24cmd/compile: more error position tests for the typecheckerAlberto Donizetti
This change adds line position tests for several yyerror calls in the typechecker that are currently not tested in any way. Untested yyerror calls were found by replacing them with yerrorl(src.NoXPos, ...) (thus destroying position information in the error), and then running the test suite. No failures means no test coverage for the relevant yyerror call. For #19683 Change-Id: Iedb3d2f02141b332e9bfa76dbf5ae930ad2fddc3 Reviewed-on: https://go-review.googlesource.com/41477 Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2017-04-20cmd/compile: only print one error for bad-type literal in assignmentAlberto Donizetti
Fixes #8438 Change-Id: Ib43cdcdc962a8d9e14faf984bc859a92ba1eb517 Reviewed-on: https://go-review.googlesource.com/40531 Reviewed-by: Robert Griesemer <gri@golang.org>
2016-11-02cmd/compile: do more type conversion inlineKeith Randall
The code to do the conversion is smaller than the call to the runtime. The 1-result asserts need to call panic if they fail, but that code is out of line. The only conversions left in the runtime are those which might allocate and those which might need to generate an itab. Given the following types: type E interface{} type I interface { foo() } type I2 iterface { foo(); bar() } type Big [10]int func (b Big) foo() { ... } This CL inlines the following conversions: was assertE2T var e E = ... b := i.(Big) was assertE2T2 var e E = ... b, ok := i.(Big) was assertI2T var i I = ... b := i.(Big) was assertI2T2 var i I = ... b, ok := i.(Big) was assertI2E var i I = ... e := i.(E) was assertI2E2 var i I = ... e, ok := i.(E) These are the remaining runtime calls: convT2E: var b Big = ... var e E = b convT2I: var b Big = ... var i I = b convI2I: var i2 I2 = ... var i I = i2 assertE2I: var e E = ... i := e.(I) assertE2I2: var e E = ... i, ok := e.(I) assertI2I: var i I = ... i2 := i.(I2) assertI2I2: var i I = ... i2, ok := i.(I2) Fixes #17405 Fixes #8422 Change-Id: Ida2367bf8ce3cd2c6bb599a1814f1d275afabe21 Reviewed-on: https://go-review.googlesource.com/32313 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com>
2016-08-17cmd/compile: inline x, ok := y.(T) where T is a scalarJosh Bleecher Snyder
When T is a scalar, there are no runtime calls required, which makes this a clear win. encoding/binary: WriteInts-8 958ns ± 3% 864ns ± 2% -9.80% (p=0.000 n=15+15) This also considerably shrinks a core fmt routine: Before: "".(*pp).printArg t=1 size=3952 args=0x20 locals=0xf0 After: "".(*pp).printArg t=1 size=2624 args=0x20 locals=0x98 Unfortunately, I find it very hard to get stable numbers out of the fmt benchmarks due to thermal scaling. Change-Id: I1278006b030253bf8e48dc7631d18985cdaa143d Reviewed-on: https://go-review.googlesource.com/26659 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Keith Randall <khr@golang.org>
2016-05-02all: make copyright headers consistent with one space after periodEmmanuel Odeke
Follows suit with https://go-review.googlesource.com/#/c/20111. Generated by running $ grep -R 'Go Authors. All' * | cut -d":" -f1 | while read F;do perl -pi -e 's/Go Authors. All/Go Authors. All/g' $F;done The code in cmd/internal/unvendor wasn't changed. Fixes #15213 Change-Id: I4f235cee0a62ec435f9e8540a1ec08ae03b1a75f Reviewed-on: https://go-review.googlesource.com/21819 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-05-07cmd/internal/gc: improve "type *X has no field or method M" messageDavid Chase
Try to provide hints for common areas, either *interface were interface would have been better, and note incorrect capitalization (but don't be more ambitious than that, at least not today). Added code and test for cases ptrInterface.ExistingMethod ptrInterface.unexportedMethod ptrInterface.MissingMethod ptrInterface.withwRongcASEdMethod interface.withwRongcASEdMethod ptrStruct.withwRongcASEdMethod struct.withwRongcASEdMethod also included tests for related errors to check for unintentional changes and consistent wording. Somewhat simplified from previous versions to avoid second- guessing user errors, yet also biased to point out most-likely root cause. Fixes #10700 Change-Id: I16693e93cc8d8ca195e7742a222d640c262105b4 Reviewed-on: https://go-review.googlesource.com/9731 Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-20cmd/internal/gc: inline x := y.(*T) and x, ok := y.(*T)Russ Cox
These can be implemented with just a compare and a move instruction. Do so, avoiding the overhead of a call into the runtime. These assertions are a significant cost in Go code that uses interface{} as a safe alternative to C's void* (or unsafe.Pointer), such as the current version of the Go compiler. *T here includes pointer to T but also any Go type represented as a single pointer (chan, func, map). It does not include [1]*T or struct{*int}. That requires more work in other parts of the compiler; there is a TODO. Change-Id: I7ff681c20d2c3eb6ad11dd7b3a37b1f3dda23965 Reviewed-on: https://go-review.googlesource.com/7862 Reviewed-by: Rob Pike <r@golang.org>
2014-10-15cmd/gc: blank methods are not permitted in interface typesChris Manghane
Fixes #6606. LGTM=rsc R=rsc CC=golang-codereviews, gri https://golang.org/cl/156210044
2013-08-19cmd/gc: don't attempt to generate wrappers for blank interface methodsAnthony Martin
Fixes #5691. R=golang-dev, bradfitz, daniel.morsing, rsc CC=golang-dev https://golang.org/cl/10255047
2012-10-10test: convert tests to run.go whenever possible.Rémy Oudompheng
The other tests either need a complex procedure or are architecture- or OS-dependent. Update #4139. R=golang-dev, daniel.morsing, iant CC=golang-dev https://golang.org/cl/6618062
2012-09-23test: expand run.go's errorcheck, make clear which bugs runRuss Cox
Today, if run.go doesn't understand a test header line it just ignores the test, making it too easy to write or edit tests that are not actually being run. - expand errorcheck to accept flags, so that bounds.go and escape*.go can run. - create a whitelist of skippable tests in run.go; skipping others is an error. - mark all skipped tests at top of file. Update #4139. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/6549054
2012-09-01cmd/gc: Suggest *T in error for x.(T) if it would work.Daniel Morsing
Accomplished by synchronizing the formatting of conversion errors between typecheck.c and subr.c Fixes #3984. R=golang-dev, remyoudompheng, rsc CC=golang-dev https://golang.org/cl/6500064
2012-08-15cmd/gc: Don't claim type assertion would help when it wont.Daniel Morsing
Fixes #3465. R=golang-dev, rsc, remyoudompheng, iant CC=golang-dev https://golang.org/cl/6448097
2012-03-22test: use testlib in a few more casesShenghou Ma
Introduce a new skip cmd. R=golang-dev, bradfitz, iant, iant CC=golang-dev https://golang.org/cl/5868048
2012-02-19test/interface: document testsRob Pike
Most already had comments (yay); adjusted for consistency. R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5676102
2012-02-18test: use testlib (another bunch).Rémy Oudompheng
Apply sed with: 1s,^// $G $D/$F.go && $L $F.$A && ./$A.out || echo.*,// run, 1s,^// $G $D/$F.go || echo.*,// compile, R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5656099
2012-02-16test: use testlib (fourth 100)Russ Cox
X ,s;^// \$G (\$D/)?\$F\.go *$;// compile;g X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A *$;// build;g X ,s;^// \$G (\$D/)?\$F\.go && \$L \$F\.\$A && \./\$A\.out *$;// run;g X ,s;^// errchk \$G( -e)? (\$D/)?\$F\.go *$;// errorcheck;g R=golang-dev, bradfitz CC=golang-dev https://golang.org/cl/5673079
2012-02-03test: don't use package main for files without a main functionBrad Fitzpatrick
Part of issue 2833, but works fine with current test runner. R=golang-dev, rsc CC=golang-dev https://golang.org/cl/5606056
2012-01-21gc: test case for recursive interface bug.David Symonds
R=rsc CC=golang-dev https://golang.org/cl/5555066
2011-12-12gc: implement == on structs and arraysRuss Cox
To allow these types as map keys, we must fill in equal and hash functions in their algorithm tables. Structs or arrays that are "just memory", like [2]int, can and do continue to use the AMEM algorithm. Structs or arrays that contain special values like strings or interface values use generated functions for both equal and hash. The runtime helper func runtime.equal(t, x, y) bool handles the general equality case for x == y and calls out to the equal implementation in the algorithm table. For short values (<= 4 struct fields or array elements), the sequence of elementwise comparisons is inlined instead of calling runtime.equal. R=ken, mpimenov CC=golang-dev https://golang.org/cl/5451105
2011-12-06gc: disallow map/func equality via interface comparisonRuss Cox
Missed when I removed direct map/func equality. R=ken2 CC=golang-dev https://golang.org/cl/5452052
2011-10-17reflect: disallow Interface method on Value obtained via unexported nameRuss Cox
Had been allowing it for use by fmt, but it is too hard to lock down. Fix other packages not to depend on it. R=r, r CC=golang-dev https://golang.org/cl/5266054
2011-09-26test: silence/coalesce some testsRuss Cox
Add copyright notice to nilptr.go. R=golang-dev, r CC=golang-dev https://golang.org/cl/5139048
2011-09-21test: match gccgo error messagesIan Lance Taylor
bug363.go:13:12: error: invalid context-determined non-integer type for shift operand bug363.go:16:12: error: invalid context-determined non-integer type for shift operand pointer.go:34:6: error: incompatible type in initialization (pointer to interface type has no methods) pointer.go:36:6: error: incompatible type in initialization method2.go:15:1: error: invalid pointer or interface receiver type method2.go:16:1: error: invalid pointer or interface receiver type method2.go:21:1: error: invalid pointer or interface receiver type method2.go:22:1: error: invalid pointer or interface receiver type method2.go:28:15: error: type ‘*Val’ has no method ‘val’ method2.go:33:11: error: reference to undefined field or method ‘val’ shift1.go:19:16: error: invalid context-determined non-integer type for shift operand shift1.go:24:19: error: invalid context-determined non-integer type for shift operand shift1.go:25:17: error: invalid context-determined non-integer type for shift operand shift1.go:18:18: error: shift of non-integer operand shift1.go:26:13: error: floating point constant truncated to integer shift1.go:33:15: error: integer constant overflow shift1.go:34:15: error: integer constant overflow shift1.go:35:17: error: integer constant overflow R=golang-dev, r CC=golang-dev https://golang.org/cl/5081051
2011-08-16errchk: allow multiple patternsRuss Cox
// ERROR "pattern1" "pattern2" means that there has to be one or more lines matching pattern1 and then excluding those, there have to be one or more lines matching pattern2. So if you expect two different error messages from a particular line, writing two separate patterns checks that both errors are produced. Also, errchk now flags lines that produce more errors than expected. Before, as long as at least one error matched the pattern, all the others were ignored. Revise tests to expect or silence these additional errors. R=lvd, r, iant CC=golang-dev https://golang.org/cl/4869044
2011-04-25fix tree for reflect renameRuss Cox
R=golang-dev, r CC=golang-dev https://golang.org/cl/4435067
2011-04-21gc: another pointer to interface messageRuss Cox
R=ken2 CC=golang-dev https://golang.org/cl/4444056
2011-04-08update go tree for reflect changesRuss Cox
R=golang-dev, r CC=golang-dev https://golang.org/cl/4353043
2011-03-29test: add test for interfaces with unexported methods.Ian Lance Taylor
R=rsc CC=golang-dev https://golang.org/cl/4271086
2011-01-19delete float, complex - code changesRuss Cox
also: cmplx -> complex float64(1.0) -> 1.0 float64(1) -> 1.0 R=gri, r, gri1, r2 CC=golang-dev https://golang.org/cl/3991043
2010-09-30gc, spec, tests: no auto-indirect of pointer to interface valueRuss Cox
Implies no embedding of pointer to interface value either. R=gri, iant, ken2, r, r2 CC=golang-dev https://golang.org/cl/2289041
2010-09-08test: Match gccgo error messages.Ian Lance Taylor
explicit.go:36:4: error: incompatible types in assignment (need explicit conversion) explicit.go:41:4: error: incompatible types in assignment (type has no methods) explicit.go:42:4: error: incompatible types in assignment (need explicit conversion) explicit.go:45:5: error: incompatible types in assignment (need explicit conversion; missing method ‘N’) explicit.go:48:9: error: invalid type conversion (need explicit conversion; missing method ‘N’) explicit.go:51:4: error: incompatible types in assignment explicit.go:51:7: error: invalid type conversion (need explicit conversion) explicit.go:57:10: error: impossible type assertion: type does not implement interface (type has no methods) explicit.go:62:10: error: impossible type assertion: type does not implement interface (incompatible type for method ‘M’ (different number of parameters)) explicit.go:67:5: error: incompatible type in initialization (type has no methods) explicit.go:68:5: error: incompatible type in initialization (incompatible type for method ‘M’ (different number of parameters)) explicit.go:70:11: error: invalid type conversion (type has no methods) explicit.go:71:11: error: invalid type conversion (incompatible type for method ‘M’ (different number of parameters)) R=rsc CC=golang-dev https://golang.org/cl/2139044
2010-09-04test: remove semiocolons.Rob Pike
The ken directory is untouched so we have some examples with explicit semis. R=gri CC=golang-dev https://golang.org/cl/2157041
2010-06-09gc: more cleanupRuss Cox
* disallow surrogate pair runes. * diagnose impossible type assertions * eliminate another static buffer. * do not overflow lexbuf. * add -u flag to disable package unsafe. R=ken2 CC=golang-dev https://golang.org/cl/1619042
2010-06-08gc: new typechecking rulesRuss Cox
* Code for assignment, conversions now mirrors spec. * Changed some snprint -> smprint. * Renamed runtime functions to separate interface conversions from type assertions: convT2I, assertI2T, etc. * Correct checking of \U sequences. Fixes #840. Fixes #830. Fixes #778. R=ken2 CC=golang-dev https://golang.org/cl/1303042
2010-03-30single argument panicRuss Cox
note that sortmain.go has been run through hg gofmt; only the formatting of the day initializers changed. i'm happy to revert that formatting if you'd prefer. stop on error in doc/progs/run R=r CC=golang-dev https://golang.org/cl/850041
2010-03-24delete all uses of panicln by rewriting them using panic or,Rob Pike
in the tests, println+panic. gofmt some tests too. R=rsc CC=golang-dev https://golang.org/cl/741041
2009-11-14test/interface/receiver.go: expand to do dynamicRuss Cox
versions of static checks in receiver1.go R=r https://golang.org/cl/155045
2009-10-25 make 5l ignore multiple defs, remove use of multipleKai Backman
defs from embed1 and gotest R=rsc http://go/go-review/1014009
2009-10-20forgot to include in 35898.Russ Cox
R=ken OCL=35917 CL=35917
2009-10-196g bug fixes:Russ Cox
* bug211 * embedded interfaces with lowercase methods * var _ = f() at top level R=ken OCL=35898 CL=35898
2009-10-19fiddling while rome burns: explain why tests are commented outRob Pike
R=rsc DELTA=2 (2 added, 0 deleted, 0 changed) OCL=35874 CL=35880
2009-09-14fix "declared and not used" in tests;Russ Cox
also template/template.go, missed last time. R=r DELTA=116 (61 added, 10 deleted, 45 changed) OCL=34620 CL=34622
2009-08-17fix up some irregular indentationRob Pike
R=rsc OCL=33382 CL=33391
2009-08-12delete forward type declarationsRuss Cox
R=r DELTA=163 (1 added, 149 deleted, 13 changed) OCL=33106 CL=33111