dojo-toulouse / elixir-koans Goto Github PK
View Code? Open in Web Editor NEWSmall exercises to discover elixir by testing
Small exercises to discover elixir by testing
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
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?
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)
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"):
assert
function doesn't seem to be raising a ExUnit.ExpectationError
anymore, instead it's raising a ExUnit.AssertionError
."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 :)
$ 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.)
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.
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
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 ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.