Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@

### Checklist

- [ ] If this PR adds or changes a language feature, it is used in
`examples/kitchen_sink.simf`, and `test-data/kitchen_sink.json` is
regenerated.
- [ ] New or changed language features are used in `fixtures/kitchen_sink.simf` (see its header).
File renamed without changes.
File renamed without changes.
9 changes: 7 additions & 2 deletions examples/kitchen_sink.simf → fixtures/kitchen_sink.simf
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,14 @@ simc ">=0.8.0";
* the `kitchen_sink` regression test.
*
* This program is not a meaningful contract. When adding a language feature,
* extend this file and regenerate `test-data/kitchen_sink.json`.
* extend this file and regenerate `test-data/kitchen_sink.json`, adding a `-Z`
* flag for any new unstable feature:
*
* Requires -Z imports -Z enums -Z raw_hash.
* simc fixtures/kitchen_sink.simf -a fixtures/kitchen_sink.args \
* -w fixtures/kitchen_sink.wit -Z imports -Z enums -Z raw_hash \
* --debug --json | jq '{program, witness}' > test-data/kitchen_sink.json
*
* `--debug` is needed because the regression test compiles with debug symbols.
*/

// Type aliases, both of custom types and of builtin aliases
Expand Down
File renamed without changes.
31 changes: 19 additions & 12 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1129,7 +1129,7 @@ pub(crate) mod tests {

#[test]
fn regression_153() {
TestCase::program_file("./examples/array_fold_2n.simf")
TestCase::program_file("./fixtures/array_fold_2n.simf")
.with_witness_values(WitnessValues::default())
.assert_run_success();
}
Expand Down Expand Up @@ -1192,11 +1192,11 @@ pub(crate) mod tests {
#[cfg(feature = "serde")]
fn kitchen_sink() {
TestCase::template_file_with_unstable(
"./examples/kitchen_sink.simf",
"./fixtures/kitchen_sink.simf",
UnstableFeatures::all(),
)
.with_argument_file("./examples/kitchen_sink.args")
.with_witness_file("./examples/kitchen_sink.wit")
.with_argument_file("./fixtures/kitchen_sink.args")
.with_witness_file("./fixtures/kitchen_sink.wit")
.assert_run_success();
}

Expand Down Expand Up @@ -1586,18 +1586,21 @@ fn main() {
}

fn regression_test_with_features(name: &str, features: crate::UnstableFeatures) {
regression_test_in("./examples", name, features);
}

/// Compare the encoding of `<dir>/<name>.simf` with `test-data/<name>.json`.
fn regression_test_in(dir: &str, name: &str, features: crate::UnstableFeatures) {
let program = serde_json::from_str::<Program>(
std::fs::read_to_string(format!("./test-data/{}.json", name))
.unwrap()
.as_str(),
)
.unwrap();

let template = TestCase::template_file_with_unstable(
format!("./examples/{}.simf", name),
features,
);
let arguments_path = format!("./examples/{}.args", name);
let template =
TestCase::template_file_with_unstable(format!("{dir}/{name}.simf"), features);
let arguments_path = format!("{dir}/{name}.args");
let test_case = if std::path::Path::new(&arguments_path).exists() {
template.with_argument_file(arguments_path)
} else {
Expand All @@ -1606,7 +1609,7 @@ fn main() {
match program.witness {
Some(wit) => {
let (new_program, new_witness) = test_case
.with_witness_file(format!("./examples/{}.wit", name))
.with_witness_file(format!("{dir}/{name}.wit"))
.get_encoding_with_witness();
assert_eq!(
program.program, new_program,
Expand All @@ -1630,7 +1633,11 @@ fn main() {

#[test]
fn array_fold_2n_regression() {
regression_test("array_fold_2n");
regression_test_in(
"./fixtures",
"array_fold_2n",
crate::UnstableFeatures::none(),
);
}

#[test]
Expand Down Expand Up @@ -1670,7 +1677,7 @@ fn main() {

#[test]
fn kitchen_sink_regression() {
regression_test_with_features("kitchen_sink", crate::UnstableFeatures::all());
regression_test_in("./fixtures", "kitchen_sink", crate::UnstableFeatures::all());
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion tests/lex_lossless_coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ mod lossless_test {
}

test_lex_coverage! {
array_fold_2n_lossless: "array_fold_2n.simf",
array_fold_2n_lossless: "../fixtures/array_fold_2n.simf",
array_fold_lossless: "array_fold.simf",
cat_lossless: "cat.simf",
ctv_lossless: "ctv.simf",
Expand Down
Loading