Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
293 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
title: "CSS: System font stack" | ||
category: CSS | ||
--- | ||
|
||
``` | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: Elixir metaprogramming | ||
category: Elixir | ||
--- | ||
|
||
## Kernel | ||
|
||
Most of these magic is defined in [Kernel.SpecialForms](http://devdocs.io/elixir/elixir/kernel.specialforms). | ||
|
||
### Pseudo-variables | ||
|
||
```elixir | ||
__DIR__ # current dir | ||
__MODULE__ # current module | ||
__CALLER__ # caller of the function | ||
``` | ||
|
||
### [`__ENV__`](http://devdocs.io/elixir/elixir/kernel.specialforms#__ENV__/0) | ||
|
||
```elixir | ||
Map.keys(__ENV__) | ||
[:__struct__, :aliases, :context, :context_modules, :export_vars, :file, | ||
:function, :functions, :lexical_tracker, :line, :macro_aliases, :macros, | ||
:module, :requires, :vars] | ||
``` | ||
|
||
```elixir | ||
__CALLER__.module |> Module.definitions_in |> IO.inspect | ||
``` | ||
|
||
```elixir | ||
apply(Enum, :reverse, [[1, 2, 3]]) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
--- | ||
title: ExUnit | ||
category: Elixir | ||
--- | ||
|
||
```elixir | ||
defmodule MyTest do | ||
use ExUnit.Case | ||
use ExUnit.Case, async: true # for async | ||
|
||
test "the truth" do | ||
assert 1 + 1 == 2 | ||
end | ||
end | ||
``` | ||
|
||
### Capture IO | ||
|
||
```elixir | ||
import ExUnit.CaptureIO | ||
|
||
test "capture io" do | ||
result = capture_io(fn -> | ||
IO.puts "sup" | ||
end) | ||
|
||
assert result == "sup\n" | ||
end | ||
``` | ||
|
||
### Capture logs | ||
|
||
```elixir | ||
config :ex_unit, capture_logs: true | ||
``` | ||
|
||
### Async | ||
|
||
```elixir | ||
defmodule AssertionTest do | ||
# run concurrently with other test cases | ||
use ExUnit.Case, async: true | ||
end | ||
``` | ||
|
||
### [Assertions](http://devdocs.io/elixir/ex_unit/exunit.assertions) | ||
|
||
```elixir | ||
assert x == y | ||
refute x == y | ||
|
||
assert_raise ArithmeticError, fn -> | ||
1 + "test" | ||
end | ||
|
||
assert_raise ArithmeticError, "message", fn -> ... | ||
assert_raise ArithmeticError, ~r/message/, fn -> ... | ||
|
||
flunk "This should've been an error" | ||
|
||
|
||
## Also see | ||
|
||
- <http://devdocs.io/elixir/ex_unit/exunit#configure/1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.