| 1 | // (c) 2016-2017 Productize SPRL <[email protected]> |
| 2 | |
| 3 | use serrust-analyzer cargo symbolic_expressions 5.0.3 ser/; |
| 4 | use formatterrust-analyzer cargo symbolic_expressions 5.0.3 formatter/; |
| 5 | use parserrust-analyzer cargo symbolic_expressions 5.0.3 parser/; |
| 6 | |
| 7 | fn check_parse_resrust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse_res().(s: &str, o: &str) { |
| 8 | let e = parserrust-analyzer cargo symbolic_expressions 5.0.3 parser/::parse_strrust-analyzer cargo symbolic_expressions 5.0.3 parser/parse_str().(s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 9 | let t = serrust-analyzer cargo symbolic_expressions 5.0.3 ser/::to_stringrust-analyzer cargo symbolic_expressions 5.0.3 ser/to_string().(&e).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 10 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(o, t) |
| 11 | } |
| 12 | |
| 13 | fn check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().(s: &str) { |
| 14 | let e = parserrust-analyzer cargo symbolic_expressions 5.0.3 parser/::parse_strrust-analyzer cargo symbolic_expressions 5.0.3 parser/parse_str().(s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 15 | let t = serrust-analyzer cargo symbolic_expressions 5.0.3 ser/::to_stringrust-analyzer cargo symbolic_expressions 5.0.3 ser/to_string().(&e).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 16 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, t) |
| 17 | } |
| 18 | |
| 19 | fn check_parse_kicadrust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse_kicad().(s: &str) { |
| 20 | let e = parserrust-analyzer cargo symbolic_expressions 5.0.3 parser/::parse_strrust-analyzer cargo symbolic_expressions 5.0.3 parser/parse_str().(s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 21 | let t = serrust-analyzer cargo symbolic_expressions 5.0.3 ser/::to_string_with_rulesrust-analyzer cargo symbolic_expressions 5.0.3 ser/to_string_with_rules().(&e, kicad_test_rulesrust-analyzer cargo symbolic_expressions 5.0.3 test/kicad_test_rules().()).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 22 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, t) |
| 23 | } |
| 24 | |
| 25 | fn check_parse_rulesrust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse_rules().(s: &str, rules: formatterrust-analyzer cargo symbolic_expressions 5.0.3 formatter/::Rulesrust-analyzer cargo symbolic_expressions 5.0.3 formatter/Rules#) { |
| 26 | let e = parserrust-analyzer cargo symbolic_expressions 5.0.3 parser/::parse_strrust-analyzer cargo symbolic_expressions 5.0.3 parser/parse_str().(s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 27 | let t = serrust-analyzer cargo symbolic_expressions 5.0.3 ser/::to_string_with_rulesrust-analyzer cargo symbolic_expressions 5.0.3 ser/to_string_with_rules().(&e, rules).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 28 | assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, t) |
| 29 | } |
| 30 | |
| 31 | |
| 32 | fn parse_failrust-analyzer cargo symbolic_expressions 5.0.3 test/parse_fail().(s: &str) { |
| 33 | parserrust-analyzer cargo symbolic_expressions 5.0.3 parser/::parse_strrust-analyzer cargo symbolic_expressions 5.0.3 parser/parse_str().(s).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(); |
| 34 | } |
| 35 | |
| 36 | fn kicad_test_rulesrust-analyzer cargo symbolic_expressions 5.0.3 test/kicad_test_rules().() -> formatterrust-analyzer cargo symbolic_expressions 5.0.3 formatter/::Rulesrust-analyzer cargo symbolic_expressions 5.0.3 formatter/Rules# { |
| 37 | let mut rf = formatterrust-analyzer cargo symbolic_expressions 5.0.3 formatter/::Rulesrust-analyzer cargo symbolic_expressions 5.0.3 formatter/Rules#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(); |
| 38 | rf.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("layer", 1); |
| 39 | rf.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("desc", 1); |
| 40 | rf.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("fp_text", 1); |
| 41 | rf.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("fp_poly", 1); |
| 42 | rf.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("fp_line", 1); |
| 43 | rf.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("pad", 1); |
| 44 | rf.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("general", 1); |
| 45 | rf |
| 46 | } |
| 47 | |
| 48 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 49 | fn test_emptyrust-analyzer cargo symbolic_expressions 5.0.3 test/test_empty().() { |
| 50 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("") |
| 51 | } |
| 52 | |
| 53 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 54 | fn test_empty_qstringrust-analyzer cargo symbolic_expressions 5.0.3 test/test_empty_qstring().() { |
| 55 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("(hello \"\")") |
| 56 | } |
| 57 | |
| 58 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 59 | fn test_minimalrust-analyzer cargo symbolic_expressions 5.0.3 test/test_minimal().() { |
| 60 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("()") |
| 61 | } |
| 62 | |
| 63 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 64 | fn test_stringrust-analyzer cargo symbolic_expressions 5.0.3 test/test_string().() { |
| 65 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("hello") |
| 66 | } |
| 67 | |
| 68 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 69 | fn test_qstring_arust-analyzer cargo symbolic_expressions 5.0.3 test/test_qstring_a().() { |
| 70 | check_parse_resrust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse_res().("\"hello\"", "hello") |
| 71 | } |
| 72 | |
| 73 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 74 | fn test_qstring_a2rust-analyzer cargo symbolic_expressions 5.0.3 test/test_qstring_a2().() { |
| 75 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("\"hello world\"") |
| 76 | } |
| 77 | |
| 78 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 79 | fn test_qstring_a3rust-analyzer cargo symbolic_expressions 5.0.3 test/test_qstring_a3().() { |
| 80 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("\"hello(world)\"") |
| 81 | } |
| 82 | |
| 83 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 84 | fn test_numberrust-analyzer cargo symbolic_expressions 5.0.3 test/test_number().() { |
| 85 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("1.3") |
| 86 | } |
| 87 | |
| 88 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 89 | fn test_float_vs_intrust-analyzer cargo symbolic_expressions 5.0.3 test/test_float_vs_int().() { |
| 90 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("2.0") |
| 91 | } |
| 92 | |
| 93 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 94 | fn test_doublerust-analyzer cargo symbolic_expressions 5.0.3 test/test_double().() { |
| 95 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("(())") |
| 96 | } |
| 97 | |
| 98 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 99 | fn test_br_stringrust-analyzer cargo symbolic_expressions 5.0.3 test/test_br_string().() { |
| 100 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("(world)") |
| 101 | } |
| 102 | |
| 103 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 104 | fn test_br_qstringrust-analyzer cargo symbolic_expressions 5.0.3 test/test_br_qstring().() { |
| 105 | check_parse_resrust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse_res().("(\"world\")", "(world)") |
| 106 | } |
| 107 | |
| 108 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 109 | fn test_br_intrust-analyzer cargo symbolic_expressions 5.0.3 test/test_br_int().() { |
| 110 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("(42)") |
| 111 | } |
| 112 | |
| 113 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 114 | fn test_br_floatrust-analyzer cargo symbolic_expressions 5.0.3 test/test_br_float().() { |
| 115 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("(12.7)") |
| 116 | } |
| 117 | |
| 118 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 119 | fn test_br_qbrstringrust-analyzer cargo symbolic_expressions 5.0.3 test/test_br_qbrstring().() { |
| 120 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("(\"(()\")") |
| 121 | } |
| 122 | |
| 123 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 124 | fn test_number_stringrust-analyzer cargo symbolic_expressions 5.0.3 test/test_number_string().() { |
| 125 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().("567A_WZ") |
| 126 | } |
| 127 | |
| 128 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 129 | #[should_panic(expected = "End of file reached")] |
| 130 | fn test_invalid1rust-analyzer cargo symbolic_expressions 5.0.3 test/test_invalid1().() { |
| 131 | parse_failrust-analyzer cargo symbolic_expressions 5.0.3 test/parse_fail().("(") |
| 132 | } |
| 133 | |
| 134 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 135 | #[should_panic(expected = "Unexpected )")] |
| 136 | fn test_invalid2rust-analyzer cargo symbolic_expressions 5.0.3 test/test_invalid2().() { |
| 137 | parse_failrust-analyzer cargo symbolic_expressions 5.0.3 test/parse_fail().(")") |
| 138 | } |
| 139 | |
| 140 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 141 | #[should_panic(expected = "End of file reached")] |
| 142 | fn test_invalid3rust-analyzer cargo symbolic_expressions 5.0.3 test/test_invalid3().() { |
| 143 | parse_failrust-analyzer cargo symbolic_expressions 5.0.3 test/parse_fail().("\"hello") |
| 144 | } |
| 145 | |
| 146 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 147 | #[should_panic(expected = "line: 4, col: 5")] |
| 148 | fn test_invalid_check_positionrust-analyzer cargo symbolic_expressions 5.0.3 test/test_invalid_check_position().() { |
| 149 | parse_failrust-analyzer cargo symbolic_expressions 5.0.3 test/parse_fail().( |
| 150 | "\"hello |
| 151 | |
| 152 | |
| 153 | ", |
| 154 | ) |
| 155 | } |
| 156 | |
| 157 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 158 | fn test_complexrust-analyzer cargo symbolic_expressions 5.0.3 test/test_complex().() { |
| 159 | check_parserust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse().( |
| 160 | "(module SWITCH_3W_SIDE_MMP221-R (layer F.Cu) (descr \"\") (pad 1 thru_hole rect \ |
| 161 | (size 1.2 1.2) (at -2.5 -1.6 0) (layers *.Cu *.Mask) (drill 0.8)) (pad 2 \ |
| 162 | thru_hole rect (size 1.2 1.2) (at 0.0 -1.6 0) (layers *.Cu *.Mask) (drill 0.8)) \ |
| 163 | (pad 3 thru_hole rect (size 1.2 1.2) (at 2.5 -1.6 0) (layers *.Cu *.Mask) (drill \ |
| 164 | 0.8)) (pad 5 thru_hole rect (size 1.2 1.2) (at 0.0 1.6 0) (layers *.Cu *.Mask) \ |
| 165 | (drill 0.8)) (pad 6 thru_hole rect (size 1.2 1.2) (at -2.5 1.6 0) (layers *.Cu \ |
| 166 | *.Mask) (drill 0.8)) (pad 4 thru_hole rect (size 1.2 1.2) (at 2.5 1.6 0) (layers \ |
| 167 | *.Cu *.Mask) (drill 0.8)) (fp_line (start -4.5 -1.75) (end 4.5 -1.75) (layer \ |
| 168 | F.SilkS) (width 0.127)) (fp_line (start 4.5 -1.75) (end 4.5 1.75) (layer \ |
| 169 | F.SilkS) (width 0.127)) (fp_line (start 4.5 1.75) (end -4.5 1.75) (layer \ |
| 170 | F.SilkS) (width 0.127)) (fp_line (start -4.5 1.75) (end -4.5 -1.75) (layer \ |
| 171 | F.SilkS) (width 0.127)))", |
| 172 | ) |
| 173 | } |
| 174 | |
| 175 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 176 | fn test_kicad_1rust-analyzer cargo symbolic_expressions 5.0.3 test/test_kicad_1().() { |
| 177 | check_parse_kicadrust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse_kicad().( |
| 178 | "(module SILABS_EFM32_QFM24 |
| 179 | (layer F.Cu))", |
| 180 | ) |
| 181 | } |
| 182 | |
| 183 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 184 | fn test_multilinerust-analyzer cargo symbolic_expressions 5.0.3 test/test_multiline().() { |
| 185 | let mut rules = formatterrust-analyzer cargo symbolic_expressions 5.0.3 formatter/::Rulesrust-analyzer cargo symbolic_expressions 5.0.3 formatter/Rules#::newrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V>`]new().(); |
| 186 | rules.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("foo", 1); |
| 187 | rules.insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().("mars", 1); |
| 188 | check_parse_rulesrust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse_rules().( |
| 189 | "\ |
| 190 | (hello \"test it\" |
| 191 | (foo bar) |
| 192 | (mars venus))", |
| 193 | rules, |
| 194 | ) |
| 195 | } |
| 196 | |
| 197 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 198 | fn test_multiline_two_emptyrust-analyzer cargo symbolic_expressions 5.0.3 test/test_multiline_two_empty().() { |
| 199 | check_parse_resrust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse_res().( |
| 200 | "\ |
| 201 | (hello |
| 202 | |
| 203 | world)", |
| 204 | "(hello world)", |
| 205 | ) |
| 206 | } |
| 207 | |
| 208 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 209 | fn test_fail_pcbrust-analyzer cargo symbolic_expressions 5.0.3 test/test_fail_pcb().() { |
| 210 | check_parse_kicadrust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse_kicad().( |
| 211 | "\ |
| 212 | (kicad_pcb (version 4) (host pcbnew \"(2015-05-31 BZR 5692)-product\") |
| 213 | \ |
| 214 | (general))", |
| 215 | ) |
| 216 | } |
| 217 | |
| 218 | #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:] |
| 219 | fn test_quoted_escaperust-analyzer cargo symbolic_expressions 5.0.3 test/test_quoted_escape().() { |
| 220 | check_parse_kicadrust-analyzer cargo symbolic_expressions 5.0.3 test/check_parse_kicad().("(hello \"21\\\" (inch test)\")") |
| 221 | } |