• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pomsky-lang / pomsky / 9142134100

18 May 2024 07:23PM UTC coverage: 82.949% (-1.3%) from 84.258%
9142134100

push

github

Aloso
fix e2e tests

1 of 1 new or added line in 1 file covered. (100.0%)

271 existing lines in 24 files now uncovered.

4242 of 5114 relevant lines covered (82.95%)

420176.26 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/pomsky-syntax/src/exprs/test.rs
1
use crate::Span;
2

3
use super::Literal;
4

5
#[derive(Debug, Clone)]
6
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
7
pub struct Test {
8
    pub cases: Vec<TestCase>,
9
    pub span: Span,
10
}
11

12
#[derive(Debug, Clone)]
13
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
14
pub enum TestCase {
15
    Match(TestCaseMatch),
16
    MatchAll(TestCaseMatchAll),
17
    Reject(TestCaseReject),
18
}
19

20
#[derive(Debug, Clone)]
21
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
22
pub struct TestCaseMatch {
23
    pub literal: Literal,
24
    pub captures: Vec<TestCapture>,
25
    pub span: Span,
26
}
27

28
#[derive(Debug, Clone)]
29
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
30
pub struct TestCaseMatchAll {
31
    pub literal: Literal,
32
    pub matches: Vec<TestCaseMatch>,
33
}
34

35
#[derive(Debug, Clone)]
36
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
37
pub struct TestCaseReject {
38
    pub literal: Literal,
39
    pub as_substring: bool,
40
}
41

42
#[derive(Debug, Clone)]
43
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
44
pub struct TestCapture {
45
    pub ident: CaptureIdent,
46
    pub ident_span: Span,
47
    pub literal: Literal,
48
}
49

50
#[derive(Debug, Clone)]
51
#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
52
pub enum CaptureIdent {
53
    Name(String),
54
    Index(u16),
55
}
56

57
impl TestCase {
58
    #[cfg(feature = "dbg")]
59
    pub(super) fn pretty_print(&self, buf: &mut crate::PrettyPrinter) {
×
60
        match self {
×
61
            TestCase::Match(match_) => {
×
62
                buf.push_str("match ");
×
UNCOV
63
                match_.pretty_print(buf);
×
64
                buf.push(';');
×
65
            }
×
66
            TestCase::MatchAll(match_all) => {
×
67
                buf.push_str("match ");
×
68
                let len = match_all.matches.len();
×
69
                buf.increase_indentation(if len == 0 { 3 } else { 6 });
×
70

71
                for (i, match_) in match_all.matches.iter().enumerate() {
×
UNCOV
72
                    match_.pretty_print(buf);
×
73
                    if i < len - 1 {
×
74
                        buf.push(',');
×
75
                    } else {
×
76
                        buf.decrease_indentation(3);
×
UNCOV
77
                    }
×
78
                    buf.write("\n");
×
79
                }
80
                buf.push_str("in ");
×
81
                match_all.literal.pretty_print(buf);
×
82
                buf.decrease_indentation(3);
×
83
                buf.push(';');
×
84
            }
UNCOV
85
            TestCase::Reject(reject) => {
×
UNCOV
86
                buf.push_str("reject ");
×
87
                if reject.as_substring {
×
UNCOV
88
                    buf.push_str("in ");
×
UNCOV
89
                }
×
UNCOV
90
                reject.literal.pretty_print(buf);
×
UNCOV
91
                buf.push(';');
×
92
            }
93
        }
94
    }
×
95
}
96

97
impl TestCaseMatch {
98
    #[cfg(feature = "dbg")]
99
    pub(super) fn pretty_print(&self, buf: &mut crate::PrettyPrinter) {
×
100
        self.literal.pretty_print(buf);
×
101

×
102
        if !self.captures.is_empty() {
×
UNCOV
103
            buf.start_indentation(" as {");
×
104

×
105
            let len = self.captures.len();
×
106
            for (i, capture) in self.captures.iter().enumerate() {
×
107
                match &capture.ident {
×
108
                    CaptureIdent::Name(name) => buf.push_str(name),
×
109
                    CaptureIdent::Index(idx) => buf.write_fmt(idx),
×
110
                }
111
                buf.push_str(": ");
×
112
                capture.literal.pretty_print(buf);
×
113
                buf.push(',');
×
UNCOV
114
                if i < len - 1 {
×
UNCOV
115
                    buf.write("\n");
×
UNCOV
116
                }
×
117
            }
UNCOV
118
            buf.end_indentation("}");
×
UNCOV
119
        }
×
UNCOV
120
    }
×
121
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc