github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/syntax/error_test.go (about)

     1  // Copyright 2018 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 regression test harness for syntax errors.
     6  // The files in the testdata directory are parsed and the reported
     7  // errors are compared against the errors declared in those files.
     8  //
     9  // Errors are declared in place in the form of "error comments",
    10  // just before (or on the same line as) the offending token.
    11  //
    12  // Error comments must be of the form // ERROR rx or /* ERROR rx */
    13  // where rx is a regular expression that matches the reported error
    14  // message. The rx text comprises the comment text after "ERROR ",
    15  // with any white space around it stripped.
    16  //
    17  // If the line comment form is used, the reported error's line must
    18  // match the line of the error comment.
    19  //
    20  // If the regular comment form is used, the reported error's position
    21  // must match the position of the token immediately following the
    22  // error comment. Thus, /* ERROR ... */ comments should appear
    23  // immediately before the position where the error is reported.
    24  //
    25  // Currently, the test harness only supports one error comment per
    26  // token. If multiple error comments appear before a token, only
    27  // the last one is considered.
    28  
    29  package syntax