OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [go.test/] [test/] [nul1.go] - Blame information for rev 700

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 700 jeremybenn
// [ "$GORUN" == "" ] || exit 0  # Android runner gets confused by the NUL output
2
// $G $D/$F.go && $L $F.$A && ./$A.out >tmp.go &&
3
// errchk $G -e tmp.go
4
// rm -f tmp.go
5
 
6
// Copyright 2009 The Go Authors. All rights reserved.
7
// Use of this source code is governed by a BSD-style
8
// license that can be found in the LICENSE file.
9
 
10
// Test source files and strings containing NUL and invalid UTF-8.
11
 
12
package main
13
 
14
import (
15
        "fmt"
16
        "os"
17
)
18
 
19
func main() {
20
        var s = "\xc2\xff"
21
        var t = "\xd0\xfe"
22
        var u = "\xab\x00\xfc"
23
 
24
        if len(s) != 2 || s[0] != 0xc2 || s[1] != 0xff ||
25
                len(t) != 2 || t[0] != 0xd0 || t[1] != 0xfe ||
26
                len(u) != 3 || u[0] != 0xab || u[1] != 0x00 || u[2] != 0xfc {
27
                println("BUG: non-UTF-8 string mangled")
28
                os.Exit(2)
29
        }
30
 
31
        fmt.Print(`
32
package main
33
 
34
var x = "in string ` + "\x00" + `"      // ERROR "NUL"
35
 
36
var y = ` + "`in raw string \x00 foo`" + `  // ERROR "NUL"
37
 
38
// in comment ` + "\x00" + `  // ERROR "NUL"
39
 
40
/* in other comment ` + "\x00" + ` */ // ERROR "NUL"
41
 
42
/* in source code */ ` + "\x00" + `// ERROR "NUL" "illegal character"
43
 
44
var xx = "in string ` + "\xc2\xff" + `" // ERROR "UTF-8"
45
 
46
var yy = ` + "`in raw string \xff foo`" + `  // ERROR "UTF-8"
47
 
48
// in comment ` + "\xe2\x80\x01" + `  // ERROR "UTF-8"
49
 
50
/* in other comment ` + "\xe0\x00\x00" + ` */ // ERROR "UTF-8|NUL"
51
 
52
/* in variable name */
53
var z` + "\xc1\x81" + ` int // ERROR "UTF-8" "invalid identifier character"
54
 
55
/* in source code */ ` + "var \xc2A int" + `// ERROR "UTF-8" "invalid identifier character"
56
 
57
`)
58
}
59
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.