Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use assert_equal as well in access_test.exs

  • Loading branch information...
commit d997b24c0fe9e8bcdb052833849f4a2ebfbe26f3 1 parent 929f84f
@josevalim josevalim authored
Showing with 34 additions and 34 deletions.
  1. +34 −34 test/elixir/access_test.exs
View
68 test/elixir/access_test.exs
@@ -6,29 +6,29 @@ defmodule Access.TupleTest do
defrecord Config, other: { :a, :b, :c }
test :literal do
- assert { :a, :b, :c }[1] == :a
- assert Config.new.other[1] == :a
+ assert_equal :a, { :a, :b, :c }[1]
+ assert_equal :a, Config.new.other[1]
end
test :positive_integer do
tuple = { :a, :b, :c }
- assert tuple[0] == nil
- assert tuple[1] == :a
- assert tuple[2] == :b
- assert tuple[3] == :c
- assert tuple[4] == nil
+ assert_equal nil, tuple[0]
+ assert_equal :a, tuple[1]
+ assert_equal :b, tuple[2]
+ assert_equal :c, tuple[3]
+ assert_equal nil, tuple[4]
end
test :negative_integer do
tuple = { :a, :b, :c }
- assert tuple[-4] == nil
- assert tuple[-3] == :a
- assert tuple[-2] == :b
- assert tuple[-1] == :c
+ assert_equal nil, tuple[-4]
+ assert_equal :a, tuple[-3]
+ assert_equal :b, tuple[-2]
+ assert_equal :c, tuple[-1]
end
test :access do
- assert Tuple.access({ :a, :b, :c }, -1) == :c
+ assert_equal :c, Tuple.access({ :a, :b, :c }, -1)
end
end
@@ -36,23 +36,23 @@ defmodule Access.ListTest do
use ExUnit.Case
test :literal do
- assert 'abc'[%r(a)] == 'a'
+ assert_equal 'a', 'abc'[%r(a)]
end
test :regex do
list = 'abc'
- assert list[%r(b)] == 'b'
- assert list[%r(d)] == nil
+ assert_equal 'b', list[%r(b)]
+ assert_equal nil, list[%r(d)]
end
test :atom do
list = [foo: "bar"]
- assert list[:foo] == "bar"
- assert list[:bar] == nil
+ assert_equal "bar", list[:foo]
+ assert_equal nil, list[:bar]
end
test :access do
- assert List.access([foo: :bar ], :foo) == :bar
+ assert_equal :bar, List.access([foo: :bar ], :foo)
end
end
@@ -60,17 +60,17 @@ defmodule Access.BinaryTest do
use ExUnit.Case
test :literal do
- assert "abc"[%r(a)] == "a"
+ assert_equal "a", "abc"[%r(a)]
end
test :regex do
binary = "abc"
- assert binary[%r(b)] == "b"
- assert binary[%r(d)] == nil
+ assert_equal "b", binary[%r(b)]
+ assert_equal nil, binary[%r(d)]
end
test :access do
- assert Binary.access("abc", %r"a") == "a"
+ assert_equal "a", Binary.access("abc", %r"a")
end
end
@@ -80,24 +80,24 @@ defmodule Access.AtomTest do
defrecord Config, integer: 0
test :keywords do
- assert Config[] == { Config, 0 }
- assert Config[integer: 1] == { Config, 1 }
+ assert_equal { Config, 0 }, Config[]
+ assert_equal { Config, 1 }, Config[integer: 1]
end
test :in_guard_with_variable do
- assert get_var(Config.new) == 0
- assert get_var(Config.new(integer: 1)) == 1
+ assert_equal 0, get_var(Config.new)
+ assert_equal 1, get_var(Config.new(integer: 1))
end
test :in_guard_with_record_match do
- assert is_config(Config.new) == true
- assert is_config({ Access.AtomTest, 1 }) == false
- assert is_config({ Config, 1, 2 }) == false
+ assert_equal true, is_config(Config.new)
+ assert_equal false, is_config({ Access.AtomTest, 1 })
+ assert_equal false, is_config({ Config, 1, 2 })
end
test :in_guard_with_field_match do
- assert is_zero(Config.new) == true
- assert is_zero(Config.new(integer: 1)) == false
+ assert_equal true, is_zero(Config.new)
+ assert_equal false, is_zero(Config.new(integer: 1))
end
test :match do
@@ -110,7 +110,7 @@ defmodule Access.AtomTest do
end
defp is_zero(Config[integer: 0]), do: true
- defp is_zero(Config[integer: _]), do: false
+ defp is_zero(Config[integer: _]), do: false
defp is_config(Config[]), do: true
defp is_config(_), do: false
@@ -121,7 +121,7 @@ defmodule Access.FunctionTest do
test :any do
function = fn(x) -> x == :foo end
- assert function[:foo] == true
- assert function[:bar] == false
+ assert_equal true, function[:foo]
+ assert_equal false, function[:bar]
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.