88// TLA+-specific constraints such as identifier validity, reachability,
99// and determinism analysis.
1010
11- use anyhow:: { bail , Result } ;
11+ use anyhow:: { Result , bail } ;
1212use std:: collections:: { HashMap , HashSet , VecDeque } ;
1313
1414use crate :: abi:: StateMachine ;
@@ -25,10 +25,7 @@ use crate::abi::StateMachine;
2525pub fn validate_state_machine ( sm : & StateMachine ) -> Result < ( ) > {
2626 // Structural validation via ABI
2727 if let Err ( errors) = sm. validate ( ) {
28- bail ! (
29- "Structural validation failed:\n {}" ,
30- errors. join( "\n " )
31- ) ;
28+ bail ! ( "Structural validation failed:\n {}" , errors. join( "\n " ) ) ;
3229 }
3330
3431 // Check: machine name is a valid TLA+ identifier
@@ -211,15 +208,21 @@ pub fn find_nondeterministic_states(sm: &StateMachine) -> Vec<(String, usize)> {
211208#[ cfg( test) ]
212209mod tests {
213210 use super :: * ;
214- use crate :: abi:: { State , Transition , StateMachine } ;
211+ use crate :: abi:: { State , StateMachine , Transition } ;
215212
216213 /// Helper to build a simple state machine for testing.
217214 fn simple_machine ( ) -> StateMachine {
218215 StateMachine {
219216 name : "Test" . to_string ( ) ,
220217 states : vec ! [
221- State { name: "A" . into( ) , description: None } ,
222- State { name: "B" . into( ) , description: None } ,
218+ State {
219+ name: "A" . into( ) ,
220+ description: None ,
221+ } ,
222+ State {
223+ name: "B" . into( ) ,
224+ description: None ,
225+ } ,
223226 ] ,
224227 initial_state : "A" . into ( ) ,
225228 transitions : vec ! [ Transition {
@@ -260,9 +263,18 @@ mod tests {
260263 let sm = StateMachine {
261264 name : "Unreachable" . to_string ( ) ,
262265 states : vec ! [
263- State { name: "A" . into( ) , description: None } ,
264- State { name: "B" . into( ) , description: None } ,
265- State { name: "C" . into( ) , description: None } ,
266+ State {
267+ name: "A" . into( ) ,
268+ description: None ,
269+ } ,
270+ State {
271+ name: "B" . into( ) ,
272+ description: None ,
273+ } ,
274+ State {
275+ name: "C" . into( ) ,
276+ description: None ,
277+ } ,
266278 ] ,
267279 initial_state : "A" . into ( ) ,
268280 transitions : vec ! [ Transition {
@@ -286,15 +298,42 @@ mod tests {
286298 let sm = StateMachine {
287299 name : "NonDet" . to_string ( ) ,
288300 states : vec ! [
289- State { name: "A" . into( ) , description: None } ,
290- State { name: "B" . into( ) , description: None } ,
291- State { name: "C" . into( ) , description: None } ,
301+ State {
302+ name: "A" . into( ) ,
303+ description: None ,
304+ } ,
305+ State {
306+ name: "B" . into( ) ,
307+ description: None ,
308+ } ,
309+ State {
310+ name: "C" . into( ) ,
311+ description: None ,
312+ } ,
292313 ] ,
293314 initial_state : "A" . into ( ) ,
294315 transitions : vec ! [
295- Transition { from: "A" . into( ) , to: "B" . into( ) , guard: None , action: None , label: None } ,
296- Transition { from: "A" . into( ) , to: "C" . into( ) , guard: None , action: None , label: None } ,
297- Transition { from: "B" . into( ) , to: "C" . into( ) , guard: None , action: None , label: None } ,
316+ Transition {
317+ from: "A" . into( ) ,
318+ to: "B" . into( ) ,
319+ guard: None ,
320+ action: None ,
321+ label: None ,
322+ } ,
323+ Transition {
324+ from: "A" . into( ) ,
325+ to: "C" . into( ) ,
326+ guard: None ,
327+ action: None ,
328+ label: None ,
329+ } ,
330+ Transition {
331+ from: "B" . into( ) ,
332+ to: "C" . into( ) ,
333+ guard: None ,
334+ action: None ,
335+ label: None ,
336+ } ,
298337 ] ,
299338 variables : vec ! [ ] ,
300339 description : None ,
0 commit comments