-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get some basic tests to work, and also print execution
Signed-off-by: Enrico Ghiorzi <[email protected]>
- Loading branch information
1 parent
05d9640
commit f64600d
Showing
25 changed files
with
427 additions
and
108 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
mod cs_builder; | ||
mod parser; | ||
|
||
use parser::*; | ||
|
||
pub use cs_builder::Sc2CsVisitor; | ||
pub use parser::Parser; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use anyhow::anyhow; | ||
use scan_fmt_xml::*; | ||
use std::{path::PathBuf, str::FromStr}; | ||
|
||
const MAXSTEP: usize = 1000; | ||
|
||
#[test] | ||
fn fsm() -> anyhow::Result<()> { | ||
test(PathBuf::from_str("./tests/test_fsm/model.xml")?) | ||
} | ||
|
||
#[test] | ||
fn datamodel() -> anyhow::Result<()> { | ||
test(PathBuf::from_str("./tests/test_datamodel/model.xml")?) | ||
} | ||
|
||
// #[test] | ||
// fn enumdata() -> anyhow::Result<()> { | ||
// test(PathBuf::from_str("./tests/test_enumdata/model.xml")?) | ||
// } | ||
|
||
#[test] | ||
fn send() -> anyhow::Result<()> { | ||
test(PathBuf::from_str("./tests/test_send/model.xml")?) | ||
} | ||
|
||
fn test(file: PathBuf) -> anyhow::Result<()> { | ||
let parser = Parser::parse(file)?; | ||
let mut model = Sc2CsVisitor::visit(parser)?; | ||
let mut steps = 0; | ||
assert!(!model.cs.possible_transitions().is_empty()); | ||
while let Some((pg_id, act, loc)) = model.cs.possible_transitions().first().cloned() { | ||
model.cs.transition(pg_id, act, loc)?; | ||
steps += 1; | ||
if steps >= MAXSTEP { | ||
return Err(anyhow!("step limit reached")); | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<scxml | ||
version="1.0" | ||
xmlns="http://www.w3.org/2005/07/scxml" | ||
datamodel="ecmascript" | ||
name="fsm" | ||
initial="idle"> | ||
|
||
<datamodel> | ||
<!-- TYPE state:TickResponse --> | ||
<data id="state" expr="FAILURE"/> | ||
</datamodel> | ||
|
||
<state id="idle"> | ||
<transition target="running" cond="state == FAILURE"/> | ||
</state> | ||
|
||
<state id="running"> | ||
<onentry> | ||
<assign location="state" expr="RUNNING"/> | ||
</onentry> | ||
<transition target="finished" cond="state == RUNNING"/> | ||
<onexit> | ||
<assign location="state" expr="SUCCESS"/> | ||
</onexit> | ||
</state> | ||
|
||
<state id="finished"/> | ||
</scxml> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<specification xmlns="..." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="..."> | ||
|
||
<model> | ||
|
||
<types path="./types.xml" /> | ||
|
||
<processList> | ||
<process id="fsm" moc="fsm" path="./fsm.scxml" /> | ||
</processList> | ||
|
||
</model> | ||
|
||
<properties path="./properties.xml"/> | ||
</specification> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.