github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/go/parser/error_test.go (about) 1 // Copyright 2012 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 // This file implements a parser test harness. The files in the testdata 6 // directory are parsed and the errors reported are compared against the 7 // error messages expected in the test files. The test files must end in 8 // .src rather than .go so that they are not disturbed by gofmt runs. 9 // 10 // Expected errors are indicated in the test files by putting a comment 11 // of the form /* ERROR "rx" */ immediately following an offending token. 12 // The harness will verify that an error matching the regular expression 13 // rx is reported at that source position. 14 // 15 // For instance, the following test file indicates that a "not declared" 16 // error should be reported for the undeclared variable x: 17 // 18 // package p 19 // func f() { 20 // _ = x /* ERROR "not declared" */ + 1 21 // } 22 23 package parser