From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/indoc/tests/compiletest.rs | 7 + vendor/indoc/tests/test_formatdoc.rs | 117 +++++++++++++++ vendor/indoc/tests/test_indoc.rs | 166 +++++++++++++++++++++ vendor/indoc/tests/test_unindent.rs | 53 +++++++ vendor/indoc/tests/test_writedoc.rs | 57 +++++++ vendor/indoc/tests/ui/no-arguments.rs | 5 + vendor/indoc/tests/ui/no-arguments.stderr | 7 + vendor/indoc/tests/ui/non-lit.rs | 5 + vendor/indoc/tests/ui/non-lit.stderr | 5 + vendor/indoc/tests/ui/non-string.rs | 5 + vendor/indoc/tests/ui/non-string.stderr | 5 + vendor/indoc/tests/ui/printdoc-binary.rs | 5 + vendor/indoc/tests/ui/printdoc-binary.stderr | 5 + vendor/indoc/tests/ui/printdoc-extra-arg.rs | 5 + vendor/indoc/tests/ui/printdoc-extra-arg.stderr | 7 + vendor/indoc/tests/ui/printdoc-no-arg.rs | 5 + vendor/indoc/tests/ui/printdoc-no-arg.stderr | 5 + vendor/indoc/tests/ui/printdoc-no-display.rs | 7 + vendor/indoc/tests/ui/printdoc-no-display.stderr | 9 ++ vendor/indoc/tests/ui/printdoc-no-named-arg.rs | 5 + vendor/indoc/tests/ui/printdoc-no-named-arg.stderr | 5 + vendor/indoc/tests/ui/three-arguments.rs | 9 ++ vendor/indoc/tests/ui/three-arguments.stderr | 5 + vendor/indoc/tests/ui/two-arguments.rs | 9 ++ vendor/indoc/tests/ui/two-arguments.stderr | 5 + 25 files changed, 518 insertions(+) create mode 100644 vendor/indoc/tests/compiletest.rs create mode 100644 vendor/indoc/tests/test_formatdoc.rs create mode 100644 vendor/indoc/tests/test_indoc.rs create mode 100644 vendor/indoc/tests/test_unindent.rs create mode 100644 vendor/indoc/tests/test_writedoc.rs create mode 100644 vendor/indoc/tests/ui/no-arguments.rs create mode 100644 vendor/indoc/tests/ui/no-arguments.stderr create mode 100644 vendor/indoc/tests/ui/non-lit.rs create mode 100644 vendor/indoc/tests/ui/non-lit.stderr create mode 100644 vendor/indoc/tests/ui/non-string.rs create mode 100644 vendor/indoc/tests/ui/non-string.stderr create mode 100644 vendor/indoc/tests/ui/printdoc-binary.rs create mode 100644 vendor/indoc/tests/ui/printdoc-binary.stderr create mode 100644 vendor/indoc/tests/ui/printdoc-extra-arg.rs create mode 100644 vendor/indoc/tests/ui/printdoc-extra-arg.stderr create mode 100644 vendor/indoc/tests/ui/printdoc-no-arg.rs create mode 100644 vendor/indoc/tests/ui/printdoc-no-arg.stderr create mode 100644 vendor/indoc/tests/ui/printdoc-no-display.rs create mode 100644 vendor/indoc/tests/ui/printdoc-no-display.stderr create mode 100644 vendor/indoc/tests/ui/printdoc-no-named-arg.rs create mode 100644 vendor/indoc/tests/ui/printdoc-no-named-arg.stderr create mode 100644 vendor/indoc/tests/ui/three-arguments.rs create mode 100644 vendor/indoc/tests/ui/three-arguments.stderr create mode 100644 vendor/indoc/tests/ui/two-arguments.rs create mode 100644 vendor/indoc/tests/ui/two-arguments.stderr (limited to 'vendor/indoc/tests') diff --git a/vendor/indoc/tests/compiletest.rs b/vendor/indoc/tests/compiletest.rs new file mode 100644 index 000000000..7974a6249 --- /dev/null +++ b/vendor/indoc/tests/compiletest.rs @@ -0,0 +1,7 @@ +#[rustversion::attr(not(nightly), ignore)] +#[cfg_attr(miri, ignore)] +#[test] +fn ui() { + let t = trybuild::TestCases::new(); + t.compile_fail("tests/ui/*.rs"); +} diff --git a/vendor/indoc/tests/test_formatdoc.rs b/vendor/indoc/tests/test_formatdoc.rs new file mode 100644 index 000000000..5e4779504 --- /dev/null +++ b/vendor/indoc/tests/test_formatdoc.rs @@ -0,0 +1,117 @@ +use indoc::formatdoc; + +#[test] +fn carriage_return() { + // Every line in the string ends with \r\n + let indoc = formatdoc! {" + {} + + \\{} + {}", + 'a', 'b', 'c' + }; + let expected = "a\n\n \\b\nc"; + assert_eq!(indoc, expected); +} + +#[test] +fn empty_string() { + let indoc = formatdoc! {""}; + let expected = ""; + assert_eq!(indoc, expected); +} + +#[test] +fn joined_first_line() { + let indoc = formatdoc! {"\ + {}", 'a' + }; + let expected = "a"; + assert_eq!(indoc, expected); +} + +#[test] +fn joined_lines() { + let indoc = formatdoc! {" + {}\ + {} + {}\ + {} + {}", + 'a', 'b', 'c', 'd', 'e' + }; + let expected = "ab\ncd\ne"; + assert_eq!(indoc, expected); +} + +#[test] +fn no_leading_newline() { + let indoc = formatdoc! {"{} + {} + {}", 'a', 'b', 'c'}; + let expected = "a\nb\nc"; + assert_eq!(indoc, expected); +} + +#[test] +fn one_line() { + let indoc = formatdoc! {"a"}; + let expected = "a"; + assert_eq!(indoc, expected); +} + +#[test] +fn raw_string() { + let indoc = formatdoc! {r#" + {:?} + + \\{} + {}"#, + "a", 'b', 'c' + }; + let expected = "\"a\"\n\n \\\\b\nc"; + assert_eq!(indoc, expected); +} + +#[test] +fn string() { + let indoc = formatdoc! {" + {} + + \\{} + {}", + 'a', 'b', 'c' + }; + let expected = "a\n\n \\b\nc"; + assert_eq!(indoc, expected); +} + +#[test] +fn string_trailing_newline() { + let indoc = formatdoc! {" + {} + + \\{} + {} + ", + 'a', 'b', 'c' + }; + let expected = "a\n\n \\b\nc\n"; + assert_eq!(indoc, expected); +} + +#[test] +fn trailing_whitespace() { + let indoc = formatdoc! {" + {} {below} + + {} {below} + + {} {below} + + end", + 2, 0, -2, below = "below" + }; + let expected = "2 below\n \n0 below\n\n-2 below\n\nend"; + assert_eq!(indoc, expected); +} diff --git a/vendor/indoc/tests/test_indoc.rs b/vendor/indoc/tests/test_indoc.rs new file mode 100644 index 000000000..e0ead11b6 --- /dev/null +++ b/vendor/indoc/tests/test_indoc.rs @@ -0,0 +1,166 @@ +use indoc::indoc; + +#[test] +fn byte_string() { + let indoc = indoc! {b" + a + + \\b + c" + }; + let expected = b"a\n\n \\b\nc"; + assert_eq!(indoc, expected); +} + +#[test] +fn carriage_return() { + // Every line in the string ends with \r\n + let indoc = indoc! {" + a + + \\b + c" + }; + let expected = "a\n\n \\b\nc"; + assert_eq!(indoc, expected); +} + +#[test] +fn trailing_comma() { + let indoc = indoc! { + " + test + ", + }; + let expected = "test\n"; + assert_eq!(indoc, expected); +} + +#[test] +fn empty_string() { + let indoc = indoc! {""}; + let expected = ""; + assert_eq!(indoc, expected); +} + +#[test] +fn joined_first_line() { + let indoc = indoc! {"\ + a" + }; + let expected = "a"; + assert_eq!(indoc, expected); +} + +#[test] +fn joined_lines() { + let indoc = indoc! {" + a\ + b + c\ + d + e" + }; + let expected = "ab\ncd\ne"; + assert_eq!(indoc, expected); +} + +#[test] +fn no_leading_newline() { + let indoc = indoc! {"a + b + c"}; + let expected = "a\nb\nc"; + assert_eq!(indoc, expected); +} + +#[test] +fn one_line() { + let indoc = indoc! {"a"}; + let expected = "a"; + assert_eq!(indoc, expected); +} + +#[test] +fn raw_byte_string() { + let indoc = indoc! {br#" + "a" + + \\b + c"# + }; + let expected = b"\"a\"\n\n \\\\b\nc"; + assert_eq!(indoc, expected); +} + +#[test] +fn raw_string() { + let indoc = indoc! {r#" + "a" + + \\b + c"# + }; + let expected = "\"a\"\n\n \\\\b\nc"; + assert_eq!(indoc, expected); +} + +#[test] +fn string() { + let indoc = indoc! {" + a + + \\b + c" + }; + let expected = "a\n\n \\b\nc"; + assert_eq!(indoc, expected); +} + +#[test] +fn string_trailing_newline() { + let indoc = indoc! {" + a + + \\b + c + "}; + let expected = "a\n\n \\b\nc\n"; + assert_eq!(indoc, expected); +} + +#[test] +fn trailing_whitespace() { + let indoc = indoc! {" + 2 below + + 0 below + + -2 below + + end" + }; + let expected = "2 below\n \n0 below\n\n-2 below\n\nend"; + assert_eq!(indoc, expected); +} + +#[test] +fn indoc_as_format_string() { + let s = format!(indoc! {"{}"}, true); + assert_eq!(s, "true"); +} + +#[test] +fn test_metavariable() { + macro_rules! indoc_wrapper { + ($e:expr) => { + indoc!($e) + }; + } + + let indoc = indoc_wrapper! {" + macros, how do they work + "}; + let expected = "macros, how do they work\n"; + assert_eq!(indoc, expected); +} diff --git a/vendor/indoc/tests/test_unindent.rs b/vendor/indoc/tests/test_unindent.rs new file mode 100644 index 000000000..798907c5e --- /dev/null +++ b/vendor/indoc/tests/test_unindent.rs @@ -0,0 +1,53 @@ +#![allow(clippy::shadow_unrelated)] + +use unindent::{unindent, unindent_bytes, Unindent}; + +#[test] +fn fn_unindent_str() { + let s = " + line one + line two"; + assert_eq!(unindent(s), "line one\nline two"); + + let s = "\n\t\t\tline one\n\t\t\tline two"; + assert_eq!(unindent(s), "line one\nline two"); +} + +#[test] +fn fn_unindent_bytes() { + let b = b" + line one + line two"; + assert_eq!(unindent_bytes(b), b"line one\nline two"); + + let b = b"\n\t\t\tline one\n\t\t\tline two"; + assert_eq!(unindent_bytes(b), b"line one\nline two"); +} + +#[test] +fn trait_unindent_str() { + let s = " + line one + line two"; + assert_eq!(s.unindent(), "line one\nline two"); + + let s = "\n\t\t\tline one\n\t\t\tline two"; + assert_eq!(s.unindent(), "line one\nline two"); +} + +#[test] +fn trait_unindent_bytes() { + let b = b" + line one + line two"; + assert_eq!(b.unindent(), b"line one\nline two"); + + let b = b"\n\t\t\tline one\n\t\t\tline two"; + assert_eq!(b.unindent(), b"line one\nline two"); +} + +#[test] +fn carriage_returns() { + let s = "\r\n\tline one\r\n\tline two"; + assert_eq!(unindent(s), "line one\r\nline two"); +} diff --git a/vendor/indoc/tests/test_writedoc.rs b/vendor/indoc/tests/test_writedoc.rs new file mode 100644 index 000000000..8d1946892 --- /dev/null +++ b/vendor/indoc/tests/test_writedoc.rs @@ -0,0 +1,57 @@ +#![allow(clippy::if_same_then_else)] + +use indoc::writedoc; +use std::fmt::Write as _; + +#[test] +fn test_write_to_string() { + let mut s = String::new(); + writedoc!( + s, + " + one + two + ", + ) + .unwrap(); + + let expected = "one\ntwo\n"; + assert_eq!(s, expected); +} + +#[test] +fn test_format_args() { + let mut s = String::new(); + writedoc!( + s, + " + {} + {} + ", + 0, + 0, + ) + .unwrap(); + + let expected = "0\n0\n"; + assert_eq!(s, expected); +} + +#[test] +fn test_angle_bracket_parsing() { + const ZERO: usize = 0; + + struct Pair(A, B); + impl Pair<(), ()> { + const ONE: usize = 1; + } + + let mut s = String::new(); + let _ = writedoc! { + if ZERO < Pair::<(), ()>::ONE { &mut s } else { &mut s }, + "writedoc", + }; + + let expected = "writedoc"; + assert_eq!(s, expected); +} diff --git a/vendor/indoc/tests/ui/no-arguments.rs b/vendor/indoc/tests/ui/no-arguments.rs new file mode 100644 index 000000000..ea394d8f2 --- /dev/null +++ b/vendor/indoc/tests/ui/no-arguments.rs @@ -0,0 +1,5 @@ +use indoc::indoc; + +fn main() { + indoc!(); +} diff --git a/vendor/indoc/tests/ui/no-arguments.stderr b/vendor/indoc/tests/ui/no-arguments.stderr new file mode 100644 index 000000000..110e44106 --- /dev/null +++ b/vendor/indoc/tests/ui/no-arguments.stderr @@ -0,0 +1,7 @@ +error: unexpected end of macro invocation, expected format string + --> tests/ui/no-arguments.rs:4:5 + | +4 | indoc!(); + | ^^^^^^^^ + | + = note: this error originates in the macro `indoc` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/vendor/indoc/tests/ui/non-lit.rs b/vendor/indoc/tests/ui/non-lit.rs new file mode 100644 index 000000000..d51072d88 --- /dev/null +++ b/vendor/indoc/tests/ui/non-lit.rs @@ -0,0 +1,5 @@ +use indoc::indoc; + +fn main() { + indoc!(fail); +} diff --git a/vendor/indoc/tests/ui/non-lit.stderr b/vendor/indoc/tests/ui/non-lit.stderr new file mode 100644 index 000000000..ba1b7466c --- /dev/null +++ b/vendor/indoc/tests/ui/non-lit.stderr @@ -0,0 +1,5 @@ +error: argument must be a single string literal + --> tests/ui/non-lit.rs:4:12 + | +4 | indoc!(fail); + | ^^^^ diff --git a/vendor/indoc/tests/ui/non-string.rs b/vendor/indoc/tests/ui/non-string.rs new file mode 100644 index 000000000..174ea95a8 --- /dev/null +++ b/vendor/indoc/tests/ui/non-string.rs @@ -0,0 +1,5 @@ +use indoc::indoc; + +fn main() { + indoc!(64); +} diff --git a/vendor/indoc/tests/ui/non-string.stderr b/vendor/indoc/tests/ui/non-string.stderr new file mode 100644 index 000000000..4c1d4279c --- /dev/null +++ b/vendor/indoc/tests/ui/non-string.stderr @@ -0,0 +1,5 @@ +error: argument must be a single string literal + --> tests/ui/non-string.rs:4:12 + | +4 | indoc!(64); + | ^^ diff --git a/vendor/indoc/tests/ui/printdoc-binary.rs b/vendor/indoc/tests/ui/printdoc-binary.rs new file mode 100644 index 000000000..24e500e66 --- /dev/null +++ b/vendor/indoc/tests/ui/printdoc-binary.rs @@ -0,0 +1,5 @@ +use indoc::printdoc; + +fn main() { + printdoc!(b""); +} diff --git a/vendor/indoc/tests/ui/printdoc-binary.stderr b/vendor/indoc/tests/ui/printdoc-binary.stderr new file mode 100644 index 000000000..a1fb07862 --- /dev/null +++ b/vendor/indoc/tests/ui/printdoc-binary.stderr @@ -0,0 +1,5 @@ +error: byte strings are not supported in formatting macros + --> tests/ui/printdoc-binary.rs:4:15 + | +4 | printdoc!(b""); + | ^^^ diff --git a/vendor/indoc/tests/ui/printdoc-extra-arg.rs b/vendor/indoc/tests/ui/printdoc-extra-arg.rs new file mode 100644 index 000000000..661e3a0b6 --- /dev/null +++ b/vendor/indoc/tests/ui/printdoc-extra-arg.rs @@ -0,0 +1,5 @@ +use indoc::printdoc; + +fn main() { + printdoc!("", 0); +} diff --git a/vendor/indoc/tests/ui/printdoc-extra-arg.stderr b/vendor/indoc/tests/ui/printdoc-extra-arg.stderr new file mode 100644 index 000000000..94aaabe92 --- /dev/null +++ b/vendor/indoc/tests/ui/printdoc-extra-arg.stderr @@ -0,0 +1,7 @@ +error: argument never used + --> tests/ui/printdoc-extra-arg.rs:4:19 + | +4 | printdoc!("", 0); + | -- ^ argument never used + | | + | formatting specifier missing diff --git a/vendor/indoc/tests/ui/printdoc-no-arg.rs b/vendor/indoc/tests/ui/printdoc-no-arg.rs new file mode 100644 index 000000000..90ea148a1 --- /dev/null +++ b/vendor/indoc/tests/ui/printdoc-no-arg.rs @@ -0,0 +1,5 @@ +use indoc::printdoc; + +fn main() { + printdoc!("{}"); +} diff --git a/vendor/indoc/tests/ui/printdoc-no-arg.stderr b/vendor/indoc/tests/ui/printdoc-no-arg.stderr new file mode 100644 index 000000000..19d0ea543 --- /dev/null +++ b/vendor/indoc/tests/ui/printdoc-no-arg.stderr @@ -0,0 +1,5 @@ +error: 1 positional argument in format string, but no arguments were given + --> tests/ui/printdoc-no-arg.rs:4:16 + | +4 | printdoc!("{}"); + | ^^ diff --git a/vendor/indoc/tests/ui/printdoc-no-display.rs b/vendor/indoc/tests/ui/printdoc-no-display.rs new file mode 100644 index 000000000..22c3ebc0e --- /dev/null +++ b/vendor/indoc/tests/ui/printdoc-no-display.rs @@ -0,0 +1,7 @@ +use indoc::printdoc; + +struct NoDisplay; + +fn main() { + printdoc!("{}", NoDisplay); +} diff --git a/vendor/indoc/tests/ui/printdoc-no-display.stderr b/vendor/indoc/tests/ui/printdoc-no-display.stderr new file mode 100644 index 000000000..1e0fee569 --- /dev/null +++ b/vendor/indoc/tests/ui/printdoc-no-display.stderr @@ -0,0 +1,9 @@ +error[E0277]: `NoDisplay` doesn't implement `std::fmt::Display` + --> tests/ui/printdoc-no-display.rs:6:21 + | +6 | printdoc!("{}", NoDisplay); + | ^^^^^^^^^ `NoDisplay` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `NoDisplay` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/vendor/indoc/tests/ui/printdoc-no-named-arg.rs b/vendor/indoc/tests/ui/printdoc-no-named-arg.rs new file mode 100644 index 000000000..e4d5d9799 --- /dev/null +++ b/vendor/indoc/tests/ui/printdoc-no-named-arg.rs @@ -0,0 +1,5 @@ +use indoc::printdoc; + +fn main() { + printdoc!("{named}"); +} diff --git a/vendor/indoc/tests/ui/printdoc-no-named-arg.stderr b/vendor/indoc/tests/ui/printdoc-no-named-arg.stderr new file mode 100644 index 000000000..bed418d92 --- /dev/null +++ b/vendor/indoc/tests/ui/printdoc-no-named-arg.stderr @@ -0,0 +1,5 @@ +error[E0425]: cannot find value `named` in this scope + --> tests/ui/printdoc-no-named-arg.rs:4:17 + | +4 | printdoc!("{named}"); + | ^^^^^ not found in this scope diff --git a/vendor/indoc/tests/ui/three-arguments.rs b/vendor/indoc/tests/ui/three-arguments.rs new file mode 100644 index 000000000..7bd11e2d2 --- /dev/null +++ b/vendor/indoc/tests/ui/three-arguments.rs @@ -0,0 +1,9 @@ +use indoc::indoc; + +fn main() { + indoc!(" + a + b + c + " 64 128); +} diff --git a/vendor/indoc/tests/ui/three-arguments.stderr b/vendor/indoc/tests/ui/three-arguments.stderr new file mode 100644 index 000000000..d3e8dbe65 --- /dev/null +++ b/vendor/indoc/tests/ui/three-arguments.stderr @@ -0,0 +1,5 @@ +error: unexpected tokens in macro invocation; indoc argument must be a single string literal + --> tests/ui/three-arguments.rs:8:11 + | +8 | " 64 128); + | ^^^^^^ diff --git a/vendor/indoc/tests/ui/two-arguments.rs b/vendor/indoc/tests/ui/two-arguments.rs new file mode 100644 index 000000000..f979fed42 --- /dev/null +++ b/vendor/indoc/tests/ui/two-arguments.rs @@ -0,0 +1,9 @@ +use indoc::indoc; + +fn main() { + indoc!(" + a + b + c + " 64); +} diff --git a/vendor/indoc/tests/ui/two-arguments.stderr b/vendor/indoc/tests/ui/two-arguments.stderr new file mode 100644 index 000000000..eccdecfca --- /dev/null +++ b/vendor/indoc/tests/ui/two-arguments.stderr @@ -0,0 +1,5 @@ +error: unexpected token in macro invocation; indoc argument must be a single string literal + --> tests/ui/two-arguments.rs:8:11 + | +8 | " 64); + | ^^ -- cgit v1.2.3