Skip to content

Commit

Permalink
Updated library doc tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
azriel91 committed Aug 1, 2019
1 parent 97d3d4f commit ecb908d
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 18 deletions.
46 changes: 31 additions & 15 deletions amethyst_test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,30 @@
//! Next, attach the logic you wish to test using the various `.with_*(..)` methods:
//!
//! ```rust,no_run
//! # use amethyst::{
//! # core::{bundle::SystemBundle, SystemDesc},
//! # derive::SystemDesc,
//! # ecs::prelude::*,
//! # prelude::*,
//! # };
//! #
//! # #[derive(Debug, SystemDesc)]
//! # struct MySystem;
//! #
//! # impl<'s> System<'s> for MySystem {
//! # type SystemData = ();
//! # fn run(&mut self, _: Self::SystemData) {}
//! # }
//! #
//! #[test]
//! fn test_name() {
//! let visibility = false; // Whether the window should be shown
//! AmethystApplication::render_base::<String, String, _>("test_name", visibility)
//! .with_bundle(MyBundle::new()) // Registers a bundle.
//! .with_bundle_fn(|| MyNonSendBundle::new()) // Registers a `!Send` bundle.
//! .with_resource(MyResource::new()) // Adds a resource to the world.
//! .with_system(|_| MySystem::new(), "my_sys", &[]) // Registers a system with the main
//! // dispatcher.
//! .with_system(MySystem, "my_sys", &[]) // Registers a system with the main
//! // dispatcher.
//!
//! // These are run in the order they are invoked.
//! // You may invoke them multiple times.
Expand Down Expand Up @@ -159,34 +174,31 @@
//! ```rust
//! # use amethyst_test::prelude::*;
//! # use amethyst::{
//! # core::bundle::SystemBundle,
//! # core::{bundle::SystemBundle, SystemDesc},
//! # derive::SystemDesc,
//! # ecs::prelude::*,
//! # prelude::*,
//! # };
//! #
//! # #[derive(Debug)]
//! # struct ApplicationResource;
//! #
//! # #[derive(Debug)]
//! # #[derive(Debug, SystemDesc)]
//! # #[system_desc(insert(ApplicationResource))]
//! # struct MySystem;
//! #
//! # impl<'s> System<'s> for MySystem {
//! # type SystemData = ReadExpect<'s, ApplicationResource>;
//! #
//! # fn run(&mut self, _: Self::SystemData) {}
//! #
//! # fn setup(&mut self, world: &mut World) {
//! # Self::SystemData::setup(world);
//! # world.insert(ApplicationResource);
//! # }
//! # }
//! #
//! # #[derive(Debug)]
//! # struct MyBundle;
//! # impl<'a, 'b> SystemBundle<'a, 'b> for MyBundle {
//! # fn build(self, _world: &mut World, builder: &mut DispatcherBuilder<'a, 'b>)
//! # fn build(self, world: &mut World, builder: &mut DispatcherBuilder<'a, 'b>)
//! # -> amethyst::Result<()> {
//! # builder.add(MySystem, "my_system", &[]);
//! # builder.add(MySystem.build(world), "my_system", &[]);
//! # Ok(())
//! # }
//! # }
Expand All @@ -212,6 +224,8 @@
//! ```rust
//! # use amethyst_test::prelude::*;
//! # use amethyst::{
//! # core::SystemDesc,
//! # derive::SystemDesc,
//! # ecs::prelude::*,
//! # prelude::*,
//! # };
Expand All @@ -222,7 +236,7 @@
//! # type Storage = DenseVecStorage<Self>;
//! # }
//! #
//! # #[derive(Debug)]
//! # #[derive(Debug, SystemDesc)]
//! # struct MySystem;
//! #
//! # impl<'s> System<'s> for MySystem {
Expand All @@ -239,7 +253,7 @@
//! fn system_increases_component_value_by_one() {
//! assert!(
//! AmethystApplication::blank()
//! .with_system(|_| MySystem, "my_system", &[])
//! .with_system(MySystem, "my_system", &[])
//! .with_effect(|world| {
//! let entity = world.create_entity().with(MyComponent(0)).build();
//! world.insert(EffectReturn(entity));
Expand Down Expand Up @@ -271,14 +285,16 @@
//! ```rust
//! # use amethyst_test::prelude::*;
//! # use amethyst::{
//! # core::SystemDesc,
//! # derive::SystemDesc,
//! # ecs::prelude::*,
//! # prelude::*,
//! # };
//! #
//! # // !Default
//! # struct MyResource(pub i32);
//! #
//! # #[derive(Debug)]
//! # #[derive(Debug, SystemDesc)]
//! # struct MySystem;
//! #
//! # impl<'s> System<'s> for MySystem {
Expand All @@ -296,7 +312,7 @@
//! .with_setup(|world| {
//! world.insert(MyResource(0));
//! })
//! .with_system_single(|_| MySystem, "my_system", &[])
//! .with_system_single(MySystem, "my_system", &[])
//! .with_assertion(|world| {
//! let my_resource = world.read_resource::<MyResource>();
//!
Expand Down
15 changes: 12 additions & 3 deletions src/game_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,12 @@ impl<'a, 'b> GameDataBuilder<'a, 'b> {
/// # Examples
///
/// ~~~no_run
/// use amethyst::derive::SystemDesc;
/// use amethyst::core::SystemDesc;
/// use amethyst::prelude::*;
/// use amethyst::ecs::prelude::System;
/// use amethyst::ecs::prelude::{System, SystemData, World};
///
/// #[derive(SystemDesc)]
/// struct NopSystem;
/// impl<'a> System<'a> for NopSystem {
/// type SystemData = ();
Expand Down Expand Up @@ -156,9 +159,12 @@ impl<'a, 'b> GameDataBuilder<'a, 'b> {
/// # Examples
///
/// ~~~no_run
/// use amethyst::core::SystemDesc;
/// use amethyst::derive::SystemDesc;
/// use amethyst::prelude::*;
/// use amethyst::ecs::prelude::System;
/// use amethyst::ecs::prelude::{System, SystemData, World};
///
/// #[derive(SystemDesc)]
/// struct NopSystem;
/// impl<'a> System<'a> for NopSystem {
/// type SystemData = ();
Expand Down Expand Up @@ -219,9 +225,12 @@ impl<'a, 'b> GameDataBuilder<'a, 'b> {
/// # Examples
///
/// ~~~no_run
/// use amethyst::core::SystemDesc;
/// use amethyst::derive::SystemDesc;
/// use amethyst::prelude::*;
/// use amethyst::ecs::prelude::System;
/// use amethyst::ecs::prelude::{System, SystemData, World};
///
/// #[derive(SystemDesc)]
/// struct NopSystem;
/// impl<'a> System<'a> for NopSystem {
/// type SystemData = ();
Expand Down

0 comments on commit ecb908d

Please sign in to comment.