MCPcopy Create free account
hub / github.com/PRQL/prql / test_pipeline

Function test_pipeline

prqlc/prqlc/src/codegen/ast.rs:535–573  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

533
534 #[test]
535 fn test_pipeline() {
536 let short = pr::Expr::new(pr::ExprKind::Ident(pr::Ident::from_name(
537 "short".to_string(),
538 )));
539 let long = pr::Expr::new(pr::ExprKind::Ident(pr::Ident::from_name(
540 "some_really_long_and_really_long_name".to_string(),
541 )));
542
543 let mut opt = WriteOpt {
544 indent: 1,
545 ..Default::default()
546 };
547
548 // short pipelines should be inlined
549 let pipeline = pr::Expr::new(pr::ExprKind::Pipeline(pr::Pipeline {
550 exprs: vec![short.clone(), short.clone(), short.clone()],
551 }));
552 assert_snapshot!(pipeline.write(opt.clone()).unwrap(), @"(short | short | short)");
553
554 // long pipelines should be indented
555 let pipeline = pr::Expr::new(pr::ExprKind::Pipeline(pr::Pipeline {
556 exprs: vec![short.clone(), long.clone(), long, short.clone()],
557 }));
558 // colons are a workaround to avoid trimming
559 assert_snapshot!(pipeline.write(opt.clone()).unwrap(), @"
560 (
561 short
562 some_really_long_and_really_long_name
563 some_really_long_and_really_long_name
564 short
565 )
566 ");
567
568 // sometimes, there is just not enough space
569 opt.rem_width = 4;
570 opt.indent = 100;
571 let pipeline = pr::Expr::new(pr::ExprKind::Pipeline(pr::Pipeline { exprs: vec![short] }));
572 assert!(pipeline.write(opt).is_none());
573 }
574
575 #[test]
576 fn test_escaped_string() {

Callers

nothing calls this directly

Calls 2

IdentClass · 0.85
PipelineClass · 0.85

Tested by

no test coverage detected