Skip to content

Commit

Permalink
Update syntax tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sagebind committed Feb 3, 2024
1 parent 8486a1c commit 5b01b64
Show file tree
Hide file tree
Showing 45 changed files with 964 additions and 966 deletions.
27 changes: 26 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
resolver = "2"
members = ["runtime", "shell", "stdlib", "syntax"]
default-members = ["shell"]

[workspace.package]
version = "0.2.0"
Expand Down
14 changes: 14 additions & 0 deletions runtime/tests/exit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,17 @@ async fn exit_throws_unrecoverable_exception() {
Err(e) => assert_eq!(e.message(), 1f64),
}
}
#[tokio::test]
async fn early_return() {
let result = riptide_runtime::eval(r#"
$test = {
return "early"
"normal"
}
test
"#).await;

assert_eq!(result.unwrap(), "early");
}
2 changes: 1 addition & 1 deletion syntax/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ difference = "2.0"
glob = "0.3"
log.workspace = true
stderrlog = "0.6"
serde_yaml = "0.9"
test-generator = "0.3"
toml = "0.8"

[dev-dependencies.serde]
workspace = true
Expand Down
6 changes: 3 additions & 3 deletions syntax/tests/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ struct ParserTest {

impl ParserTest {
fn load(path: impl AsRef<Path>) -> Result<Self, Box<dyn Error>> {
Ok(toml::from_str(&fs::read_to_string(path)?)?)
Ok(serde_yaml::from_str(&fs::read_to_string(path)?)?)
}

fn save(&self, path: impl AsRef<Path>) -> Result<(), Box<dyn Error>> {
Ok(fs::write(path, toml::to_string_pretty(self)?)?)
Ok(fs::write(path, serde_yaml::to_string(self)?)?)
}
}

#[test_generator::test_resources("syntax/tests/parser/**/*.toml")]
#[test_generator::test_resources("syntax/tests/parser/**/*.yaml")]
fn parser_test(path: &str) {
let path = &path[7..];
let mut test = ParserTest::load(path).unwrap();
Expand Down
49 changes: 0 additions & 49 deletions syntax/tests/parser/block-named-params.toml

This file was deleted.

47 changes: 47 additions & 0 deletions syntax/tests/parser/block-named-params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
source: |
call <left, right> {
println
}
ast: |-
Block {
span: Some(
Span(3:1, 4:36),
),
named_params: None,
vararg_param: None,
statements: [
Pipeline(
[
Named {
function: "call",
args: [
Expr(
Block {
span: Some(
Span(3:6, 3:35),
),
named_params: Some(
[
"left",
"right",
],
),
vararg_param: None,
statements: [
Pipeline(
[
Named {
function: "println",
args: [],
},
],
),
],
},
),
],
},
],
),
],
}
107 changes: 0 additions & 107 deletions syntax/tests/parser/block-syntax.toml

This file was deleted.

Loading

0 comments on commit 5b01b64

Please sign in to comment.