Skip to content

Commit 6b74116

Browse files
author
José Valim
committed
Remove namespaces from module names in defguard tests
Signed-off-by: José Valim <[email protected]>
1 parent 9565310 commit 6b74116

File tree

1 file changed

+40
-40
lines changed

1 file changed

+40
-40
lines changed

lib/elixir/test/elixir/kernel/guard_test.exs

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Kernel.GuardTest do
44
use ExUnit.Case, async: true
55

66
describe "Kernel.defguard(p) usage" do
7-
defmodule Guards.In.Macros do
7+
defmodule GuardsInMacros do
88
defguard is_foo(atom) when atom == :foo
99

1010
defmacro is_compile_time_foo(atom) when is_foo(atom) do
@@ -13,13 +13,13 @@ defmodule Kernel.GuardTest do
1313
end
1414

1515
test "guards can be used in other macros in the same module" do
16-
require Guards.In.Macros
17-
assert Guards.In.Macros.is_foo(:foo)
18-
refute Guards.In.Macros.is_foo(:baz)
19-
assert Guards.In.Macros.is_compile_time_foo(:foo)
16+
require GuardsInMacros
17+
assert GuardsInMacros.is_foo(:foo)
18+
refute GuardsInMacros.is_foo(:baz)
19+
assert GuardsInMacros.is_compile_time_foo(:foo)
2020
end
2121

22-
defmodule Guards.In.Funs do
22+
defmodule GuardsInFuns do
2323
defguard is_foo(atom) when atom == :foo
2424
defguard is_equal(foo, bar) when foo == bar
2525

@@ -29,19 +29,19 @@ defmodule Kernel.GuardTest do
2929
end
3030

3131
test "guards can be used in other funs in the same module" do
32-
require Guards.In.Funs
33-
assert Guards.In.Funs.is_foo(:foo)
34-
refute Guards.In.Funs.is_foo(:bar)
32+
require GuardsInFuns
33+
assert GuardsInFuns.is_foo(:foo)
34+
refute GuardsInFuns.is_foo(:bar)
3535
end
3636

3737
test "guards do not change code evaluation semantics" do
38-
require Guards.In.Funs
38+
require GuardsInFuns
3939
x = 1
40-
assert Guards.In.Funs.is_equal(x = 2, x) == false
40+
assert GuardsInFuns.is_equal(x = 2, x) == false
4141
assert x == 2
4242
end
4343

44-
defmodule Macros.In.Guards do
44+
defmodule MacrosInGuards do
4545
defmacro is_foo(atom) do
4646
quote do
4747
unquote(atom) == :foo
@@ -52,35 +52,35 @@ defmodule Kernel.GuardTest do
5252
end
5353

5454
test "macros can be used in other guards in the same module" do
55-
require Macros.In.Guards
56-
assert Macros.In.Guards.is_foobar(:foo)
57-
assert Macros.In.Guards.is_foobar(:bar)
58-
refute Macros.In.Guards.is_foobar(:baz)
55+
require MacrosInGuards
56+
assert MacrosInGuards.is_foobar(:foo)
57+
assert MacrosInGuards.is_foobar(:bar)
58+
refute MacrosInGuards.is_foobar(:baz)
5959
end
6060

61-
defmodule Guards.In.Guards do
61+
defmodule GuardsInGuards do
6262
defguard is_foo(atom) when atom == :foo
6363
defguard is_foobar(atom) when is_foo(atom) or atom == :bar
6464
end
6565

6666
test "guards can be used in other guards in the same module" do
67-
require Guards.In.Guards
68-
assert Guards.In.Guards.is_foobar(:foo)
69-
assert Guards.In.Guards.is_foobar(:bar)
70-
refute Guards.In.Guards.is_foobar(:baz)
67+
require GuardsInGuards
68+
assert GuardsInGuards.is_foobar(:foo)
69+
assert GuardsInGuards.is_foobar(:bar)
70+
refute GuardsInGuards.is_foobar(:baz)
7171
end
7272

73-
defmodule Default.Args do
73+
defmodule DefaultArgs do
7474
defguard is_divisible(value, remainder \\ 2)
7575
when is_integer(value) and rem(value, remainder) == 0
7676
end
7777

7878
test "permits default values in args" do
79-
require Default.Args
80-
assert Default.Args.is_divisible(2)
81-
refute Default.Args.is_divisible(1)
82-
assert Default.Args.is_divisible(3, 3)
83-
refute Default.Args.is_divisible(3, 4)
79+
require DefaultArgs
80+
assert DefaultArgs.is_divisible(2)
81+
refute DefaultArgs.is_divisible(1)
82+
assert DefaultArgs.is_divisible(3, 3)
83+
refute DefaultArgs.is_divisible(3, 4)
8484
end
8585

8686
test "doesn't allow matching in args" do
@@ -109,7 +109,7 @@ defmodule Kernel.GuardTest do
109109
end
110110
end
111111

112-
defmodule Integer.Private.Guards do
112+
defmodule IntegerPrivateGuards do
113113
defguardp is_even(value) when is_integer(value) and rem(value, 2) == 0
114114

115115
def is_even_and_large?(value) when is_even(value) and value > 100, do: true
@@ -121,28 +121,28 @@ defmodule Kernel.GuardTest do
121121
end
122122

123123
test "defguardp defines private guards that work inside and outside guard clauses" do
124-
assert Integer.Private.Guards.is_even_and_large?(102)
125-
refute Integer.Private.Guards.is_even_and_large?(98)
126-
refute Integer.Private.Guards.is_even_and_large?(99)
127-
refute Integer.Private.Guards.is_even_and_large?(103)
124+
assert IntegerPrivateGuards.is_even_and_large?(102)
125+
refute IntegerPrivateGuards.is_even_and_large?(98)
126+
refute IntegerPrivateGuards.is_even_and_large?(99)
127+
refute IntegerPrivateGuards.is_even_and_large?(103)
128128

129-
assert Integer.Private.Guards.is_even_and_small?(98)
130-
refute Integer.Private.Guards.is_even_and_small?(99)
131-
refute Integer.Private.Guards.is_even_and_small?(102)
132-
refute Integer.Private.Guards.is_even_and_small?(103)
129+
assert IntegerPrivateGuards.is_even_and_small?(98)
130+
refute IntegerPrivateGuards.is_even_and_small?(99)
131+
refute IntegerPrivateGuards.is_even_and_small?(102)
132+
refute IntegerPrivateGuards.is_even_and_small?(103)
133133

134134
assert_raise CompileError, ~r"cannot invoke local is_even/1 inside guard", fn ->
135-
defmodule Integer.Private.Guard.Utils do
136-
import Integer.Private.Guards
135+
defmodule IntegerPrivateGuardUtils do
136+
import IntegerPrivateGuards
137137

138138
def is_even_and_large?(value) when is_even(value) and value > 100, do: true
139139
def is_even_and_large?(_), do: false
140140
end
141141
end
142142

143143
assert_raise CompileError, ~r"undefined function is_even/1", fn ->
144-
defmodule Integer.Private.Function.Utils do
145-
import Integer.Private.Guards
144+
defmodule IntegerPrivateFunctionUtils do
145+
import IntegerPrivateGuards
146146

147147
def is_even_and_small?(value) do
148148
if is_even(value) and value <= 100, do: true, else: false

0 commit comments

Comments
 (0)