File tree Expand file tree Collapse file tree
lib/elixir_script_test/test Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -103,6 +103,31 @@ defmodule ElixirScript.Test.Assertions do
103103 end
104104 end
105105
106+ @ doc """
107+ Asserts that `value1` and `value2` differ by no more than `delta`
108+ """
109+ defmacro assert_in_delta ( value1 , value2 , delta , message \\ nil ) do
110+ % { file: file , line: line } = __CALLER__
111+
112+ quote [ file: file , line: line ] do
113+ try do
114+ ExUnit.Assertions . assert_in_delta (
115+ unquote ( value1 ) ,
116+ unquote ( value2 ) ,
117+ unquote ( delta ) ,
118+ unquote ( message )
119+ )
120+ rescue
121+ error in [ ExUnit.AssertionError ] ->
122+ ElixirScript.Test.Assertions . raise_elixir_script_assert (
123+ error ,
124+ unquote ( file ) ,
125+ unquote ( line )
126+ )
127+ end
128+ end
129+ end
130+
106131 @ doc """
107132 A negative assertion, expects the expression to be `false` or `nil`.
108133 """
@@ -143,6 +168,31 @@ defmodule ElixirScript.Test.Assertions do
143168 end
144169 end
145170
171+ @ doc """
172+ Asserts that `value1` and `value2` are not within `delta`
173+ """
174+ defmacro refute_in_delta ( value1 , value2 , delta , message \\ nil ) do
175+ % { file: file , line: line } = __CALLER__
176+
177+ quote [ file: file , line: line ] do
178+ try do
179+ ExUnit.Assertions . refute_in_delta (
180+ unquote ( value1 ) ,
181+ unquote ( value2 ) ,
182+ unquote ( delta ) ,
183+ unquote ( message )
184+ )
185+ rescue
186+ error in [ ExUnit.AssertionError ] ->
187+ ElixirScript.Test.Assertions . raise_elixir_script_assert (
188+ error ,
189+ unquote ( file ) ,
190+ unquote ( line )
191+ )
192+ end
193+ end
194+ end
195+
146196 @ doc """
147197 Fails with a message.
148198 """
You can’t perform that action at this time.
0 commit comments