Skip to content

Commit

Permalink
uneval slots test
Browse files Browse the repository at this point in the history
  • Loading branch information
dragazo committed Oct 23, 2023
1 parent e7cce43 commit a19c59d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/test/blocks/unevaluated-inputs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<blocks app="NetsBlox 2.1.4, http://netsblox.org" version="2.1.4"><block-definition collabId="item_-1_2" s="while %&apos;cond&apos; %&apos;f&apos;" type="command" category="custom"><header></header><code></code><translations></translations><inputs><input type="%boolUE"></input><input type="%cs"></input></inputs><script><block collabId="item_19" s="doForever"><script><block collabId="item_20" s="doIf"><block collabId="item_43" s="reportNot"><block collabId="item_22" s="evaluate"><block collabId="item_23" var="cond"/><list></list></block></block><script><block collabId="item_21" s="doReport"><l></l></block></script></block><block collabId="item_25" s="doRun"><block collabId="item_26" var="f"/><list></list></block></script></block></script></block-definition><block-definition collabId="item_2" s="main" type="reporter" category="custom"><header></header><code></code><translations></translations><inputs></inputs><script><block collabId="item_3" s="doDeclareVariables"><list><l>vals</l></list></block><block collabId="item_8" s="doSetVar"><l>vals</l><block collabId="item_7" s="reportNewList"><list></list></block></block><block collabId="item_12" s="doAddToList"><l>before</l><block collabId="item_16" var="vals"/></block><custom-block collabId="item_18" s="while %boolUE %cs"><block collabId="item_29" s="reportLessThan"><block collabId="item_27" s="reportListAttribute"><l><option>length</option></l><block collabId="item_28" var="vals"/></block><l>7</l></block><script><block collabId="item_34" s="doAddToList"><block collabId="item_36" s="reportJoinWords"><list><l>waiting... </l><block collabId="item_35" s="reportListAttribute"><l><option>length</option></l><block collabId="item_35_1" var="vals"/></block></list></block><block collabId="item_34_1" var="vals"/></block></script></custom-block><block collabId="item_14" s="doAddToList"><l>after</l><block collabId="item_17" var="vals"/></block><block collabId="item_5" s="doReport"><block collabId="item_6" var="vals"/></block></script></block-definition></blocks>
19 changes: 19 additions & 0 deletions src/test/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1752,6 +1752,25 @@ fn test_proc_list_combinations() {
});
}


#[test]
fn test_proc_unevaluated_inputs() {
let system = Rc::new(StdSystem::new_sync(BASE_URL.to_owned(), None, Config::default(), UtcOffset::UTC));
let (mut env, _) = get_running_proc(&format!(include_str!("templates/generic-static.xml"),
globals = "",
fields = "",
funcs = include_str!("blocks/unevaluated-inputs.xml"),
methods = "",
), Settings::default(), system);

run_till_term(&mut env, |mc, _, res| {
let expect = Value::from_json(mc, json!([
"before", "waiting... 1", "waiting... 2", "waiting... 3", "waiting... 4", "waiting... 5", "waiting... 6", "after",
])).unwrap();
assert_values_eq(&res.unwrap().0.unwrap(), &expect, 1e-5, "unevaluated inputs");
});
}

#[test]
fn test_proc_index_over_bounds() {
let system = Rc::new(StdSystem::new_sync(BASE_URL.to_owned(), None, Config::default(), UtcOffset::UTC));
Expand Down

0 comments on commit a19c59d

Please sign in to comment.