Skip to main content

shape_vm/feature_tests/
mod.rs

1//! Automatic feature coverage tracking for Interpreter/VM/JIT parity
2//!
3//! This module provides:
4//! 1. Grammar feature definitions extracted from pest (via build.rs)
5//! 2. Feature test case definitions
6//! 3. Coverage gap detection
7//! 4. Three-way parity testing (Interpreter vs VM vs JIT)
8
9// Include auto-generated grammar rules from build.rs
10include!(concat!(env!("OUT_DIR"), "/grammar_features.rs"));
11
12// ============================================================================
13// Submodules
14// ============================================================================
15
16pub mod annotation_tests;
17pub mod backends;
18pub mod coverage;
19pub mod definitions;
20pub mod jit_analysis;
21pub mod module_tests;
22pub mod parity;
23pub mod parity_runner;
24pub mod pattern_tests;
25pub mod query_tests;
26pub mod stream_tests;
27pub mod testing_framework_tests;
28pub mod type_system_tests;
29pub mod window_tests;
30
31// ============================================================================
32// Feature Registry - tracks all declared test cases
33// ============================================================================
34
35/// A single feature test case
36#[derive(Debug, Clone)]
37pub struct FeatureTest {
38    /// Unique name of the test
39    pub name: &'static str,
40    /// Grammar rule(s) this test covers
41    pub covers: &'static [&'static str],
42    /// Shape code to execute
43    pub code: &'static str,
44    /// Function to call
45    pub function: &'static str,
46    /// Category (expression, statement, control_flow, etc.)
47    pub category: FeatureCategory,
48    /// Whether this test requires market data
49    pub requires_data: bool,
50}
51
52#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
53pub enum FeatureCategory {
54    /// Literal values (numbers, strings, booleans)
55    Literal,
56    /// Arithmetic and comparison operators
57    Operator,
58    /// Control flow (if, match, loops)
59    ControlFlow,
60    /// Variable declarations and assignments
61    Variable,
62    /// Function definitions and calls
63    Function,
64    /// Array and object operations
65    Collection,
66    /// Domain-specific (data rows, series, indicators)
67    Domain,
68    /// Exception handling
69    Exception,
70    /// Type system features
71    TypeSystem,
72    /// Module system
73    Module,
74}
75
76// ============================================================================
77// Aggregated Feature Tests
78// ============================================================================
79
80/// Returns all feature tests from all modules for coverage analysis
81pub fn all_feature_tests() -> Vec<&'static FeatureTest> {
82    let mut all = Vec::new();
83    all.extend(definitions::FEATURE_TESTS.iter());
84    all.extend(type_system_tests::TESTS.iter());
85    all.extend(module_tests::TESTS.iter());
86    all.extend(pattern_tests::TESTS.iter());
87    all.extend(query_tests::TESTS.iter());
88    all.extend(window_tests::TESTS.iter());
89    all.extend(stream_tests::TESTS.iter());
90    all.extend(annotation_tests::TESTS.iter());
91    all.extend(testing_framework_tests::TESTS.iter());
92    all
93}
94
95// ============================================================================
96// Re-exports
97// ============================================================================
98
99pub use backends::{BackendExecutor, InterpreterBackend, JITBackend, VMBackend};
100pub use coverage::{CoverageReport, analyze_coverage};
101pub use definitions::FEATURE_TESTS as MANUAL_FEATURE_TESTS;
102pub use jit_analysis::{JitAnalysis, analyze_jit_support};
103pub use parity::{ExecutionResult, ParityResult, ParityStatus};
104pub use parity_runner::{ParityReport, ParityRunner};