- Fork it
- Clone repo (
https://github.com/{your-nickname}/battle_asserts.git
) - Create your feature branch (
git checkout -b my-new-feature
) - Make changes
- Run tests (
make test
) - Run linters (
make checks
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
- Check if Request passed GithubActions
- Wait, until PR is reviewed
You can generate issue template by command make generate-template
with hints.
A description of the issue includes:
level
— difficulty of the problem; possible values areelementary
,easy
,medium
,hard
.description
— detailed description of the issue. Now supported languages isru
anden
,en
is required. You can runmake check-translations
for list current translation progress.tags
— tags that provide additional info about task, array of strings.signature
— function signature; map withinput
andoutput
types. Available typesinteger
,float
,string
,array
,hash (map, dicts)
. See examples in the existing issues.test-data
— data in a specified format which will be used to test solutions. The first element in this list will be displayed as an example to players, so it should clarify and illustrate the problem as much as possible. Do not choose a trivial case for this example.
Example:
(ns battle-asserts.issues.array_sum)
(def level :elementary)
(def tags ["training" "collections"])
(def description
{:en "Calculate the sum of array." :ru "Рассчитайте сумму всех чисел в массиве."})
(def signature
{:input [{:argument-name "numbers" :type {:name "arr" :nested {:name "integer"}}}]
:output {:type {:name "integer"}}})
(def test-data
[{:expected 1 :arguments [[1]]}
{:expected 0 :arguments [[]]}
{:expected 10 :arguments [[1 2 3 4]]}])
See examples in src/battle_asserts/issues/*.clj
An implementation of the issue includes:
arguments-generator
— arguments generator for thesolution
function; generated arguments will be used to test players' solutions.solution
— implemented correct solution. Example:
(ns battle-asserts.issues.array_sum)
(def level :elementary)
(def tags ["training" "collections"])
(def description
{:en "Calculate the sum of array." :ru "Рассчитайте сумму всех чисел в массиве."})
(def signature
{:input [{:argument-name "numbers" :type {:name "arr" :nested {:name "integer"}}}]
:output {:type {:name "integer"}}})
(def test-data
[{:expected 1 :arguments [[1]]}
{:expected 0 :arguments [[]]}
{:expected 10 :arguments [[1 2 3 4]]}])
(defn arguments-generator []
(gen/tuple (gen/list gen/small-integer))
(defn solution [numbers]
(apply + numbers))
Corresponding tests are in test/test_helper.clj
there is no need to add tests to this file, because tests runs dynamically, depending on the described signature
, test-data
, arguments-generator
and solution
.
run-solution-spec-test
tests are checking that result type of solving issue is correct.run-generator-spec-test
tests are checking that input signatures are correctly described forarguments-generator
.run-solution-test
tests are checking that test data solves correctly.run-test-data-spec-test
tests are checking that test data corresponds to signature.run-description-test
tests are checking that issue has minimal description.run-difficulty-test
tests are checking that issue has correct difficulty level.
It will appear with auto-generated asserts on codebattle after merge.
Thanks for your interest in the project and happy hacking!