diff --git a/src/runtime2/tests/basics.rs b/src/runtime2/tests/basics.rs index 471394c34e84602b9d7197b13a54b41c0f5b4a79..0a3a06db525162b88b488d57b0e6ce94bd204458 100644 --- a/src/runtime2/tests/basics.rs +++ b/src/runtime2/tests/basics.rs @@ -1,6 +1,49 @@ use super::*; +#[test] +fn test_doing_nothing() { + // If this thing does not get into an infinite loop, (hence: the runtime + // exits), then the test works + const CODE: &'static str =" + primitive silent_willy(u32 loops) { + u32 index = 0; + while (index < loops) { + sync { index += 1; } + } + } + "; + + let thing = TestTimer::new("doing_nothing"); + run_test_in_runtime(CODE, |api| { + api.create_connector("", "silent_willy", ValueGroup::new_stack(vec![ + Value::UInt32(NUM_LOOPS), + ])).expect("create component"); + }); +} + +#[test] +fn test_local_sync_failure() { + // If the component exits cleanly, then the runtime exits cleanly, and the + // test will finish + const CODE: &'static str = " + primitive immediate_failure() { + u32[] only_allows_index_0 = { 1 }; + while (true) sync { // note the infinite loop + auto value = only_allows_index_0[1]; + } + } + "; + + let thing = TestTimer::new("immediate_local_failure"); + run_test_in_runtime(CODE, |api| { + api.create_connector("", "immediate_failure", ValueGroup::new_stack(Vec::new())) + .expect("create component"); + }) +} + + + #[test] fn test_single_put_and_get() { const CODE: &'static str = "