]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/ascii_ctype.rs
Rollup merge of #72279 - RalfJung:raw-ref-macros, r=nikomatsakis
[rust.git] / src / test / ui / consts / ascii_ctype.rs
1 // run-pass
2
3 #![feature(const_ascii_ctype_on_intrinsics)]
4
5 macro_rules! suite {
6     ( $( $fn:ident => [$a:ident, $A:ident, $nine:ident, $dot:ident, $space:ident]; )* ) => {
7         $(
8             mod $fn {
9                 const CHAR_A_LOWER: bool = 'a'.$fn();
10                 const CHAR_A_UPPER: bool = 'A'.$fn();
11                 const CHAR_NINE: bool = '9'.$fn();
12                 const CHAR_DOT: bool = '.'.$fn();
13                 const CHAR_SPACE: bool = ' '.$fn();
14
15                 const U8_A_LOWER: bool = b'a'.$fn();
16                 const U8_A_UPPER: bool = b'A'.$fn();
17                 const U8_NINE: bool = b'9'.$fn();
18                 const U8_DOT: bool = b'.'.$fn();
19                 const U8_SPACE: bool = b' '.$fn();
20
21                 pub fn run() {
22                     assert_eq!(CHAR_A_LOWER, $a);
23                     assert_eq!(CHAR_A_UPPER, $A);
24                     assert_eq!(CHAR_NINE, $nine);
25                     assert_eq!(CHAR_DOT, $dot);
26                     assert_eq!(CHAR_SPACE, $space);
27
28                     assert_eq!(U8_A_LOWER, $a);
29                     assert_eq!(U8_A_UPPER, $A);
30                     assert_eq!(U8_NINE, $nine);
31                     assert_eq!(U8_DOT, $dot);
32                     assert_eq!(U8_SPACE, $space);
33                 }
34             }
35         )*
36
37         fn main() {
38             $( $fn::run(); )*
39         }
40     }
41 }
42
43 suite! {
44     //                        'a'    'A'    '9'    '.'    ' '
45     is_ascii_alphabetic   => [true,  true,  false, false, false];
46     is_ascii_uppercase    => [false, true,  false, false, false];
47     is_ascii_lowercase    => [true,  false, false, false, false];
48     is_ascii_alphanumeric => [true,  true,  true,  false, false];
49     is_ascii_digit        => [false, false, true,  false, false];
50     is_ascii_hexdigit     => [true,  true,  true,  false, false];
51     is_ascii_punctuation  => [false, false, false, true,  false];
52     is_ascii_graphic      => [true,  true,  true,  true,  false];
53     is_ascii_whitespace   => [false, false, false, false, true];
54     is_ascii_control      => [false, false, false, false, false];
55 }