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

pomsky-lang / pomsky / 12097940961

30 Nov 2024 04:39PM UTC coverage: 81.072% (-0.2%) from 81.241%
12097940961

push

github

Aloso
feat: Allow supported boolean Unicode properties in Java

0 of 12 new or added lines in 2 files covered. (0.0%)

4296 of 5299 relevant lines covered (81.07%)

405519.19 hits per line

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

76.67
/pomsky-syntax/src/exprs/char_class/unicode.rs
1
use super::char_group::{GroupName, ScriptExtension};
2
use crate::error::CharClassError;
3

4
include!(concat!(env!("OUT_DIR"), "/unicode_data.rs"));
5

6
pub(super) fn parse_group_name(
164✔
7
    kind: Option<&str>,
164✔
8
    name: &str,
164✔
9
) -> Result<GroupName, CharClassError> {
164✔
10
    let mut name_str;
164✔
11
    let mut name = name;
164✔
12
    if let Some("blk" | "block") = kind {
164✔
13
        name_str = String::with_capacity(name.len() + 2);
2✔
14
        name_str.push_str("In");
2✔
15
        name_str.push_str(name);
2✔
16
        name = &name_str;
2✔
17
    }
162✔
18

19
    let mut res = match PARSE_LUT.binary_search_by_key(&name, |(k, _)| k) {
1,804✔
20
        Ok(n) => PARSE_LUT[n].1,
163✔
21
        Err(_) => {
22
            return Err(CharClassError::UnknownNamedClass {
1✔
23
                found: name.into(),
1✔
24
                extra_in_prefix: name.starts_with("InIn"),
1✔
25
                #[cfg(feature = "suggestions")]
1✔
26
                similar: crate::util::find_suggestion(
1✔
27
                    name,
1✔
28
                    PARSE_LUT.iter().map(|&(name, _)| name),
976✔
29
                ),
1✔
30
            })
1✔
31
        }
32
    };
33
    if let Some(kind) = kind {
163✔
34
        match &mut res {
14✔
35
            GroupName::Word
36
            | GroupName::Digit
37
            | GroupName::Space
38
            | GroupName::HorizSpace
39
            | GroupName::VertSpace
40
            | GroupName::OtherProperties(_) => return Err(CharClassError::UnexpectedPrefix),
1✔
41
            GroupName::Category(_) => {
42
                if kind != "gc" && kind != "general_category" {
3✔
43
                    return Err(CharClassError::WrongPrefix {
×
44
                        expected: "general_category (gc)",
×
45
                        has_in_prefix: false,
×
46
                    });
×
47
                }
3✔
48
            }
49
            GroupName::Script(_, is_extension) => {
7✔
50
                if kind == "sc" || kind == "script" {
7✔
51
                    *is_extension = ScriptExtension::No;
4✔
52
                } else if kind == "scx" || kind == "script_extensions" {
4✔
53
                    *is_extension = ScriptExtension::Yes;
3✔
54
                } else {
3✔
55
                    return Err(CharClassError::WrongPrefix {
×
56
                        expected: "script_extensions (scx) or script (sc)",
×
57
                        has_in_prefix: false,
×
58
                    });
×
59
                }
60
            }
61
            GroupName::CodeBlock(_) => {
62
                if kind != "blk" && kind != "block" {
3✔
63
                    return Err(CharClassError::WrongPrefix {
1✔
64
                        expected: "block (blk)",
1✔
65
                        has_in_prefix: true,
1✔
66
                    });
1✔
67
                }
2✔
68
            }
69
        }
70
    }
149✔
71

72
    Ok(res)
161✔
73
}
164✔
74

75
pub fn blocks_supported_in_dotnet() -> &'static [&'static str] {
3✔
76
    DOTNET_SUPPORTED
3✔
77
}
3✔
78

NEW
79
pub fn props_supported_in_java() -> &'static [&'static str] {
×
NEW
80
    JAVA_SUPPORTED
×
NEW
81
}
×
82

83
/// Returns the list of all accepted shorthands.
84
pub fn list_shorthands() -> impl Iterator<Item = (&'static str, GroupName)> {
×
85
    PARSE_LUT.iter().copied()
×
86
}
×
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

© 2025 Coveralls, Inc