From 7b0cce752eca91696664c2bb0de3c5e0395f3fda Mon Sep 17 00:00:00 2001 From: Peter Pentchev Date: Tue, 10 Sep 2024 23:49:05 +0300 Subject: Add Peter Pentchev's Python solutions to 286 Also fix a couple of things in the other files: - make the TAP test functions accept an arrayref for the command to run instead of a single string, since we want to run the Python solution using `python3 -B -u /path/to/the/program` - fix the use of Test::More::skip() in the Self Spammer test function - fix a shadowed variable in the Order Game test function - correct the indentation in the documentation's "Implementation details" section - make the README file a copy of docs/index.md instead of a wrong copy of a completely different project's README file - point blog.txt to the Ringlet copy of this challenge's documentation --- challenge-286/ppentchev/tests/04-python-ch-2.t | 47 ++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 challenge-286/ppentchev/tests/04-python-ch-2.t (limited to 'challenge-286/ppentchev/tests/04-python-ch-2.t') diff --git a/challenge-286/ppentchev/tests/04-python-ch-2.t b/challenge-286/ppentchev/tests/04-python-ch-2.t new file mode 100644 index 0000000000..1d36b91a85 --- /dev/null +++ b/challenge-286/ppentchev/tests/04-python-ch-2.t @@ -0,0 +1,47 @@ +#!/usr/bin/perl +# SPDX-FileCopyrightText: Peter Pentchev +# SPDX-License-Identifier: BSD-2-Clause + +use v5.16; +use strict; +use warnings; + +use Test::More; + +use lib 'tests/lib'; + +use PWCTest::Ch286 qw( + find_python3 + test_order_game + test_order_game_count + test_order_game_default +); + +my $py3; +BEGIN { + $py3 = find_python3; +} + +if (!defined $py3) { + plan skip_all => 'no Python 3 interpreter found'; + exit 0; +} + +plan tests => 2; + +use constant PROG => 'python/scripts/ch-2.py'; + +my $py3_prog = [$py3, '-B', '-u', '--', PROG]; + +subtest order_game_default => sub { + test_order_game_default $py3_prog; +}; + +subtest order_game => sub { + plan tests => test_order_game_count; + for my $idx (1..test_order_game_count) { + subtest "run $idx" => sub { + test_order_game $py3_prog, $idx - 1; + }; + } +}; -- cgit