]>
git.proxmox.com Git - rustc.git/blob - src/test/ui/proc-macro/auxiliary/api/parse.rs
1 // ignore-tidy-linelength
3 use proc_macro
::Literal
;
6 test_display_literal();
10 fn test_display_literal() {
11 assert_eq
!(Literal
::isize_unsuffixed(-10).to_string(), "-10");
12 assert_eq
!(Literal
::isize_suffixed(-10).to_string(), "-10isize");
13 assert_eq
!(Literal
::f32_unsuffixed(-10.0).to_string(), "-10.0");
14 assert_eq
!(Literal
::f32_suffixed(-10.0).to_string(), "-10f32");
15 assert_eq
!(Literal
::f64_unsuffixed(-10.0).to_string(), "-10.0");
16 assert_eq
!(Literal
::f64_suffixed(-10.0).to_string(), "-10f64");
18 Literal
::f64_unsuffixed(1e100
).to_string(),
19 "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0",
23 fn test_parse_literal() {
24 assert_eq
!("1".parse
::<Literal
>().unwrap().to_string(), "1");
25 assert_eq
!("1.0".parse
::<Literal
>().unwrap().to_string(), "1.0");
26 assert_eq
!("'a'".parse
::<Literal
>().unwrap().to_string(), "'a'");
27 assert_eq
!("\"\n\"".parse
::<Literal
>().unwrap().to_string(), "\"\n\"");
28 assert_eq
!("b\"\"".parse
::<Literal
>().unwrap().to_string(), "b\"\"");
29 assert_eq
!("r##\"\"##".parse
::<Literal
>().unwrap().to_string(), "r##\"\"##");
30 assert_eq
!("10ulong".parse
::<Literal
>().unwrap().to_string(), "10ulong");
31 assert_eq
!("-10ulong".parse
::<Literal
>().unwrap().to_string(), "-10ulong");
33 assert
!("true".parse
::<Literal
>().is_err());
34 assert
!(".8".parse
::<Literal
>().is_err());
35 assert
!("0 1".parse
::<Literal
>().is_err());
36 assert
!("'a".parse
::<Literal
>().is_err());
37 assert
!(" 0".parse
::<Literal
>().is_err());
38 assert
!("0 ".parse
::<Literal
>().is_err());
39 assert
!("/* comment */0".parse
::<Literal
>().is_err());
40 assert
!("0/* comment */".parse
::<Literal
>().is_err());
41 assert
!("0// comment".parse
::<Literal
>().is_err());
42 assert
!("- 10".parse
::<Literal
>().is_err());
43 assert
!("-'x'".parse
::<Literal
>().is_err());