]> Cypherpunks.ru repositories - gostls13.git/blob - test/import5.go
gc: disallow absolute import paths
[gostls13.git] / test / import5.go
1 // errorcheck
2
3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 // Verify that invalid imports are rejected by the compiler.
8 // Does not compile.
9
10 package main
11
12 // Correct import paths.
13 import _ "fmt"
14 import _ `time`
15 import _ "m\x61th"
16 import _ "go/parser"
17
18 // Correct import paths, but the packages don't exist.
19 // Don't test.
20 //import "a.b"
21 //import "greek/αβ"
22
23 // Import paths must be strings.
24 import 42    // ERROR "import statement"
25 import 'a'   // ERROR "import statement"
26 import 3.14  // ERROR "import statement"
27 import 0.25i // ERROR "import statement"
28
29 // Each of these pairs tests both `` vs "" strings
30 // and also use of invalid characters spelled out as
31 // escape sequences and written directly.
32 // For example `"\x00"` tests import "\x00"
33 // while "`\x00`" tests import `<actual-NUL-byte>`.
34 import ""         // ERROR "import path"
35 import ``         // ERROR "import path"
36 import "\x00"     // ERROR "import path"
37 import `\x00`     // ERROR "import path"
38 import "\x7f"     // ERROR "import path"
39 import `\x7f`     // ERROR "import path"
40 import "a!"       // ERROR "import path"
41 import `a!`       // ERROR "import path"
42 import "a b"      // ERROR "import path"
43 import `a b`      // ERROR "import path"
44 import "a\\b"     // ERROR "import path"
45 import `a\\b`     // ERROR "import path"
46 import "\"`a`\""  // ERROR "import path"
47 import `\"a\"`    // ERROR "import path"
48 import "\x80\x80" // ERROR "import path"
49 import `\x80\x80` // ERROR "import path"
50 import "\xFFFD"   // ERROR "import path"
51 import `\xFFFD`   // ERROR "import path"
52
53 // Invalid local imports.
54 import "/foo"  // ERROR "import path cannot be absolute path"
55 import "c:/foo"  // ERROR "import path contains invalid character"