From 87ad60e5513cc2fbf2a32a2e7d94867e88a9f458 Mon Sep 17 00:00:00 2001 From: Keenan Gugeler Date: Tue, 26 Dec 2023 23:04:07 -0500 Subject: [PATCH] testsuite: add rust generator test This would have caught a failure on #1148. --- testsuite/rust_generator/README.md | 1 + testsuite/rust_generator/generator.rs | 14 ++++++++++++++ testsuite/rust_generator/init.yml | 5 +++++ testsuite/rust_generator/tests/AC/sol.py | 2 ++ testsuite/rust_generator/tests/AC/test.yml | 5 +++++ 5 files changed, 27 insertions(+) create mode 100644 testsuite/rust_generator/README.md create mode 100644 testsuite/rust_generator/generator.rs create mode 100644 testsuite/rust_generator/init.yml create mode 100644 testsuite/rust_generator/tests/AC/sol.py create mode 100644 testsuite/rust_generator/tests/AC/test.yml diff --git a/testsuite/rust_generator/README.md b/testsuite/rust_generator/README.md new file mode 100644 index 000000000..32e3f164a --- /dev/null +++ b/testsuite/rust_generator/README.md @@ -0,0 +1 @@ +This test checks that a generator, using rand, can be compiled and run in Rust. diff --git a/testsuite/rust_generator/generator.rs b/testsuite/rust_generator/generator.rs new file mode 100644 index 000000000..2cc3a971e --- /dev/null +++ b/testsuite/rust_generator/generator.rs @@ -0,0 +1,14 @@ +use rand::{Rng, SeedableRng}; + +type ConcreteRng = rand_xoshiro::Xoshiro256PlusPlus; + +fn main() { + let mut args = std::env::args(); + args.next(); + let mut rng = ConcreteRng::seed_from_u64(args.next().unwrap().parse().unwrap()); + + let x = rng.gen_range(0..10); + let y = rng.gen_range(0..10); + println!("{x} {y}"); + eprintln!("{}", x + y); +} diff --git a/testsuite/rust_generator/init.yml b/testsuite/rust_generator/init.yml new file mode 100644 index 000000000..34f86bfa2 --- /dev/null +++ b/testsuite/rust_generator/init.yml @@ -0,0 +1,5 @@ +generator: generator.rs +test_cases: +- {generator_args: [1], points: 10} +- {generator_args: [2], points: 10} +- {generator_args: [3], points: 30} diff --git a/testsuite/rust_generator/tests/AC/sol.py b/testsuite/rust_generator/tests/AC/sol.py new file mode 100644 index 000000000..3bd0380cc --- /dev/null +++ b/testsuite/rust_generator/tests/AC/sol.py @@ -0,0 +1,2 @@ +x, y = map(int, input().split()) +print(x + y) diff --git a/testsuite/rust_generator/tests/AC/test.yml b/testsuite/rust_generator/tests/AC/test.yml new file mode 100644 index 000000000..600fbc723 --- /dev/null +++ b/testsuite/rust_generator/tests/AC/test.yml @@ -0,0 +1,5 @@ +language: PY3 +time: 2 +memory: 65536 +source: sol.py +expect: [AC, AC, AC]