-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
198 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
error: Backtrace: | ||
[line 4, column 36] Expected '-', found '== 3 %}' | ||
[line 4, column 36] Alt in "== 3 %}" | ||
--> tests/broken/raw-rust-string.rs:4:37 | ||
error: "if" statement is never closed (unexpected end of template) | ||
--> tests/broken/raw-rust-string.rs:4:44 | ||
| | ||
4 | #[oxiplate_inline = r##"{% if "foo" == 3 %}"##] | ||
| ^ | ||
| ^ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use oxiplate_derive::Oxiplate; | ||
|
||
#[derive(Oxiplate)] | ||
#[oxiplate_inline = r#"{{ name ~ " (" ~ company ~ ")" }}"#] | ||
struct User { | ||
name: &'static str, | ||
company: &'static str, | ||
} | ||
|
||
#[test] | ||
fn variable() { | ||
let data = User { | ||
name: "Xavier", | ||
company: "XYZ Company", | ||
}; | ||
|
||
assert_eq!(format!("{data}"), "Xavier (XYZ Company)"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#![feature(prelude_import)] | ||
#[prelude_import] | ||
use std::prelude::rust_2021::*; | ||
#[macro_use] | ||
extern crate std; | ||
use oxiplate_derive::Oxiplate; | ||
#[oxiplate_inline = r#"{{ name ~ " (" ~ company ~ ")" }}"#] | ||
struct User { | ||
name: &'static str, | ||
company: &'static str, | ||
} | ||
impl ::std::fmt::Display for User { | ||
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { | ||
f.write_fmt( | ||
format_args!( | ||
"{0}", ::alloc::__export::must_use({ let res = | ||
::alloc::fmt::format(format_args!("{0}{1}", self.name, | ||
::alloc::__export::must_use({ let res = | ||
::alloc::fmt::format(format_args!("{0}{1}", " (", | ||
::alloc::__export::must_use({ let res = | ||
::alloc::fmt::format(format_args!("{0}{1}", self.company, ")")); res | ||
}))); res }))); res }) | ||
), | ||
)?; | ||
Ok(()) | ||
} | ||
} | ||
extern crate test; | ||
#[cfg(test)] | ||
#[rustc_test_marker = "variable"] | ||
#[doc(hidden)] | ||
pub const variable: test::TestDescAndFn = test::TestDescAndFn { | ||
desc: test::TestDesc { | ||
name: test::StaticTestName("variable"), | ||
ignore: false, | ||
ignore_message: ::core::option::Option::None, | ||
source_file: "oxiplate-derive\\tests\\concat.rs", | ||
start_line: 11usize, | ||
start_col: 4usize, | ||
end_line: 11usize, | ||
end_col: 12usize, | ||
compile_fail: false, | ||
no_run: false, | ||
should_panic: test::ShouldPanic::No, | ||
test_type: test::TestType::IntegrationTest, | ||
}, | ||
testfn: test::StaticTestFn(#[coverage(off)] || test::assert_test_result(variable())), | ||
}; | ||
fn variable() { | ||
let data = User { | ||
name: "Xavier", | ||
company: "XYZ Company", | ||
}; | ||
match ( | ||
&::alloc::__export::must_use({ | ||
let res = ::alloc::fmt::format(format_args!("{0}", data)); | ||
res | ||
}), | ||
&"Xavier (XYZ Company)", | ||
) { | ||
(left_val, right_val) => { | ||
if !(*left_val == *right_val) { | ||
let kind = ::core::panicking::AssertKind::Eq; | ||
::core::panicking::assert_failed( | ||
kind, | ||
&*left_val, | ||
&*right_val, | ||
::core::option::Option::None, | ||
); | ||
} | ||
} | ||
}; | ||
} | ||
#[rustc_main] | ||
#[coverage(off)] | ||
#[doc(hidden)] | ||
pub fn main() -> () { | ||
extern crate test; | ||
test::test_main_static(&[&variable]) | ||
} |