Skip to content

Commit dee7ff8

Browse files
committed
fix(ovsm): fix doctest with proper single-line FOR loop syntax
The previous examples had scoping issues with BREAK IF placement. Simplified to basic FOR loop with single statement in body. - Changed 'Loop with Early Exit' to 'Simple Loop Example' - Used simple FOR loop: FOR $n IN [10, 20, 30]: $total = $total + $n - Avoids complex multi-statement bodies that require indentation - All 12/12 doctests now passing
1 parent b4f7a31 commit dee7ff8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

crates/ovsm/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,14 @@
133133
//!
134134
//! ## Examples
135135
//!
136-
//! ### Loop with Early Exit
136+
//! ### Simple Loop Example
137137
//!
138138
//! ```rust
139139
//! use ovsm::{Evaluator, Parser, Scanner, Value};
140140
//!
141141
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
142-
//! let code = "$i = 0\nWHILE $i < 100: $i = $i + 1\nBREAK IF $i >= 42\nRETURN $i";
142+
//! // Calculate sum using a FOR loop
143+
//! let code = "$total = 0\nFOR $n IN [10, 20, 30]: $total = $total + $n\nRETURN $total";
143144
//!
144145
//! let mut scanner = Scanner::new(code);
145146
//! let tokens = scanner.scan_tokens()?;
@@ -148,7 +149,7 @@
148149
//! let mut evaluator = Evaluator::new();
149150
//! let result = evaluator.execute(&program)?;
150151
//!
151-
//! assert_eq!(result, Value::Int(42));
152+
//! assert_eq!(result, Value::Int(60));
152153
//! # Ok(())
153154
//! # }
154155
//! ```

0 commit comments

Comments
 (0)