/battle_asserts

issues for codebattle games

Primary LanguageClojureEclipse Public License 1.0EPL-1.0

Build Status Hexlet chat

Setup for development

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Make changes
  4. Run tests (lein test).
  5. Commit your changes (git commit -am 'Added some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new Pull Request
  8. Check if Request passed Travis-Ci

How to add a new source

  1. Create yaml file with the name of your issue. Look at the example

    # source/array_fetch.yml
    level: easy # (elementary|easy|medium|hard)
    tags: [string, numbers]
    author:
      github_nickname: your_name
      web_page: "http://your.site"
    description: |
      This is description.
      The description can be multiline.
    multicode_checks:
      langs: [javascript, php] #[ruby, javascript, python, php]

    Example: array_fetch.yml

  2. Create a .clj file in the test/battle_solutions folder, e.g. array_fetch_test.clj

  • Write a test by defining a function (deftest test-asserts ()) Look at the example

    ; test/battle_solutions/array_fetch_test.clj
    (deftest test-asserts
      (let [arr [\a \b \c]]
      (assert-equal \b (fetch arr 1 \d))
      (assert-equal \d (fetch arr 5 \d))
      (assert-equal \c (fetch arr -1 \d))
      (assert-equal \d (fetch arr -5 \d))))
  • Write a namespace with your issue name

    ; test/battle_solutions/array_fetch_test.clj
    (ns battle-solutions.array-fetch-test
      (:require [clojure.test :refer :all]
                [battle-asserts.test-helper :refer [assert-equal assert]]))
  • Write a function to resolve your tests

    ; test/battle_solutions/array_fetch_test.clj
    (defn fetch
      [s index default]
      (let [positive-index (if (> index 0) index (+ (count s) index))]
        (nth s positive-index default)))

Example: array_fetch_test.clj

  1. Run tests
lein test

If you want to run test for only one issue - use lein test + namespace

lein test battle-solutions.array-fetch-test
  1. Run code format
make format

Problems and exercises

PHP

Python

Go

Erlang

Ruby

javascript

Related links

Leiningen

Bitdeli Badge