0.3.0-0-pre.3
This commit is contained in:
27
crates/apps/game-snake-poc-wasm/unit_tests/runtime.rs
Normal file
27
crates/apps/game-snake-poc-wasm/unit_tests/runtime.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
// file: crates/apps/game-snake-poc-wasm/unit_tests/runtime.rs
|
||||
// version: 1
|
||||
|
||||
#[test]
|
||||
fn direction_is_queued_without_advancing_simulation() {
|
||||
let mut game = crate::SnakeWasmGame::new();
|
||||
let before_x = game.rectangle_x(1);
|
||||
let before_y = game.rectangle_y(1);
|
||||
game.up();
|
||||
assert_eq!(game.rectangle_x(1), before_x);
|
||||
assert_eq!(game.rectangle_y(1), before_y);
|
||||
game.tick();
|
||||
assert_eq!(game.rectangle_x(1), before_x);
|
||||
assert!(game.rectangle_y(1) < before_y);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn scene_and_status_are_exposed_for_canvas_host() {
|
||||
let game = crate::SnakeWasmGame::new();
|
||||
assert_eq!(game.score(), 0);
|
||||
assert_eq!(game.length(), 3);
|
||||
assert_eq!(game.rectangle_count(), 4);
|
||||
assert!(game.rectangle_width(0) > 0.0);
|
||||
assert!(game.rectangle_height(0) > 0.0);
|
||||
assert_eq!(game.rectangle_x(99), -1.0);
|
||||
assert_eq!(game.rectangle_y(99), -1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user