Shenghou Ma | dda6d6a | 2012-04-20 23:45:43 +0800 | [diff] [blame] | 1 | // runoutput |
Russ Cox | 17264df | 2011-12-15 10:47:09 -0500 | [diff] [blame] | 2 | |
| 3 | // Copyright 2011 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 | // Test source files and strings containing \r and \r\n. |
| 8 | |
| 9 | package main |
| 10 | |
| 11 | import ( |
| 12 | "fmt" |
| 13 | "strings" |
| 14 | ) |
| 15 | |
| 16 | func main() { |
| 17 | prog = strings.Replace(prog, "BQ", "`", -1) |
| 18 | prog = strings.Replace(prog, "CR", "\r", -1) |
| 19 | fmt.Print(prog) |
| 20 | } |
| 21 | |
| 22 | var prog = ` |
| 23 | package main |
| 24 | CR |
| 25 | |
| 26 | import "fmt" |
| 27 | |
| 28 | var CR s = "hello\n" + CR |
| 29 | " world"CR |
| 30 | |
| 31 | var t = BQhelloCR |
| 32 | worldBQ |
| 33 | |
| 34 | var u = BQhCReCRlCRlCRoCR |
| 35 | worldBQ |
| 36 | |
| 37 | var golden = "hello\n world" |
| 38 | |
| 39 | func main() { |
| 40 | if s != golden { |
| 41 | fmt.Printf("s=%q, want %q", s, golden) |
| 42 | } |
| 43 | if t != golden { |
| 44 | fmt.Printf("t=%q, want %q", t, golden) |
| 45 | } |
| 46 | if u != golden { |
| 47 | fmt.Printf("u=%q, want %q", u, golden) |
| 48 | } |
| 49 | } |
| 50 | ` |