From bb5ceb3978a99e9e25270e20ecbf349f31ad2fc4 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 18:10:39 +0000 Subject: [PATCH 1/3] Add unit tests for register_redis module Added unit tests in stdlib/src/redis.rs covering module registration, module metadata, export availability, arity check, function call execution, and arity error handling. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- stdlib/src/redis.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/stdlib/src/redis.rs b/stdlib/src/redis.rs index 8be06367..0d4c40de 100644 --- a/stdlib/src/redis.rs +++ b/stdlib/src/redis.rs @@ -30,3 +30,43 @@ impl StdlibRegistry { ); } } + +#[cfg(test)] +mod tests { + use super::*; + use techscript_runtime::context::{RuntimeConfig, RuntimeContext}; + + #[test] + fn test_register_redis() { + let mut registry = StdlibRegistry::new(); + registry.register_redis(); + + assert!(registry.has_module("std.redis")); + let module = registry.get_module("std.redis").unwrap(); + assert_eq!(module.name, "std.redis"); + assert_eq!(module.version, "1.0.0"); + assert!(module.required_capabilities.is_empty()); + assert!(module.exports.contains_key("connect")); + + let connect_fn = module.exports.get("connect").unwrap(); + assert_eq!(connect_fn.name(), "connect"); + assert_eq!(connect_fn.arity(), 1); + assert!(connect_fn.accepts_arity(1)); + assert!(!connect_fn.accepts_arity(0)); + + let mut ctx = RuntimeContext::new(RuntimeConfig::default()); + let res = connect_fn + .call( + &mut ctx, + vec![RuntimeValue::Str("redis://127.0.0.1:6379".to_string())], + ) + .unwrap(); + assert_eq!( + res, + RuntimeValue::Str("Redis not yet available".to_string()) + ); + + let err_res = connect_fn.call(&mut ctx, vec![]); + assert!(err_res.is_err()); + } +} From afc93ded5092bbaa38d22bb59c2bedf2e5d354d7 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 18:46:12 +0000 Subject: [PATCH 2/3] Add unit tests for register_redis module Added unit tests in stdlib/src/redis.rs covering module registration, module metadata, export availability, arity check, function call execution, and arity error handling. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> From 9d79b4e3554bb07d24406fe4d7046e83005d99db Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 27 Oct 2026 22:08:53 +0000 Subject: [PATCH 3/3] Add unit tests for register_redis module and fix threads example timing flakiness - Added unit tests in stdlib/src/redis.rs covering module registration, module metadata, export availability, arity check, function call execution, and arity error handling. - Increased sleep duration difference in examples/threads/threads.txs to eliminate thread scheduling flakiness on macOS runners. Co-authored-by: Tcode-Motion <188012755+Tcode-Motion@users.noreply.github.com> --- examples/threads/threads.txs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/threads/threads.txs b/examples/threads/threads.txs index 7396bb40..96d5b7db 100644 --- a/examples/threads/threads.txs +++ b/examples/threads/threads.txs @@ -6,12 +6,12 @@ spawn_fn = thread["spawn"] join_fn = thread["join"] do task_a() - time.sleep(100) + time.sleep(200) say "Task A completed on worker thread." end do task_b() - time.sleep(50) + time.sleep(20) say "Task B completed on worker thread." end