Debian Codegraph @

tests/helper_with_space.rs

raw symbols SCIP
1 use handlebarsrust-analyzer cargo handlebars 5.1.2 crate/::*;
2 use serde_jsonrust-analyzer cargo serde_json 1.0.114 crate/::jsonrust-analyzer cargo serde_json 1.0.114 macros/json!;
3
4 fn dumprust-analyzer cargo handlebars 5.1.2 dump().<'reg, 'rc>(
5 h: &Helperrust-analyzer cargo handlebars 5.1.2 render/Helper#<'rc>,
6 _: &'reg Handlebarsrust-analyzer cargo handlebars 5.1.2 registry/Registry#,
7 _: &Contextrust-analyzer cargo handlebars 5.1.2 context/Context#,
8 _: &mut RenderContextrust-analyzer cargo handlebars 5.1.2 render/RenderContext#,
9 out: &mut dyn Outputrust-analyzer cargo handlebars 5.1.2 output/Output#,
10 ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), RenderErrorrust-analyzer cargo handlebars 5.1.2 error/RenderError#> {
11 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(2, h.paramsrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]params().().lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().());
12
13 let result = h
14 .paramsrust-analyzer cargo handlebars 5.1.2 render/impl#[`Helper<'rc>`]params().()
15 .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()
16 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|p| p.valuerust-analyzer cargo handlebars 5.1.2 json/value/impl#[`PathAndJson<'rc>`]value().().renderrust-analyzer cargo handlebars 5.1.2 json/value/impl#[Json][JsonRender]render().())
17 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>>()
18 .joinrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/impl#[`[T]`]join().(", ");
19 out.writerust-analyzer cargo handlebars 5.1.2 output/Output#write().(&result)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
20
21 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
22 }
23
24 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
25 fn test_helper_with_space_paramrust-analyzer cargo handlebars 5.1.2 test_helper_with_space_param().() {
26 let mut r = Handlebarsrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().();
27 r.register_helperrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_helper().("echo", Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(dumprust-analyzer cargo handlebars 5.1.2 dump().));
28
29 let s = r
30 .render_templaterust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render_template().(
31 "Output: {{echo \"Mozilla Firefox\" \"Google Chrome\"}}",
32 &jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({}),
33 )
34 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
35 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(s, "Output: Mozilla Firefox, Google Chrome".to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().());
36 }
37
38 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
39 fn test_empty_lines_472rust-analyzer cargo handlebars 5.1.2 test_empty_lines_472().() {
40 let mut r = Handlebarsrust-analyzer cargo handlebars 5.1.2 registry/Registry#::newrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]new().();
41
42 r.register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().(
43 "t1",
44 r#"{{#each routes}}
45 import { default as {{this.handler}} } from '{{this.file_path}}'
46 {{/each}}
47
48 addEventListener('fetch', (event) => {
49 event.respondWith(handleEvent(event))
50 })"#,
51 )
52 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
53
54 r.register_template_stringrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]register_template_string().(
55 "t2",
56 r#"addEventListener('fetch', (event) => {
57 event.respondWith(handleEvent(event))
58 })
59
60 {{#each routes}}
61 import { default as {{this.handler}} } from '{{this.file_path}}'
62 {{/each}}
63 "#,
64 )
65 .unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
66
67 let data = jsonrust-analyzer cargo serde_json 1.0.114 macros/json!!({"routes": [{"handler": "__hello_handler", "file_path": "./hello.js"},
68 {"handler": "__world_index_handler", "file_path": "./world/index.js"},
69 {"handler": "__index_handler", "file_path": "./index.js"}]});
70
71 let exp1 = r#"import { default as __hello_handler } from './hello.js'
72 import { default as __world_index_handler } from './world/index.js'
73 import { default as __index_handler } from './index.js'
74
75 addEventListener('fetch', (event) => {
76 event.respondWith(handleEvent(event))
77 })"#;
78
79 let exp2 = r#"addEventListener('fetch', (event) => {
80 event.respondWith(handleEvent(event))
81 })
82
83 import { default as __hello_handler } from './hello.js'
84 import { default as __world_index_handler } from './world/index.js'
85 import { default as __index_handler } from './index.js'
86 "#;
87
88 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t1", &data).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), exp1);
89 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(r.renderrust-analyzer cargo handlebars 5.1.2 registry/impl#[`Registry<'reg>`]render().("t2", &data).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().(), exp2);
90 }