Russ Cox | 0b477ef | 2012-02-16 23:48:57 -0500 | [diff] [blame] | 1 | // errorcheck |
Russ Cox | 6cd8537 | 2010-06-10 13:30:39 -0700 | [diff] [blame] | 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 | |
Rob Pike | fc0dc04 | 2012-02-19 13:19:43 +1100 | [diff] [blame] | 7 | // Verify that illegal character literals are detected. |
| 8 | // Does not compile. |
| 9 | |
Russ Cox | 6cd8537 | 2010-06-10 13:30:39 -0700 | [diff] [blame] | 10 | package main |
| 11 | |
| 12 | const ( |
| 13 | // check that surrogate pair elements are invalid |
| 14 | // (d800-dbff, dc00-dfff). |
| 15 | _ = '\ud7ff' // ok |
Ian Lance Taylor | 472cd3a | 2010-08-31 11:43:52 -0700 | [diff] [blame] | 16 | _ = '\ud800' // ERROR "Unicode|unicode" |
| 17 | _ = "\U0000D999" // ERROR "Unicode|unicode" |
| 18 | _ = '\udc01' // ERROR "Unicode|unicode" |
| 19 | _ = '\U0000dddd' // ERROR "Unicode|unicode" |
| 20 | _ = '\udfff' // ERROR "Unicode|unicode" |
Russ Cox | 6cd8537 | 2010-06-10 13:30:39 -0700 | [diff] [blame] | 21 | _ = '\ue000' // ok |
| 22 | _ = '\U0010ffff' // ok |
Ian Lance Taylor | 472cd3a | 2010-08-31 11:43:52 -0700 | [diff] [blame] | 23 | _ = '\U00110000' // ERROR "Unicode|unicode" |
Russ Cox | 6cd8537 | 2010-06-10 13:30:39 -0700 | [diff] [blame] | 24 | _ = "abc\U0010ffffdef" // ok |
Ian Lance Taylor | 472cd3a | 2010-08-31 11:43:52 -0700 | [diff] [blame] | 25 | _ = "abc\U00110000def" // ERROR "Unicode|unicode" |
| 26 | _ = '\Uffffffff' // ERROR "Unicode|unicode" |
Russ Cox | 6cd8537 | 2010-06-10 13:30:39 -0700 | [diff] [blame] | 27 | ) |
| 28 | |