Accept trailing comma in test of impl Debug for PackageId · rust-lang/cargo@1b10b70 (original) (raw)

`@@ -224,15 +224,32 @@ mod tests {

`

224

224

`let pkg_id = PackageId::new("foo", "1.0.0", SourceId::for_registry(&loc).unwrap()).unwrap();

`

225

225

`` assert_eq!(r#"PackageId { name: "foo", version: "1.0.0", source: "registry https://github.com/rust-lang/crates.io-index" }"#, format!("{:?}", pkg_id));

``

226

226

``

227

``

`-

let pretty = r#"

`

``

227

`+

let expected = r#"

`

``

228

`+

PackageId {

`

``

229

`+

name: "foo",

`

``

230

`+

version: "1.0.0",

`

``

231

`` +

source: "registry https://github.com/rust-lang/crates.io-index",

``

``

232

`+

}

`

``

233

`+

"#

`

``

234

`+

.trim();

`

``

235

+

``

236

`+

// Can be removed once trailing commas in Debug have reached the stable

`

``

237

`+

// channel.

`

``

238

`+

let expected_without_trailing_comma = r#"

`

228

239

`PackageId {

`

229

240

` name: "foo",

`

230

241

` version: "1.0.0",

`

231

242

`` source: "registry https://github.com/rust-lang/crates.io-index"

``

232

243

`}

`

233

244

`"#

`

234

245

`.trim();

`

235

``

`-

assert_eq!(pretty, format!("{:#?}", pkg_id));

`

``

246

+

``

247

`+

let actual = format!("{:#?}", pkg_id);

`

``

248

`+

if actual.ends_with(",\n}") {

`

``

249

`+

assert_eq!(actual, expected);

`

``

250

`+

} else {

`

``

251

`+

assert_eq!(actual, expected_without_trailing_comma);

`

``

252

`+

}

`

236

253

`}

`

237

254

``

238

255

`#[test]

`