Giter Site home page Giter Site logo

elixir-koans's Introduction

elixir-koans

Discover elixir lang by replacing "__?" and "assert_?" to make tests pass.

Install

  $ git clone [email protected]:dojo-toulouse/elixir-koans.git
  $ cd elixir-koans

Get deps

  $ mix deps.get

Compile

  $ mix compile

Launch

You can safely ignore warnings

  $ mix test

or

Launch with reload

 $ mix test.watch

Note: On Linux you may need to install inotify-tools for test.watch task.

[Advanced mix test options] (http://elixir-lang.org/docs/v1.0/mix/Mix.Tasks.Test.html)

elixir-koans's People

Contributors

acassaigne avatar alco avatar apieum avatar dustinfisher avatar gregmalcolm avatar hiemanshu avatar marcosx avatar markborcherding avatar msoedov avatar radar avatar real34 avatar styx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

elixir-koans's Issues

Issue in "Assertions are smart"

Hi all, I'm pretty new to Elixir and using this Koans to learn more about the language and I stumbled on the following issue (while meditating about "Assertions are smart"):

  • The assert function doesn't seem to be raising a ExUnit.ExpectationError anymore, instead it's raising a ExUnit.AssertionError.
  • The error message also seems to be different, it used to be "Expected 1 to be equal to 2" but now it is "Assertion with == failed"

Here is an example of changes I've made in my local copy

    think "Assertions are smart" do
        is_1_equal_2? = fn -> assert 1 == 2 end
        is_1_greater_than_2? = fn -> assert 1 > 2 end

        #This works:
        message = "Assertion with " <> "==" <> " failed"
        assert_raise ExUnit.AssertionError, message, is_1_equal_2?

        #This doesn't:
        message = "Expected 1 to be " <> __? <> " 2"
        assert_raise ExUnit.ExpectationError, message, is_1_greater_than_2?
    end

Looking at the code for version 1.0.4 (which is what I have now), it seems like we might need to update.

  def assert(value, message) when is_binary(message) do
    assert(value, message: message)
  end

  def assert(value, opts) when is_list(opts) do
    unless value, do: raise(ExUnit.AssertionError, opts)
    true
  end

from https://github.com/elixir-
lang/elixir/blob/a3dd9e247375bd99dbac115cdd6d11f08d71952f/lib/ex_unit/lib/ex_unit/assertions.ex

Let me know what you all think and I can make a PR if needed :)

Using "think" instead of "test" in about_named_function causes errors

There is a problem with scopes when using think in a test which needs to access methods defined externally.

For instance in about_name_function.exs replacing think with test for the first test causes the following error:

** (CompileError) about_named_function.exs:10: function hello/1 undefined
    src/elixir_translator.erl:40: :elixir_translator.translate_each/2
    lists.erl:1339: :lists.mapfoldl/3
    src/elixir_translator.erl:58: :elixir_translator.translate_each/2
    about_named_function.exs:10: About_Named_Functions (module)
    about_named_function.exs:9: About_Named_Functions (module)

After searching I found Module.eval_quoted which may be a solution, but I could not make it work.

Tested on Elixir v0.11.3-dev

Direction Going Forward?

Howdy,

I found these linked in the Awesome Elixir repo. I saw its been a while since anything was committed, and had been working on a similar project in the past but have learned enough since I want to generally scrap it. I was going to start over and thought forking this may be a great point.

However, if you plan on keeping actively developing it I would love to hear your plans and possibly just end up contributing via PR's instead of forking myself and needing to maintain it.

Great work! Hope to hear back.

Cheers,
Bobby

Compilation Error

Using Elixir 0.13.1 and Erlang 17.

When I run elixirc utils/Koans.ex
I get:

== Compilation error on file utils/Koans.ex ==
** (SyntaxError) utils/Koans.ex:32: unexpected comma. Parentheses are required to solve ambiguity in nested calls. Syntax error before: ','
    (elixir) lib/kernel/parallel_compiler.ex:89: anonymous fn/3 in Kernel.ParallelCompiler.spawn_compilers/8

I was going to use the koans as my first dive into Elixir, so I'm not able to pick out the wrong syntax in the file.

Any suggestions?

is koans the right word ?

When I've started it, it was just a background to play with friends in the koans way.
I think it is more a tour on elixir than a real exercise that emphasize the way of thinking in elixir and I don't want to induce errors in people minds with an inappropriate term.

I suggest to rename the repository elixir-tour.

Any objection ?

Can not start: "(Koans.MeditateWarning) Please meditate: you should start a ExUnit server to automatically run your test case"

I am fairly new to Elixir so I might be missing something obvious, but I can not start any koan from the repository.

$ elixirc utils/Koans.ex
$ ./path_to_enlightenment.exs
utils/Koans.ex:1: warning: redefining module Koans.MeditateWarning
utils/Koans.ex:9: warning: redefining module Koans
utils/Koans.ex:43: warning: redefining module Koans.About_testing
utils/Koans.ex:70: warning: redefining module FakeUnit.Case
** (Koans.MeditateWarning) Please meditate: you should start a ExUnit server to automatically run your test case
    utils/Koans.ex:30: Koans.meditate/1
    about_testing.exs:3: (file)
    (elixir) lib/code.ex:278: Code.load_file/2
    path_to_enlightenment.exs:5: (file)

Compile utils/Koans.ex fails with Elixir 1.0.0

$ elixirc utils/Koans.ex gives:

== Compilation error on file utils/Koans.ex ==
** (CompileError) utils/Koans.ex:2: undefined function defexception/3
(stdlib) lists.erl:1352: :lists.mapfoldl/3
(elixir) src/elixir_exp.erl:49: :elixir_exp.expand/2
(elixir) src/elixir.erl:206: :elixir.quoted_to_erl/3
(elixir) src/elixir_lexical.erl:17: :elixir_lexical.run/3

I use Elixir 1.0.0, installed with homebrew on OS X. And the installation seems to be ok. (No error and no warning on installation. And on my first steps in elixir everything worked fine.)

Code indent style violates published conventions

One of the first things I noticed when trying out these Koans is that the code is formatted with 4-space indentations rather than 2 spaces.

Here are the first three Elixir style guides returned from a Google search for "elixir code style guide". All three guides recommend or require 2-space indents.

https://github.com/niftyn8/elixir_style_guide#source-code-layout
https://github.com/rrrene/elixir-style-guide#code-readability
https://github.com/lexmag/elixir-style-guide#source-code-layout

I could reformat the source files if you'd like, but I wanted to run this by you first.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.