Skip to content

Commit 2e75ba4

Browse files
committed
split point annotation contents by whitespace and interpret as multiple points
1 parent 553ab9a commit 2e75ba4

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

tmc-langs-framework/src/plugin.rs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,9 @@ pub trait LanguagePlugin {
470470
let (_, parsed) = res.map_err(|e| TmcError::PointParse(e.to_string()))?;
471471
for (_, parse) in parsed {
472472
if let Parse::Points(parsed) = parse {
473-
points.push(parsed);
473+
// a single points annotation can contain multiple whitespace separated points
474+
let split_points = parsed.split_whitespace().map(str::to_string);
475+
points.extend(split_points);
474476
}
475477
}
476478
}
@@ -614,7 +616,7 @@ mod test {
614616
Ok(())
615617
}
616618

617-
fn points_parser<'a>(i: &'a str) -> IResult<&'a str, &'a str> {
619+
fn points_parser(i: &str) -> IResult<&str, &str> {
618620
combinator::map(
619621
sequence::delimited(
620622
sequence::tuple((
@@ -1057,4 +1059,22 @@ force_update:
10571059
.join("extracted/test/some existing non-student file")
10581060
.exists())
10591061
}
1062+
1063+
#[test]
1064+
fn splits_points_by_whitespace() {
1065+
init();
1066+
1067+
let temp = tempfile::tempdir().unwrap();
1068+
file_to(
1069+
&temp,
1070+
"test/file",
1071+
r#"
1072+
@points("1 2 3 4")
1073+
@points(" 5 6 7 8 ")
1074+
"#,
1075+
);
1076+
1077+
let points = MockPlugin::get_available_points(temp.path()).unwrap();
1078+
assert_eq!(points, &["1", "2", "3", "4", "5", "6", "7", "8"]);
1079+
}
10601080
}

0 commit comments

Comments
 (0)