2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -1,3 +1,8 @@
Assertions are a way of breaking out of code when there is an error or an unexpected input. Some languages throw [[exceptions]] and some treat it as a break point.
Assertions are a way of breaking out of code when there is an error or an unexpected input.
Show an assertion in your language by asserting that an integer variable is equal to 42.
Some languages throw [[exceptions]] and some treat it as a break point.
;Task:
Show an assertion in your language by asserting that an integer variable is equal to '''42'''.
<br><br>

View file

@ -0,0 +1,11 @@
ExUnit.start
defmodule AssertionTest do
use ExUnit.Case
def return_5, do: 5
test "not equal" do
assert 42 == return_5
end
end

View file

@ -0,0 +1,2 @@
my $a = (1..100).pick;
$a == 42 or die '$a ain\'t 42';

View file

@ -1,8 +1,3 @@
my $a = (1..100).pick;
# with a (non-hygienic) macro
macro assert ($x) { "$x or die 'assertion failed: $x'" }
assert('$a == 42');
# but usually we just say
$a == 42 or die '$a ain\'t 42';