test: stabilize nyash-rust --lib tests in release
This commit is contained in:
@ -498,6 +498,9 @@ pub mod builtin_impls;
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::sync::Mutex;
|
||||
|
||||
static BOX_FACTORY_POLICY_ENV_LOCK: Mutex<()> = Mutex::new(());
|
||||
|
||||
#[test]
|
||||
fn test_registry_creation() {
|
||||
@ -509,6 +512,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_default_policy_is_strict_plugin_first() {
|
||||
let _lock = BOX_FACTORY_POLICY_ENV_LOCK.lock().unwrap();
|
||||
let prev = crate::config::env::box_factory_policy();
|
||||
// Ensure NYASH_BOX_FACTORY_POLICY is not set
|
||||
crate::config::env::reset_box_factory_policy();
|
||||
@ -527,6 +531,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_env_policy_override() {
|
||||
let _lock = BOX_FACTORY_POLICY_ENV_LOCK.lock().unwrap();
|
||||
let prev = crate::config::env::box_factory_policy();
|
||||
|
||||
// Test builtin_first override
|
||||
@ -608,6 +613,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_plugin_override_with_env() {
|
||||
let _lock = BOX_FACTORY_POLICY_ENV_LOCK.lock().unwrap();
|
||||
// This test verifies that NYASH_USE_PLUGIN_BUILTINS or
|
||||
// NYASH_PLUGIN_OVERRIDE_TYPES allows plugins to override reserved types
|
||||
|
||||
@ -645,6 +651,9 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
let prev_policy = crate::config::env::box_factory_policy();
|
||||
let prev_override_types = std::env::var("NYASH_PLUGIN_OVERRIDE_TYPES").ok();
|
||||
|
||||
// Test with NYASH_PLUGIN_OVERRIDE_TYPES
|
||||
crate::config::env::set_box_factory_policy("strict_plugin_first"); // ensure plugin first
|
||||
std::env::set_var("NYASH_PLUGIN_OVERRIDE_TYPES", "StringBox");
|
||||
@ -653,7 +662,16 @@ mod tests {
|
||||
|
||||
// With override enabled, StringBox should not be rejected
|
||||
// (Note: has_type will be false because create_box fails, but registration shouldn't be rejected)
|
||||
std::env::remove_var("NYASH_PLUGIN_OVERRIDE_TYPES");
|
||||
if let Some(v) = prev_override_types {
|
||||
std::env::set_var("NYASH_PLUGIN_OVERRIDE_TYPES", v);
|
||||
} else {
|
||||
std::env::remove_var("NYASH_PLUGIN_OVERRIDE_TYPES");
|
||||
}
|
||||
if let Some(v) = prev_policy {
|
||||
crate::config::env::set_box_factory_policy(&v);
|
||||
} else {
|
||||
crate::config::env::reset_box_factory_policy();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@ -166,6 +166,7 @@ mod tests {
|
||||
assert!(info.all_latch_set());
|
||||
}
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
#[test]
|
||||
#[should_panic(expected = "Double latch set")]
|
||||
fn set_latch_incoming_double_set_panics_in_debug() {
|
||||
|
||||
@ -241,6 +241,7 @@ mod tests {
|
||||
let condition = canonical.facts.pattern1_simplewhile.as_ref().unwrap().condition.clone();
|
||||
let ctx = LoopPatternContext::new(&condition, &[], "composer_test", false, false);
|
||||
let mut builder = MirBuilder::new();
|
||||
builder.enter_function_for_test("composer_test".to_string());
|
||||
let loop_var_init = builder.alloc_typed(MirType::Integer);
|
||||
builder
|
||||
.variable_ctx
|
||||
@ -250,6 +251,7 @@ mod tests {
|
||||
try_compose_core_plan_via_normalizer(&mut builder, &canonical, &ctx)
|
||||
.expect("Ok");
|
||||
assert!(matches!(plan, Some(super::CorePlan::Loop(_))));
|
||||
builder.exit_function_for_test();
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@ -267,7 +267,7 @@ fn try_extract_step_shape(body: &[ASTNode]) -> Result<Option<StepShape>, Freeze>
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
mod tests_invariants {
|
||||
use super::{try_build_loop_facts, LoopFacts};
|
||||
use crate::ast::{ASTNode, BinaryOperator, LiteralValue, Span};
|
||||
use crate::mir::builder::control_flow::plan::facts::skeleton_facts::SkeletonKind;
|
||||
|
||||
@ -1,13 +1,18 @@
|
||||
#[cfg(debug_assertions)]
|
||||
use crate::mir::builder::MirBuilder;
|
||||
#[cfg(debug_assertions)]
|
||||
use crate::mir::join_ir::verify_phi_reserved::{
|
||||
analyze_distribution, disable_observation, enable_observation, get_observations,
|
||||
};
|
||||
#[cfg(debug_assertions)]
|
||||
use crate::mir::types::ConstValue;
|
||||
#[cfg(debug_assertions)]
|
||||
use crate::mir::MirInstruction;
|
||||
|
||||
/// Phase 72-1: Observe PHI dst distribution from MirBuilder usage
|
||||
///
|
||||
/// This test manually creates MIR scenarios to observe PHI dst allocation.
|
||||
#[cfg(debug_assertions)]
|
||||
#[test]
|
||||
fn test_phase72_observe_phi_dst_via_builder() {
|
||||
enable_observation();
|
||||
@ -103,3 +108,9 @@ fn test_phase72_observe_phi_dst_via_builder() {
|
||||
// This test always passes - it's for observation and decision-making
|
||||
assert!(true, "Observation complete - see output above for analysis");
|
||||
}
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
#[test]
|
||||
fn test_phase72_observe_phi_dst_via_builder() {
|
||||
assert!(true, "Observation test is debug-only");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user