wip: tests added for new iterative
This commit is contained in:
1 parent
2ce0752a9c
commit
24572b63de
6 files changed
+191
-69
No files matched your search
@@ -8,6 +8,7 @@ use dioxus::{
|
||||
scheduler::Mutations,
|
||||
DomEdit,
|
||||
};
|
||||
mod test_logging;
|
||||
use dioxus_core as dioxus;
|
||||
use dioxus_html as dioxus_elements;
|
||||
|
||||
@@ -29,29 +30,55 @@ fn test_original_diff() {
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
async fn test_iterative_diff() {
|
||||
async fn test_iterative_create() {
|
||||
static App: FC<()> = |cx| {
|
||||
cx.render(rsx! {
|
||||
div {
|
||||
div {
|
||||
"Hello, world!"
|
||||
div {
|
||||
div {
|
||||
Fragment {
|
||||
"hello"
|
||||
"world"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
let shared = SharedResources::new();
|
||||
test_logging::set_up_logging();
|
||||
|
||||
let mut machine = DiffMachine::new_headless(&shared);
|
||||
let a = machine.work().await.unwrap();
|
||||
let mut dom = VirtualDom::new(App);
|
||||
let mutations = dom.rebuild_async().await.unwrap();
|
||||
dbg!(mutations);
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
async fn websys_loop() {
|
||||
///loop {
|
||||
/// let deadline = request_idle_callback().await;
|
||||
/// let edits = dom.work(deadline);
|
||||
/// request_animation_frame().await;
|
||||
/// apply(edits);
|
||||
///}
|
||||
async fn test_iterative_create_list() {
|
||||
static App: FC<()> = |cx| {
|
||||
cx.render(rsx! {
|
||||
{(0..10).map(|f| rsx!{ div {
|
||||
"hello"
|
||||
}})}
|
||||
})
|
||||
};
|
||||
|
||||
test_logging::set_up_logging();
|
||||
|
||||
let mut dom = VirtualDom::new(App);
|
||||
let mutations = dom.rebuild_async().await.unwrap();
|
||||
dbg!(mutations);
|
||||
}
|
||||
|
||||
// #[async_std::test]
|
||||
// async fn websys_loop() {
|
||||
// ///loop {
|
||||
// /// let deadline = request_idle_callback().await;
|
||||
// /// let edits = dom.work(deadline);
|
||||
// /// request_animation_frame().await;
|
||||
// /// apply(edits);
|
||||
// ///}
|
||||
// }
|
||||
@@ -0,0 +1,49 @@
|
||||
pub fn set_up_logging() {
|
||||
use fern::colors::{Color, ColoredLevelConfig};
|
||||
use log::debug;
|
||||
|
||||
// configure colors for the whole line
|
||||
let colors_line = ColoredLevelConfig::new()
|
||||
.error(Color::Red)
|
||||
.warn(Color::Yellow)
|
||||
// we actually don't need to specify the color for debug and info, they are white by default
|
||||
.info(Color::White)
|
||||
.debug(Color::White)
|
||||
// depending on the terminals color scheme, this is the same as the background color
|
||||
.trace(Color::BrightBlack);
|
||||
|
||||
// configure colors for the name of the level.
|
||||
// since almost all of them are the same as the color for the whole line, we
|
||||
// just clone `colors_line` and overwrite our changes
|
||||
let colors_level = colors_line.clone().info(Color::Green);
|
||||
// here we set up our fern Dispatch
|
||||
fern::Dispatch::new()
|
||||
.format(move |out, message, record| {
|
||||
out.finish(format_args!(
|
||||
"{color_line}[{level}{color_line}] {message}\x1B[0m",
|
||||
color_line = format_args!(
|
||||
"\x1B[{}m",
|
||||
colors_line.get_color(&record.level()).to_fg_str()
|
||||
),
|
||||
level = colors_level.color(record.level()),
|
||||
message = message,
|
||||
));
|
||||
})
|
||||
// set the default log level. to filter out verbose log messages from dependencies, set
|
||||
// this to Warn and overwrite the log level for your crate.
|
||||
.level(log::LevelFilter::Debug)
|
||||
// .level(log::LevelFilter::Warn)
|
||||
// change log levels for individual modules. Note: This looks for the record's target
|
||||
// field which defaults to the module path but can be overwritten with the `target`
|
||||
// parameter:
|
||||
// `info!(target="special_target", "This log message is about special_target");`
|
||||
// .level_for("dioxus", log::LevelFilter::Debug)
|
||||
// .level_for("dioxus", log::LevelFilter::Info)
|
||||
// .level_for("pretty_colored", log::LevelFilter::Trace)
|
||||
// output to stdout
|
||||
.chain(std::io::stdout())
|
||||
.apply()
|
||||
.unwrap();
|
||||
|
||||
debug!("finished setting up logging! yay!");
|
||||
}
|
||||
Reference in new issue
Block a user